访问maven ant任务依赖项&x27;s属性(在其pom中声明)来自ant
我正在为一个项目使用maven ant任务,我遇到了从ant引用依赖项的pom中声明的属性的需要 具体来说,我依赖华夫格jna:访问maven ant任务依赖项&x27;s属性(在其pom中声明)来自ant,maven,ant,properties,maven-ant-tasks,Maven,Ant,Properties,Maven Ant Tasks,我正在为一个项目使用maven ant任务,我遇到了从ant引用依赖项的pom中声明的属性的需要 具体来说,我依赖华夫格jna: <property name="waffle-jna-version" value="1.7" /> <artifact:dependencies ...> <dependency groupId="com.github.dblock.waffle" artifactId="waffle-jna" version="${waffle-
<property name="waffle-jna-version" value="1.7" />
<artifact:dependencies ...>
<dependency groupId="com.github.dblock.waffle" artifactId="waffle-jna" version="${waffle-jna-version}">
</artifact:dependencies>
我需要找出我正在构建的Waffle版本所使用的jna和slf4j版本,然后添加一些具有相同版本的相关依赖项(例如,slf4j simple上的运行时依赖项)
我知道我可以在maven ant任务中排除对华夫格的依赖,然后在顶层用我自己的版本声明它们,但我更愿意遵循我正在使用的华夫格版本所使用的版本
有没有办法告诉maven ant任务将依赖项pom中声明的属性公开给ant
我尝试导入pom,附加了对pom的依赖项和一个
:
所以我已经束手无策了。我宁愿全部使用Maven,但不幸的是,这不是我目前可以单方面做出的决定。您上面的pom导入声明:
<!-- Expose the Waffle POM so we can reference its version attributes -->
<artifact:pom file="${com.github.dblock.waffle:waffle-jna:pom}" inheritAllProperties="true"/>
:
您缺少id=“mypom”
分配
它将允许您按名称引用属性,如${mypom.properties.jna.version}
请注意,必须显式指定属性节点的路径;属性不是直接添加到mypom
下,而是出现在mypom.properties
下,反映了pom.xml
结构。(这也意味着从父POM继承的属性将不会公开)。谢谢-缺少id
是NPE的原因。修复后,构建继续进行,但似乎仍然没有公开嵌套属性;在上述pom声明中添加了id=“waffle pom”
,然后
导致下载:org/slf4j/slf4j simple/${waffle pom.slf4j.version}/slf4j simple-${waffle pom.slf4j.version}.pom
ant-debug
在运行工件:pom
之后,不会显示正在注册的任何属性,只是注册waffle pom
its self.Aha。必须显式指定属性节点,它是一个XML路径。因此4.1.0的mypom.properties.jna.version
。编辑以反映这一点。
<artifact:dependencies>
<dependency groupId="com.github.dblock.waffle" artifactId="waffle-jna" version="${waffle-jna-version}" type="pom"/>
</artifact:dependencies>
<!-- Expose the Waffle POM so we can reference its version attributes -->
<artifact:pom file="${com.github.dblock.waffle:waffle-jna:pom}" inheritAllProperties="true"/>
ant -debug
....
Setting project property: com.github.dblock.waffle:waffle-jna:pom -> /home/craig/.m2/repository/com/github/dblock/waffle/waffle-jna/1.7/waffle-jna-1.7.pom
Adding reference: com.github.dblock.waffle:waffle-jna:pom
....
[artifact:pom] Maven Ant Tasks version: 2.1.3
BUILD FAILED
/home/craig/projects/2Q/pgjdbc/build.xml:148: java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:334)
at org.apache.tools.ant.Project$AntRefTable.getReal(Project.java:2409)
at org.apache.tools.ant.Project$AntRefTable.access$000(Project.java:2394)
at org.apache.tools.ant.Project.addReference(Project.java:1973)
at org.apache.maven.artifact.ant.Pom.doExecute(Pom.java:423)
at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:751)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
....
<!-- Expose the Waffle POM so we can reference its version attributes -->
<artifact:pom file="${com.github.dblock.waffle:waffle-jna:pom}" inheritAllProperties="true"/>
<artifact:pom id="mypom" file="pom.xml" />