且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Eclipse 之外运行 P2 Ant 任务

更新时间:2022-10-31 15:06:08

通过阅读 此主题P2 Publisher 文档,应该是在 org.eclipse.equinox.launcher_*.jar

仅用于 -jar 参数的 P2 任务示例(此处不是 ant 任务):

java -jar /plugins/org.eclipse.equinox.launcher_*.jar-application org.eclipse.equinox.p2.publisher.UpdateSitePublisher-metadataRepository 文件://repository-artifactRepository 文件://repository-source/<location with a site.xml>-configs gtk.linux.x86-压缩- 发布工件

此处描述了 P2 Ant 任务,并在 Eclipse 帮助.

OP Anthony43 在评论中添加:

我只想在 eclipse 之外运行一个带有 p2 taskdefs 的 ant 目标.
我发现我应该使用 antRunner,使用这样的命令行:

./eclipse -vm/opt/sun-java2-6.0/bin/java -nosplash \-data ${java.io.tmpdir}/workspace -consolelog \-应用程序 org.eclipse.ant.core.antRunner \-f/path/to/scripts/partialMirrorFromRepo.xml

但是 Andrew Niefer(PDE/Build、p2 和 Equinox 框架的 Eclipse 提交者)补充说:

p2 任务需要在 osgi 环境中运行,在正常的 ant 运行中无法运行.
这就是您需要使用 org.eclipse.ant.core.antRunner 应用程序的原因.
以java -jar launcher.jar"开头只是调用 eclipse 可执行文件的另一种方法.

martin jakubik 提及:

我希望看到一个可以剪切和粘贴并将所有内容组合在一起的命令.
我用的是:

java -jar \eclipse\plugins\org.eclipse.equinox.launcher_*.jar -application org.eclipse.ant.core.antRunner.

请注意,我无法弄清楚 是什么,所以我改用了 .

I got ant script running fine inside Eclipse Here is a piece of it :

<p2.composite.repository failOnExists="true">
            <repository location="file:/${basedir}/compRepo" name="Repository description goes here" />
            <add>
                <repository location="http://url/Eclipse/repo/Galileo-3.5.1/" />
                <repository location="http://another-url/Java/repo/4.0/" />
                <repository location="${diag.location}" />
            </add>
        </p2.composite.repository>

But I would like Hudson CI server to be able to run it, but, no matter all the jars I put in ANT_HOME/lib I can't get this task to run in a simple command line ant... I got stuck with this error :

C:\workspaces\workspace\project\junit.script\createCompRepo.xml:10: Problem: failed to create task or type p2.composite.repository
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

Where are defined the p2 ant tasks ? Is there a way to run them outside Eclipse ? Thank you very much for you help ! Anthony

By reading this thread and the P2 Publisher documentation, it should be in org.eclipse.equinox.launcher_*.jar

Example of a P2 task (not an ant task here) just for the -jar argument:

java -jar <targetProductFolder>/plugins/org.eclipse.equinox.launcher_*.jar
 -application org.eclipse.equinox.p2.publisher.UpdateSitePublisher
 -metadataRepository file:/<some location>/repository
 -artifactRepository file:/<some location>/repository
 -source /<location with a site.xml>
 -configs gtk.linux.x86
 -compress 
 -publishArtifacts

The P2 Ant tasks are described here, and in the Eclipse help.


The OP Anthony43 adds in the comments:

I just want to run an an ant target with p2 taskdefs, outside of eclipse.
I found out that I should use antRunner, using such a command line :

./eclipse -vm /opt/sun-java2-6.0/bin/java -nosplash \
-data ${java.io.tmpdir}/workspace -consolelog       \
-application org.eclipse.ant.core.antRunner         \
-f /path/to/scripts/partialMirrorFromRepo.xml 

But Andrew Niefer (Eclipse committer on PDE/Build, p2, & Equinox Framework) adds:

The p2 tasks need to be run inside an osgi environment and won't work in a normal ant run.
That is why you need to use the org.eclipse.ant.core.antRunner application.
Starting with "java -jar launcher.jar" is just an alternate method to invoking the eclipse executable.


martin jakubik mentions:

I would have liked to see a command that I could cut&paste and that put everything together.
What I used was:

java -jar <eclipse-install-directory>\eclipse\plugins\org.eclipse.equinox.launcher_*.jar -application org.eclipse.ant.core.antRunner. 

Note that I could not figure out what <targetProductFolder> was, so I used <eclipse-install...> instead.