10

我已经将 Gradle 配置为使用新的 Maven Publisher Plugin发布项目工件,不幸的是,这个插件在生成的依赖项方面存在问题pom.xml- 依赖项具有范围runtime而不是compile.

我的配置是这样的:

apply plugin: 'maven-publish'

publishing {
    publications {
        mavenCustom(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            url "https://api.bintray.com/maven/codearte/public/fairyland"
            credentials {
                username = bintrayUser
                password = bintrayKey
            }
        }
    }
}

发布很简单,只需一个命令:

gradle publish

如何以旧(工作)方式实现这一目标?项目发布时是否可以自动化项目标记?

4

2 回答 2

6

好的,我想通了:

apply plugin: 'maven'

uploadArchives {
    repositories {
        mavenDeployer {
            name = 'Codearte Public Repository'
            repository(id: 'codearte-repository', url: 'https://api.bintray.com/maven/codearte/public/fairyland'){
                authentication(userName: bintrayUser, password: bintrayKey)
        }
    }
}

使用命令上传:

gradle uploadArchives
于 2013-11-21T22:17:36.830 回答
3

runtime所有 POM 依赖项都有范围这一事实是新的孵化maven-publish插件的一个已知限制。在解决此问题之前,您可以使用publication.pom.withXml钩子自己修复它,也可以回退到maven插件。这两个插件都记录在Gradle 用户指南中。

标记是一个完全不同的问题。您可以使用第三方 Gradle SCM 插件之一或调用命令行工具(例如使用Exec任务)。

于 2013-11-21T21:45:18.867 回答