In Gradle, how can I generate a POM file with dynamic dependencies resolved to the actual version used?

后端 未结 3 1841
我在风中等你
我在风中等你 2021-01-02 10:22

In Gradle, how can I generate a POM file with dynamic dependencies resolved to the actual version used?

dependencies {
    testCompile(group: \'junit\', name         


        
3条回答
  •  醉梦人生
    2021-01-02 10:53

    It will require some effort to code this up. The two main parts are:

    • Querying resolved versions using the Configuration#getIncoming or Configuration#getResolvedConfiguration API
    • Manipulating the POM using Groovy's XMlParser API (assuming the new maven-publish plugin is used)

    Information about the Configuration API can be found in the Gradle Build Language Reference, which further links into the Javadoc. The full Gradle distribution contains a tiny sample that demonstrates POM manipulation. Information about XmlParser can be found in the Groovy docs.

提交回复
热议问题