如何发布gradle生成的BOM

时间:2017-11-04 05:54:47

标签: gradle groovy maven-bom

我有这个配置,但是发布没有找到任何要做的事情,我需要添加/更改什么才能正确发布此BOM? (它似乎正确地生成build/pom.xml

group 'com.xenoterracide'
version '0.1.0-SNAPSHOT'

repositories {
    maven {
        url System.getenv('JAR_REPOSITORY_URI')
    }
    jcenter()
}

apply plugin: 'maven-publish'
apply plugin: 'maven'

publish {
    repositories {
        maven {
            url System.getenv('JRS_S3_URI')
            credentials(AwsCredentials) {
                accessKey System.getenv('JRS_ACCESSKEYID')
                secretKey System.getenv('JRS_SECRETACCESSKEY')
            }
        }
    }
}


build.doFirst {
    pom {
        project {
            properties {
                equalsverifier   version: "2.3.3"
                mbassador        version: "1.3.1"
                tika             version: "1.15"
                immutables       version: "2.5.5"
                assertj          version: "3.8.0"
                s3mock           version: "0.2.2"
                aws              version: "1.11.207"
                "slf4j-test"     version: "1.1.0"
                "jcabi-matchers" version: "1.3"
            }
            dependencyManagement {
                dependencies {
                    dependency 'nl.jqno.equalsverifier:equalsverifier:${equalsverifier.version}'
                    dependency 'net.engio:mbassador:${mbassador.version}'
                    dependency 'org.apache.tika:tika-core:${tika.version}'
                    dependency 'org.immutables:builder:${immutables.version}'
                    dependency 'org.immutables:value:${immutables.version}'
                    dependency 'io.findify:s3mock_2.12:${s3mock.version}'
                    dependency 'com.jcabi:jcabi-matchers:${jcabi-matchers.version}'
                    dependency 'uk.org.lidalia:slf4j-test:${slf4j-test.version}'
                }
            }
            licenses {
                license {
                    name 'The Apache Software License, Version 2.0'
                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    distribution 'repo'
                }
            }

        }
    }.writeTo("$buildDir/pom.xml")
}

使用gradle 4.3

1 个答案:

答案 0 :(得分:0)

这很有效,但对于内容如何进入生成的pom似乎非常容易。

group 'com.xenoterracide'
version '0.1.0-SNAPSHOT'

repositories {
    maven {
        url System.getenv('JAR_REPOSITORY_URI')
    }
    jcenter()
}

apply plugin: 'maven-publish'
apply plugin: 'maven'


publishing {
    repositories {
        maven {
            url System.getenv('JRS_S3_URI')
            credentials(AwsCredentials) {
                accessKey System.getenv('JRS_ACCESSKEYID')
                secretKey System.getenv('JRS_SECRETACCESSKEY')
            }
        }
    }
    publications {
        maven(MavenPublication) {
            pom.withXml {
                def sb = asString()
                sb.setLength 0
                sb.append  file( "$buildDir/bom.pom" ).text
                println( sb.toString() )
            }
        }
    }
}

build.doFirst {
    pom {
        project {
            packaging 'pom'
            properties {
                equalsverifier   version: "2.3.3"
                mbassador        version: "1.3.1"
                tika             version: "1.15"
                immutables       version: "2.5.5"
                assertj          version: "3.8.0"
                s3mock           version: "0.2.2"
                aws              version: "1.11.207"
                "slf4j-test"     version: "1.1.0"
                "jcabi-matchers" version: "1.3"
            }
            dependencyManagement {
                dependencies {
                    dependency 'nl.jqno.equalsverifier:equalsverifier:${equalsverifier.version}'
                    dependency 'net.engio:mbassador:${mbassador.version}'
                    dependency 'org.apache.tika:tika-core:${tika.version}'
                    dependency 'org.immutables:builder:${immutables.version}'
                    dependency 'org.immutables:value:${immutables.version}'
                    dependency 'io.findify:s3mock_2.12:${s3mock.version}'
                    dependency 'com.jcabi:jcabi-matchers:${jcabi-matchers.version}'
                    dependency 'uk.org.lidalia:slf4j-test:${slf4j-test.version}'
                }
            }
            licenses {
                license {
                    name 'The Apache Software License, Version 2.0'
                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    distribution 'repo'
                }
            }

        }
    }.writeTo("$buildDir/bom.pom")
}

所以如果有人有更好的方法,那就不胜感激了