所以我知道如何使用gradle中的maven插件生成pom文件,如here所述。
现在我想在生成的pom中包含一个属性部分,例如:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycorp.mycomponent</groupId>
<artifactId>mything/artifactId>
<version>myversion</version>
<packaging>zip</packaging>
<properties>
<bom_status>SUCCESS</bom_status>
<bom_url>http://jenkins/job/build-mything/9735/</bom_url>
<bom_md5sum>ac69702b40cd3f68cd76a1a2d59ae08d</bom_md5sum>
<bom_sha1sum>b4cf32524b42a7bf0b8cdba8a383624525bd7727</bom_sha1sum>
</properties>
</project>
我该怎么做?
答案 0 :(得分:2)
与您生成POM本身相同。
生成pom对象后,您可以执行以下操作:
def updatePomWithProperties(pomObject) {
pomObject.project {
properties {
bom_status = "SUCCESS"
bom_url = "http://jenkins/job/build-mything/9735/"
bom_md5sum = "ac69702b40cd3f68cd76a1a2d59ae08d"
bom_sha1sum = "b4cf32524b42a7bf0b8cdba8a383624525bd7727"
}
}
}