在 Eclipse 外部运行 P2 Ant 任务

发布于 2024-08-23 12:43:15 字数 1083 浏览 6 评论 0原文

我的 ant 脚本在 Eclipse 中运行良好 这是其中的一部分:

<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>

但我希望 Hudson CI 服务器能够运行它,但是,无论我放入 ANT_HOME/lib 中的所有 jars,我都无法让这个任务在简单的命令行 ant 中运行。 .. 我遇到了这个错误:

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.

哪里定义了 p2 ant 任务?有没有办法在 Eclipse 之外运行它们? 非常感谢您的帮助! 安东尼

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

洛阳烟雨空心柳 2024-08-30 12:43:15

通过阅读此线程P2 Publisher 文档,它应该位于 org.eclipse.equinox.launcher_*.jar

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

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

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       \
-application 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-install-directory>\eclipse\plugins\org.eclipse.equinox.launcher_*.jar -application org.eclipse.ant.core.antRunner. 

请注意,我无法弄清楚 是什么,因此我使用 代替。

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.

寒冷纷飞旳雪 2024-08-30 12:43:15

我为此目的创建了一个小型 Ant 宏

<path id="equinox.launcher.path">
    <fileset dir="${eclipse.home}/plugins">
        <include name="org.eclipse.equinox.launcher_*.jar" />
    </fileset>
</path>

<macrodef name="antRunner">
    <!-- Ant script location -->
    <attribute name="antFile" />
    <!-- the arguments for the script that is executed -->
    <attribute name="args" default=""/>
    <sequential>
        <java 
            classname="org.eclipse.equinox.launcher.Main" 
            fork="true" 
            failonerror="true">

            <arg line="-application org.eclipse.ant.core.antRunner" />
            <arg line="-f @{antFile}" />
            <arg line="@{args}"/>
            <classpath refid="equinox.launcher.path" />
        </java> 
    </sequential>
</macrodef>

I created a small Ant macro for that exact purpose

<path id="equinox.launcher.path">
    <fileset dir="${eclipse.home}/plugins">
        <include name="org.eclipse.equinox.launcher_*.jar" />
    </fileset>
</path>

<macrodef name="antRunner">
    <!-- Ant script location -->
    <attribute name="antFile" />
    <!-- the arguments for the script that is executed -->
    <attribute name="args" default=""/>
    <sequential>
        <java 
            classname="org.eclipse.equinox.launcher.Main" 
            fork="true" 
            failonerror="true">

            <arg line="-application org.eclipse.ant.core.antRunner" />
            <arg line="-f @{antFile}" />
            <arg line="@{args}"/>
            <classpath refid="equinox.launcher.path" />
        </java> 
    </sequential>
</macrodef>
简单爱 2024-08-30 12:43:15

所有p2任务都需要eclipse运行时(如上面提到的eclipse帮助中明确指出的),所以你肯定需要使用eclipse。

解决这个问题的唯一方法是分析 Eclipse 代码,提取所需内容并用它创建您自己的构建系统。

All the p2 tasks NEED the eclipse runtime (as explicitly stated in the eclipse help mentioned above), so you definitely need to use eclipse.

The only way to get round of it would be to analyze the eclipse code, extract what is needed and create your own build system with it.

空心↖ 2024-08-30 12:43:15

只是为了完成 Jarek Przygódzki 的示例,这是我的解决方案,使用他的 ant 文件。我不太熟悉使用ant,所以可能有优化的潜力。
这种方法在没有 GUI 的服务器上无头使用,但我必须安装 eclipse。使用 apt-get 安装不起作用,因此最好手动安装(下载并解压)。

  1. 第一个 antfile 组装名称、版本等...
  2. 第二个 antfile 从第一个 antfile 调用并创建复合存储库。

第一个 antfile:

<project name="project">

<!-- ....do some other stuff...-->

<target name="p2.composite.add">

<!--Call macro for child repo-->
 <antRunner
    name="${site.composite.name}"
    location="${composite.repository.directory}"
    child="${child.repository}"
/>  

<!--Call macro for main repo-->
<antRunner
    name="${main.site.composite.name}"
    location="${main.composite.repository.directory}"
    child="${majorMinorVersion}"
/> 

</target>

<!--Eclipse installation path-->
<path id="equinox.launcher.path">
    <fileset dir="/usr/share/eclipse/plugins">
        <include name="org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar" />
    </fileset>
</path>

<macrodef name="antRunner">

    <attribute name="name"/>    
    <attribute name="location"/>
    <attribute name="child"/>

    <sequential>

        <java 
            classname="org.eclipse.equinox.launcher.Main" 
            fork="true" 
            failonerror="true">

            <arg line="-application org.eclipse.ant.core.antRunner" />
            <arg line="-f addCompositeInternal.ant run" />
            <arg line="-Dcomposite.name=@{name}"/>
            <arg line="-Dcomposite.location=@{location}"/>
            <arg line="-Dcomposite.child=@{child}"/>
            <classpath refid="equinox.launcher.path" />
        </java> 
    </sequential>
