(見下面的編輯。)Maven的Antrun和依賴
我不能只使用類路徑的原因,是因爲我需要管理一些非Java庫,而且我編譯非java項目。
我想在antrun呼叫使用Maven依賴關係,在Maven站點文檔以下內容:
http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html
在頁面的底部:
<property name="mvn.dependency.jar"
refid="maven.dependency.my.group.id:my.artifact.id:classifier:jar.path"/>
<echo message="My Dependency JAR-Path: ${mvn.dependency.jar}"/>
我可以無論我如何嘗試,都無法做到這一點。我已經嘗試過在refid內容中添加$ {},我試過了冒號,句點等等。作爲分隔符,我可以想到各種方式。
任何人都可以告訴我什麼是refid應真的看起來像一些常見的依賴?
編輯:
感謝您的答覆。
使用你的榜樣SingleShot,我有以下幾點:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>create-messages</id>
<phase>compile</phase>
<configuration>
<tasks>
<property name="build.compiler" value="extJavac"/>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<property name="log4j.jar" refid="log4j:log4j:jar"/>
<echo message="Where is the Log4J JAR?: ${log4j.jar}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
</plugin>
這裏就是我得到的運行時MVN編譯:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Chat Component
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
Downloading: http://<redacted>/content/groups/public/log4j/log4j/1.2.14/log4j-1.2.14.pom
2K downloaded
Downloading: http://<redacted>/content/groups/public/log4j/log4j/1.2.14/log4j-1.2.14.jar
358K downloaded
[INFO] [antrun:run {execution: create-messages}]
[INFO] Executing tasks
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing ant tasks
Embedded error: Reference log4j:log4j:jar not found.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Fri Oct 16 14:54:19 PDT 2009
[INFO] Final Memory: 7M/80M
[INFO] ------------------------------------------------------------------------
EDIT(2):
展望在源代碼鏈接我決定運行「mvn -X編譯」和grep的「存儲」,這變成了一堆日誌輸出的地方是東西g存儲。
有趣的是,我明確指定的依賴並不在列表中顯示的事實,並且,當我切換到基於該項目的一個關鍵我做看,我仍然得到錯誤。
對不起。我原來的回答錯過了「maven.dependency」。前綴和「.path」後綴。它現在已經修復並且應該可以工作。查看插件來源(上面鏈接)的第87行,看看它應該看起來如何。 – SingleShot 2009-10-16 22:14:50