質問
Eclipse内でantスクリプトを正常に実行しました ここにその一部があります:
<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 サーバーで実行できるようにしたいのですが、すべての jar を ANT_HOME/lib に入れても、このタスクを単純なコマンド ラインで実行することはできません...このエラーで行き詰まってしまいました:
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 の外で実行する方法はありますか?助けてくれて本当にありがとう!アンソニー
解決
読むことで このスレッド そしてその P2 パブリッシャーのドキュメント, にあるはずです org.eclipse.equinox.launcher_*.jar
のための P2 タスク (ここでは Ant タスクではありません) の例 -jar
口論:
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 アンソニー43 コメントに次のように追加します。
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
しかし アンドリュー・ニーファー (PDE/Build、p2、および Equinox Framework の Eclipse コミッター) は次のように追加します。
の p2 タスクは osgi 環境内で実行する必要があり、通常の ant の実行では機能しません。.
そのため、次を使用する必要があります。org.eclipse.ant.core.antRunner
応用。
「java -jar launcher.jar」で始めるのは、Eclipse 実行可能ファイルを呼び出すための単なる代替方法です。
マーティン・ジャクビック 言及:
カット&ペーストしてすべてをまとめられるコマンドがあればよかったと思います。
私が使用したのは次のとおりです。
java -jar <eclipse-install-directory>\eclipse\plugins\org.eclipse.equinox.launcher_*.jar -application org.eclipse.ant.core.antRunner.
何を理解できなかったことに注意してください
<targetProductFolder>
だったので使用しました<eclipse-install...>
その代わり。
他のヒント
私はその正確な目的のために小さな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>
すべてのp2のタスクは、日食ランタイム(Eclipseのヘルプは、上記のように明示的に述べ)が必要です。
それのラウンドを取得する唯一の方法は、Eclipseのコードを解析に必要とされるもの抽出し、それを使用して独自のビルドシステムを作成することです。
例を完成させるために ヤレク・プジゴツキ これが彼のantファイルを使用した私の解決策です。私は ant の使用に詳しくないので、最適化の可能性があるかもしれません。このアプローチは、GUI のないサーバー上でヘッドレスで使用されますが、Eclipse をインストールする必要がありました。apt-get によるインストールは機能しなかったので、手動でインストール (ダウンロードして解凍) した方がよいでしょう。
- 最初の antfile は、名前、バージョンなどをアセンブルします。
- 2 番目の 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>
2 番目の Ant ファイル、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>