</macrodef>

</project>   

第二个 Antfile,名为 addCompositeInternal.ant

<project name="composite">
<target name="run">
            <add.composite.repository.internal
                composite.repository.location="${composite.location}"
                composite.repository.name="${composite.name}"
                composite.repository.child="${composite.child}"
            />
</target>      

<!-- = = = = = = = = = = = = = = = = =
      macrodef: add.composite.repository.internal          
     = = = = = = = = = = = = = = = = = -->
<macrodef name="add.composite.repository.internal">
    <attribute name="composite.repository.location" />
    <attribute name="composite.repository.name" />
    <attribute name="composite.repository.child" />
    <sequential>

        <echo message=" " />
        <echo message="Composite repository       : @{composite.repository.location}" />
        <echo message="Composite name             : @{composite.repository.name}" />
        <echo message="Adding child repository    : @{composite.repository.child}" />

        <p2.composite.repository>
            <repository compressed="false" location="@{composite.repository.location}" name="@{composite.repository.name}" />
            <add>
                <repository location="@{composite.repository.child}" />
            </add>
        </p2.composite.repository>

        <echo file="@{composite.repository.location}/p2.index">version=1
   metadata.repository.factory.order=compositeContent.xml,\!
   artifact.repository.factory.order=compositeArtifacts.xml,\!
   </echo>

    </sequential>
</macrodef>

</project>

Just to complete the example of Jarek Przygódzki here is my solution, using his ant-file. I'm not well versed in using ant, so there might be potential for optimisation.
This aproach is used headless on a server without GUI, nevertheless I had to install eclipse. Installation with apt-get wasn't working, so it's better to install manual (download and untar).

  1. First antfile assembles names, versions, etc...
  2. Second antfile is called from first antfile and creates composite repositories.

First antfile:

<project name="project">

<!-- ....do some other stuff...-->

<target name="p2.composite.add">

<!--Call macro for child repo-->
 <antRunner
    name="${site.composite.name}"
    location="${composite.repository.directory}"
    child="${child.repository}"
/>  

<!--Call macro for main repo-->
<antRunner
    name="${main.site.composite.name}"
    location="${main.composite.repository.directory}"
    child="${majorMinorVersion}"
/> 

</target>

<!--Eclipse installation path-->
<path id="equinox.launcher.path">
    <fileset dir="/usr/share/eclipse/plugins">
        <include name="org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar" />
    </fileset>
</path>

<macrodef name="antRunner">

    <attribute name="name"/>    
    <attribute name="location"/>
    <attribute name="child"/>

    <sequential>

        <java 
            classname="org.eclipse.equinox.launcher.Main" 
            fork="true" 
            failonerror="true">

            <arg line="-application org.eclipse.ant.core.antRunner" />
            <arg line="-f addCompositeInternal.ant run" />
            <arg line="-Dcomposite.name=@{name}"/>
            <arg line="-Dcomposite.location=@{location}"/>
            <arg line="-Dcomposite.child=@{child}"/>
            <classpath refid="equinox.launcher.path" />
        </java> 
    </sequential>
</macrodef>

</project>   

Second Antfile, named addCompositeInternal.ant

<project name="composite">
<target name="run">
            <add.composite.repository.internal
                composite.repository.location="${composite.location}"
                composite.repository.name="${composite.name}"
                composite.repository.child="${composite.child}"
            />
</target>      

<!-- = = = = = = = = = = = = = = = = =
      macrodef: add.composite.repository.internal          
     = = = = = = = = = = = = = = = = = -->
<macrodef name="add.composite.repository.internal">
    <attribute name="composite.repository.location" />
    <attribute name="composite.repository.name" />
    <attribute name="composite.repository.child" />
    <sequential>

        <echo message=" " />
        <echo message="Composite repository       : @{composite.repository.location}" />
        <echo message="Composite name             : @{composite.repository.name}" />
        <echo message="Adding child repository    : @{composite.repository.child}" />

        <p2.composite.repository>
            <repository compressed="false" location="@{composite.repository.location}" name="@{composite.repository.name}" />
            <add>
                <repository location="@{composite.repository.child}" />
            </add>
        </p2.composite.repository>

        <echo file="@{composite.repository.location}/p2.index">version=1
   metadata.repository.factory.order=compositeContent.xml,\!
   artifact.repository.factory.order=compositeArtifacts.xml,\!
   </echo>

    </sequential>
</macrodef>

</project>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文