Hi all,
I am trying to use ant tasks provided by several plugins to generate P2 based update sites. So far I failed to compose a working solution, so I am wondering if the ant based approach provided is still supported these days, since a bit of googling learns me that the problems I encountered so far are known/unsolved since 2009.
The following plugins seem to provide ant P2 repo related ant-tasks:
(1) org.eclipse.equinox.p2.publisher.eclipse_1.0.0.v20110815-1438: pdepublishing-ant.jar && pdepublishing.jar
(2) org.eclipse.pde.build_3.7.0.v20111116-2009: pdebuild-ant.jar && pdebuild.jar
(3) org.eclipse.equinox.p2.metadata.repository_1.2.0.v20110815-1419.jar: metadataRepository-ant.jar
The ant tasks provided and mentioned in the plugins above do not seem to work. The most promising solutions seems to be the first (1) mentioned above. The command line way of generating a P2 update site was working very well and I was also able to categorize my P2 site using a category.xml file.
As mentioned in hxxp://wiki.eclipse.org/Equinox_p2_Metadata_Generator:
java -jar <targetProductFolder>/plugins/org.eclipse.equinox.launcher_*.jar
-application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher
-metadataRepository file:/<some location>/repository
-artifactRepository file:/<some location>/repository
-source /<location with a plugin and feature directory>
-configs gtk.linux.x86
-compress
-publishArtifacts
java -jar <targetProductFolder>/plugins/org.eclipse.equinox.launcher_*.jar
-consolelog -application org.eclipse.equinox.p2.publisher.CategoryPublisher
-metadataRepository file:/<repo location>/repository
-categoryDefinition file:/home/irbull/workspaces/p2/mail/category.xml
-categoryQualifier
-compress
The ant tasks mentioned later on the site do not work however:
<project name="p2.updatesite" default="main" xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<property name="p2.site.output" value="file:/tmp/wtp-sdk/output"/>
<property name="p2.site.input" value="/tmp/wtp-sdk/eclipse"/>
<property name="eclipse.plugins" value="/tmp/eclipse/plugins/"/>
<taskdef name="featuresAndBundles" classname="org.eclipse.equinox.internal.p2.publisher.ant.FeaturesAndBundlesPublisherTask">
<classpath>
<pathelement location="/tmp/wtp-sdk/jars/pdepublishing-ant.jar"/>
<pathelement location="/tmp/wtp-sdk/jars/pdepublishing.jar"/>
<pathelement location="${eclipse.plugins}/org.eclipse.equinox.common_3.6.0.v20110523.jar"/>
<pathelement location="${eclipse.plugins}/org.eclipse.equinox.p2.core_2.1.1.v20120113-1346.jar"/>
<pathelement location="${eclipse.plugins}/org.eclipse.equinox.p2.repository_2.1.1.v20120113-1346.jar"/>
<pathelement location="${eclipse.plugins}/org.eclipse.equinox.p2.metadata_2.1.0.v20110815-1419.jar"/>
<pathelement location="${eclipse.plugins}/org.eclipse.equinox.p2.publisher_1.2.0.v20110815-1419.jar"/>
<pathelement location="${eclipse.plugins}/org.eclipse.osgi_3.7.2.v20120110-1415.jar"/>
</classpath>
</taskdef>
<target name="main">
<featuresAndBundles
metadataRepository="${p2.site.output}"
artifactRepository="${p2.site.output}"
publishArtifacts="true"
compress="true"
source="${p2.site.input}"/>
</target>
</project>
I can't get around the following error:
BUILD FAILED
/tmp/wtp-sdk/build.xml:26: java.lang.NullPointerException
at org.eclipse.equinox.p2.publisher.Publisher.getService(Publisher.java:166)
at org.eclipse.equinox.p2.publisher.Publisher.loadArtifactRepository(Publisher.java:140)
at org.eclipse.equinox.p2.publisher.Publisher.createArtifactRepository(Publisher.java:105)
at org.eclipse.equinox.internal.p2.publisher.ant.AbstractPublishTask.initializeRepositories(AbstractPublishTask.java:114)
at org.eclipse.equinox.internal.p2.publisher.ant.FeaturesAndBundlesPublisherTask.execute(FeaturesAndBundlesPublisherTask.java:30)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:809)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Solution (2) above comes down to a similar null pointer exception.
Solution (3) is not documented well and does not support the arguments it claims to support. Reverse engineering the jars clearly proved this too.
Does anyone has an idea on how to get P2 Repo generation working within ant and ever got it actually working? I want to avoid calling the command line version from within my ant based build system, since it would require me to extract a full eclipse and need for graphical support (like Xvfb) on my build machine.
Also I like to avoid migrating my build system to maven or tycho (cfr hxxp://dev.eclipse.org/mhonarc/lists/p2-dev/msg02969.html)
Any idea welcome...
Bart