How to get source bundles when using tycho-p2-extras to mirror an eclipse p2 repository - eclipse-rcp

I want to create a mirror of an eclipse p2 repository containing the needed ius for building an rcp application. The mirroring did work and the needed bundles are locally stored. I can reference them from my tycho build and from my eclipse ide. It works but the targetdefinition file, containing the folder of the eclipse p2 mirror, complains about the missing source bundles.
I read and tried the switches tycho-p2-extras offers but no switch seems to solve that problem.
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-p2-extras-plugin</artifactId>
<version>${tycho.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>mirror</goal>
</goals>
</execution>
</executions>
<configuration>
<source>
<!-- source repositories to mirror from -->
<!-- supported layouts are "p2-metadata", "p2-artifacts", and "p2"
(for joint repositories; default) -->
<repository>
<id>eclipse-2018-09</id>
<url>http://download.eclipse.org/releases/2018-09</url>
<layout>p2</layout>
</repository>
<repository>
<id>eclipse-2018-09-tech</id>
<url>https://download.eclipse.org/technology/epp/packages/2018-09/</url>
<layout>p2</layout>
</repository>
</source>
<!-- List of IUs to mirror. If omitted, allIUs will be mirrored. -->
<!-- Omitted IU version element means latest version of the IU -->
<ius>
<iu>
<id>org.eclipse.e4.rcp.feature.group</id>
</iu>
<iu>
<id>org.eclipse.emf.common.feature.group</id>
</iu>
<iu>
<id>org.eclipse.emf.ecore.feature.group</id>
</iu>
<iu>
<id>org.eclipse.equinox.executable.feature.group</id>
</iu>
<iu>
<id>org.eclipse.ui.themes</id>
</iu>
<iu>
<id>org.objectweb.asm</id>
</iu>
<iu>
<id>org.eclipse.swt</id>
</iu>
</ius>
<!-- The destination directory to mirror to. -->
<destination>${project.build.directory}/repository</destination>
<!-- Whether only strict dependencies should be followed. -->
<!-- "strict" means perfect version match -->
<followStrictOnly>false</followStrictOnly>
<!-- Whether or not to follow optional requirements. -->
<includeOptional>true</includeOptional>
<!-- Whether or not to follow non-greedy requirements. -->
<includeNonGreedy>true</includeNonGreedy>
<!-- Filter properties. E.g. filter only one platform -->
<!--
<filter>
<osgi.os>win32</osgi.os>
<osgi.ws>win32</osgi.ws>
<osgi.arch>x86_64</osgi.arch>
</filter>
-->
<!-- Whether to filter the resulting set of IUs to only -->
<!-- include the latest version of each IU -->
<latestVersionOnly>false</latestVersionOnly>
<!-- don't mirror artifacts, only metadata -->
<mirrorMetadataOnly>false</mirrorMetadataOnly>
<!-- whether to compress the content.xml/artifacts.xml -->
<compress>false</compress>
<!-- whether to append to the target repository content -->
<append>true</append>
<!-- whether to mirror pack200 artifacts also. Available since tycho-extras
0.17.0 -->
<includePacked>true</includePacked>
</configuration>
</plugin>
</plugins>
</build>

As far as I know, there's no such option in the tycho-p2-extras-plugin:mirror goal, because there's no such option in the Eclipse mirror application on which the plugin relies.
You have to mirror the corresponding source features yourself (which will automatically mirror the related sources of the included bundles).
However, some projects provide features that automatically include all the sources, for example, org.eclipse.emf.sdk.feature.group. You will also mirror all the sources if you mirror such a feature.

Related

Exception while building Scala-Maven project on IntelliJ

I am trying to build a Scala-Maven project on IntelliJ IDEA. Right after creating the project, it says build successful. This is how my pom.xml looks like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dbloads.pgms</groupId>
<artifactId>Arts</artifactId>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2008</inceptionYear>
<properties>
<scala.version>2.7.0</scala.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.specs</groupId>
<artifactId>specs</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-target:jvm-1.5</arg>
</args>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<buildcommands>
<buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
</buildcommands>
<additionalProjectnatures>
<projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
</additionalProjectnatures>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Next I tried to add the compiler options in project like below:
Once added and when I click the RUN button, I get the below error message:
[ERROR] Plugin net.alchim31.maven:scala-maven-plugin:3.4.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for net.alchim31.maven:scala-maven-plugin:jar:3.4.0: Could not transfer artifact net.alchim31.maven:scala-maven-plugin:pom:3.4.0 from/to central (https://repo.maven.apache.org/maven2): PITC-Zscaler-EMEA-Amsterdam3PR.proxy.corporate.ge.com: Unknown host PITC-Zscaler-EMEA-Amsterdam3PR.proxy.corporate.ge.com -> [Help 1]
I am using the jdk version: 1.8.0_172 and I have added the Scala plugin directly from the plugins. Hence it is the latest version of the Scala.
Could anyone let me know how can I fix this problem.
It looks like you need to configure Maven and IntelliJ to use network proxy settings, since it looks like you might be behind a corporate firewall.
Maven has the ability to configure a proxy through its settings (in ~/.m2/settings.xml on Unix-like systems, or %HOME%\.m2\settings.xml on Windows), as follows:
<settings ...>
.
.
<proxies>
<!-- You can have one of these for each possible proxy. -->
<proxy>
<active>true</active>
<!-- Pick some ID for your proxy here. -->
<id>corp-proxy</id>
<!-- Choose your protocol here. E.g. "http", "socks4" or "socks5" -->
<protocol>http</protocol>
<!-- Specify the proxy server name (or IP address) and port of your proxy here. -->
<host>proxy.example.com</host>
<port>8080</port>
<!-- Identify any hosts here that you can access directly. It's unlikely that you'll
need this unless you have a proxy repository (such as Nexus, Artifactory, etc.) on
your corporate network. -->
<nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
<!-- The following fields are only necessary if required by your proxy. If you need to
enter your own username and password, make sure you do not add this file to version
control! -->
<username>proxyuser</username>
<password>somepassword</password>
</proxy>
</proxies>
.
.
</settings>
Meanwhile, IntelliJ is configured to use proxies through its settings. Refer to this answer for further details. (Note that setting proxy information via the JAVA_OPTS environment variable will work for running any Java/Scala/JVM application that needs to access the Internet via a proxy.)
Alternatively, if your proxy settings are configured correctly or are not required, it might be a temporary network connection issue, so make sure you have an Internet connection and try again. (The exception is a failure by Maven to download the plugin from the Maven central repository.)
BTW, the version of Scala you have specified—2.7.0—is ancient and almost certainly will not work with JDK 8. Either use an older JDK or a more recent version of Scala (the current release is 2.12.6).
Note that if you need to work with the current version of Apache Spark, you must currently use Scala 2.11.x - the most recent release being 2.11.12.
UPDATE:
From your comments, it seems there is some confusion about the roles played by Maven, the scala-maven-plugin, IntelliJ and the IntelliJ Scala plugin, so I'll quickly summarize them here. Please bear with me if I cover topics you're already familiar with...
Maven is a system for building and publishing software. (It actually does a lot more than just that, which is why Maven describes itself as project management software.) It allows developers to specify, in a single place, all of their software's dependencies (third-party libraries used by the software), which Maven downloads as required from the Central Maven Repository—mostly open-source—or from other, private repositories, as required. Further settings control how compilers are configured, tests are run, reports generated, etc.
Maven was developed primarily for development of Java-language projects. The scala-maven-plugin provides support for the Scala language and compiler within Maven. It is this plugin that downloads the version of the Scala compiler specified by your project and uses it to compile and build your sources.
If you look at your Maven project's pom.xml file, you will notice the following lines in the build section:
<project ...>
...
<build>
...
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-target:jvm-1.5</arg>
</args>
</configuration>
</plugin>
...
</build>
...
</project>
and again in the reporting section:
<project ...>
...
<reporting>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
In both cases, there is a line that reads <scalaVersion>${scala.version}</scalaVersion>, which tells Maven which version of Scala you want to use. The plugin then uses this version of the Scala compiler, and has Maven download it to a cached, local repository on your machine (typically, in C:\Users\{your account}\.m2 on a Windows machine). Note that both Maven and the scala-maven-plugin will ignore any versions of Scala you have installed on your machine.
So which version of Scala is the plugin going to download for you? The value ${scala.version} states that the version number is stored as the value of a property named scala.version. Your pom.xml file also has lines, near the top, that create this property:
<project ...>
...
<properties>
<scala.version>2.7.0</scala.version>
</properties>
...
</project>
So, you can see that you will use version 2.7.0 of the Scala compiler. If you want to use the latest Scala version, you should change this to:
<project ...>
...
<properties>
<scala.version>2.12.6</scala.version>
</properties>
...
</project>
OK, so now you will be using the latest version of the Scala compiler. Now let's move on to IntelliJ...
IntelliJ IDEA is an Integrated Development Environment (IDE), primarily aimed at development with the Java language. It provides syntax highlighting, smart code completion, and other features to simplify the process of writing code. In order to provide those features for the Scala programming language, you need to install its Scala plugin.
You can configure IntelliJ to use any version of Scala that you have installed on your machine. IntelliJ will then know how to compile, build and run your software and can work without using your Maven project object model (POM) file's build definition.
However, one of the reasons for using Maven is to ensure a consistent build environment for developing a project, so that it is not at the whim of whatever each developer may or may not have installed on their machine. For this reason, if a project uses Maven, it's a good idea to tell IntelliJ. That way, IntelliJ can use Maven's pom.xml file to specify the version of the compiler, download dependencies, configure the compiler settings, etc.
So, the above information should help you to get up-and-running with your project, working with your corporation's network proxy and using the latest version of Scala, using Maven and IntelliJ.

Build single update-site for RAP and RCP flavored feature

I have a build for a single-sourced RCP/RAP Eclipse feature project that uses maven profiles to either build RAP or RCP bundles, fragments and features.
This works reasonably well. If I include my update site project as module in the above build's parent POM I can also easily build a platform-specific update-site using either "eclipse-update-site" (or "eclipse-repository") packaging.
However, I was wondering, if there is a way to
build RCP target platform > publish to local repo
build RAP target platform > publish to local repo
run build for RCP (target platform from step 1) > publish to local repo
run build for RAP (target platform from step 2) > publish to local repo
run build for update site only, include feature for RAP and for RCP (not compiling anything, just assembling from 1+2)
I could successfully execute steps 1-4, but not 5, because Tycho was trying to resolve the features referenced by the category.xml with a different qualifier.
If I understand update sites/p2 repositories correctly, it should be possible to offer any artifacts / bundles / features in various flavors, right?
How can I solve this, or rather: can I have a single tycho build that runs the above build steps consecutively with the same qualifier for all?
Addendum: This existing question goes in the same direction and suggests to "install the (feature) Tycho project(s) into ... local Maven repository". That's actually what I'm doing when I run 1. and 2. after each other, specifiying the same local repo for both. But then 3. fails to pull the referenced artifacts from there, because the qualifier is different (two distinct reactor builds). Running everything in the same reactor build would be totally fine for me, but I think that's not possible, because there are different target platforms involved.
I think the solution there is pretty close to what I need, but I don't understand how my category.xml (or site.xml) and the extra dependencies in POM work together. Do I have to abandon category.xml altogether and respecify all my dependencies in the eclipse-repository POM?
My build roughly looks like this:
foo.releng/pom.xml (parent POM)
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>net.bar</groupId>
<artifactId>foo</artifactId>
<version>0.31.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<tycho-version>1.0.0</tycho-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jacoco-version>0.7.6.201602180812</jacoco-version>
</properties>
<modules>
<module>../foo.plugin1</module>
<module>../foo.plugin2</module>
<!-- feature module is built depending on target platform, see below -->
</modules>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<!-- target and dependency-resolution are RAP/RCP dependent, see profiles below -->
<resolver>p2</resolver>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>target-rcp</id>
<activation>
<property>
<name>target.platform</name>
<value>rcp</value>
</property>
</activation>
<modules>
<module>../foo.fragment.rcp</module>
<module>../foo.feature.rcp</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<target>
<artifact>
<groupId>net.bar</groupId>
<artifactId>net.bar.foo.target.rcp</artifactId>
<version>${project.version}</version>
<classifier>rcp</classifier>
</artifact>
</target>
<dependency-resolution>
<optionalDependencies>ignore</optionalDependencies>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.ui</id>
<versionRange>0.0.0</versionRange>
</requirement>
... more rcp-only dependencies
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>target-rap</id>
<activation>
<property>
<name>target.platform</name>
<value>rap</value>
</property>
</activation>
<modules>
<module>../foo.fragment.rap</module>
<module>../foo.feature.rap</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
... same as for RCP above, but for RAP
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
An this is the updatesite/category.xml
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="features/net.bar.foo.feature.rcp_0.31.0.qualifier.jar" id="net.bar.foo.feature.rcp" version="0.31.0.qualifier">
<category name="net.bar.rcp"/>
</feature>
<feature url="features/net.bar.foo.feature.rap_0.31.0.qualifier.jar" id="net.bar.foo.feature.rap" version="0.31.0.qualifier">
<category name="net.bar.rap"/>
</feature>
<category-def name="net.bar.rcp" label="RCP">
<description>
RCP Platform Features
</description>
</category-def>
<category-def name="net.bar.rap" label="RAP">
<description>
RAP Platform Features
</description>
</category-def>
</site>
And the updatesite/pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<version>0.31.0-SNAPSHOT</version>
<relativePath>../foo.releng/pom.xml</relativePath>
<artifactId>foo</artifactId>
<groupId>net.bar</groupId>
</parent>
<artifactId>net.bar.foo.updatesite</artifactId>
<packaging>eclipse-repository</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<archiveSite>true</archiveSite>
</configuration>
</plugin>
</plugins>
</build>
</project>
This question which concerns a very similar problem helped me to find a solution.
I succeded by configuring the tycho-packaging-plugin with a reproducible timestamp qualifier.
By using a constant version qualifier (based on the git commit ID) for all of my consecutive builds, the final repository build could resolve all referenced feature bundles correctly in the local maven repo.
After this adjustment the following build runs through without any problems and publishes a RAP and RCP feature flavor:
# build rcp target
cd foo/net.bar.foo.target.rcp
mvn clean install -Dmaven.repo.local=../../m2
# build rap target
cd ../net.bar.foo.target.rap
mvn clean install -Dmaven.repo.local=../../m2
# build features and plugins for rcp, then for rap
cd ../net.bar.foo.releng
mvn clean install -Dmaven.repo.local=../../m2 -Dtarget.platform=rcp
mvn clean install -Dmaven.repo.local=../../m2 -Dtarget.platform=rap
# build p2 repository
cd ../net.bar.foo.updatesite
mvn clean install -Dmaven.repo.local=../../m2 -Dtarget.platform=rap
Voilà:

Tycho build with optional dependencies to SWT and RAP

I have an application with two versions: swt and rap. Therefore in my plugins I have optional dependencies on both of them and when there is missing one, the other is present and vice versa. Problem is, that in Tycho I can only require or ignore optional dependencies. Is there a way to treat this somehow?
My suggestion: not use optional dependencies. In my single sourced RCP/RAP project, i'm create several empty/"fake" plugins, only id matters with no source.
RAP build
org.eclipse.jface.databinding
org.eclipse.ui
org.eclipse.ui.forms
RCP build
org.eclipse.rap.jface.databinding
org.eclipse.rap.ui
org.eclipse.rap.ui.form
well I have found a solution to this. it is having two separate profiles for rcp and rap, ignore optional dependencies and define extra requirement for each bundle I need in that particular profile eg:
<profiles>
<profile>
<id>rap</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>maven.profile</name>
<value>rap</value>
</property>
</activation>
<repositories>
...
</repositories>
<modules>
...
</modules>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependency-resolution>
<optionalDependencies>ignore</optionalDependencies>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.rap.ui</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.rap.ui.views</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
this is what i have in top level pom.xml, if some bundle that is part of your build have optional dependecy on other bundle from that build there will be circular dependency if you add the extra requirement in the top level pom. solution is simply to add the extra requirement to pom of the bundle that has the dependency - you just have to put it inside a profile it is meant to be in

Dependencies from pom.xml not considered by Eclipse in Tycho Project

I created a Tycho project with an eclipse-plugin packaging. The project includes some dependencies that are specified via pom.xml. The relevant pom sections are:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tycho.version>0.15.0</tycho.version>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<pomDependencies>consider</pomDependencies>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>juno</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/juno</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>com.springsource.org.testng</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>com.google.guice</groupId>
<artifactId>com.springsource.com.google.inject</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.aopalliance</groupId>
<artifactId>com.springsource.org.aopalliance</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
And the Manifest is:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Plugin-project-pure
Bundle-SymbolicName: plugin-project-pure
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.equinox.app,
org.eclipse.uml2.uml;bundle-version="4.0.0",
org.eclipse.uml2.uml.resources;bundle-version="4.0.0",
org.junit;bundle-version="4.10.0",
com.springsource.org.testng;bundle-version="[6.4.0,6.4.0]"
The project only consists of a class in the default package that uses an annotation from org.testng.annotations to test that during compilation the dependency is included.
If I'm building the project on the command line with Maven 3.0.4 everything works fine. After importing the project in Eclipse Juno, I get multiple errors. The most important one is in the manifest and it states that the bundle com.springsource.org.testng can't be resolved. There is also a compile error in the class, because the import of the annotation is not possible. The project has the Maven Nature configured. Am I missing something so that Eclipse Juno will also consider the dependencies of the pom?
You can circumvent this problem splitting your project build into two parts:
First, aggregate your POM dependencies into a p2 repository. You'll need an eclipse-feature and an eclipse-repository module for this, plus a separate parent POM that lists the POM dependencies and configures pomDependencies=consider.
In the second build, add the p2 repository from the first build to the target platform, e.g. via a jar:file: URL pointing to the build result in your local Maven repository.
Then, you can also configure your target platform in Eclipse to include the p2 repository from the first build (which depends on how you currently configure it). You'll get the best consistency between Tycho and Eclipse if you use a so-called target definition file, which you can use both as target platform in Eclipse and in Tycho.
I am aware that all this is quite a bit of effort to set up, but AFAIK there are no better solutions that fully work.
The most elegant solution to all problems that exist between maven-RCP problems is to use the
p2-maven-plugin. Here is the brief summary of those problems (cuts from the link above):
In order to add a third-party dependency to an Eclipse RCP project the
dependency has to reside in a P2 update site.
Eclipse (and other providers) provide a set of public update sites,
but obviously not all popular and publicly available dependencies are
there (that is the problem number #1).
Since Eclipse RCP is an OSGi environment in order to add a dependency
to a p2 update site the depenedncy has to be an OSGi bundle (that is
the problem number #2).
So, let’s sum up for now: all our artifacts have to be OSGi bundles,
but they are not always bundles and they have to be located in a P2
site, but we do not have that site. How do we proceed then?
It is not that difficult, there is a ‘bnd’ tool written by Peter
Kriens that can transform your jars into bundles. There is also a
convenience tool provided by Eclipse RCP that can generate a P2 site
(in a cumbersome and painful way though). Both tools assume that all
your jars/bundles are located in a local folder - which means that you
have to download them by-hand. You could use Maven to automate it a
bit, but there is a significant difference in the way how Maven
calculates a dependency tree and this is not alwyas compatible with
the OSGi way (that is the problem number #3). Let us elaborate on it a
bit more.
It allows you to define a pom-packaged project that will resolve all maven dependencies, convert all non-OSGi ones to bundles and generate a p2 site from them.
Below is the full minimal pom file including the dependency on slf4j-log4j12 (which implicitly depends on both slf4j and log4j v1.2):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.berezovskiy.project</groupId>
<artifactId>p2</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.1-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<artifacts>
<artifact>
<id>org.slf4j:slf4j-log4j12:1.7.7</id>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.12.v20130726</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>${basedir}/target/repository/</webAppSourceDirectory>
<webApp>
<contextPath>/site</contextPath>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>reficio</id>
<url>http://repo.reficio.org/maven/</url>
</pluginRepository>
</pluginRepositories>
</project>
P.S. I usually do not post answers to old and answered questions, but in my case it took so long to resolve this issue in a clean and elegant way that I decided to write about it. Additionally, the solution has appeared in late 2013.
from the command line navigate to the folder where the pom.xml is located.
Run mvn eclipse:eclipse.
This should build a valid eclipse project.

Maven plugin to ensure UTF-8 Encoding?

Is there a Maven plugin I can use to fail my build if the builder notices a file that is not encoded with UTF-8?
Yes, there is https://github.com/mikedon/encoding-enforcer
It uses the Maven Enforcer Plugin, and juniversalchardet to do the encoding detection.
UPDATE 2016-10-20: org.codehaus.mojo has an extra-enforcer-rules plugin which introduces a requireEncoding rule. It uses ICU4J for the encoding detection.
Usage is:
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<!-- find the latest version at http://maven.apache.org/plugins/maven-enforcer-plugin/ -->
<version>1.0</version>
<executions>
<execution>
<id>require-utf-8</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireEncoding>
<encoding>UTF-8</encoding>
<includes>src/main/resources/**,src/test/resources/**</includes>
</requireEncoding>
</rules>
<fastFail>false</fastFail>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>extra-enforcer-rules</artifactId>
<!-- find the latest version at http://www.mojohaus.org/extra-enforcer-rules/ -->
<version>1.0-beta-6</version>
</dependency>
</dependencies>
</plugin>
Good choice on adopting Maven - no doubt you'll soon be a total convert! :)
You may want to look at the Maven enforcer plugin. As a start you could use the requireProperty rule to ensure that the project.build.sourceEncoding property is set to UTF-8.
As for checking the actual files themselves (i.e. checking whether someone has committed a non-unicode file), you could implement your own custom rule for the enforcer plugin. When this rule is executed, you'd need read all the resources in the project and find some method of detecting the encoding for each (e.g. iconv).