gradle发布jar到nexus maven repo

时间:2017-05-05 21:30:31

标签: java gradle nexus maven-publish

我正在使用gradle v3.4和maven-publish插件以及用于创建jar文件的shadow插件。我已经复制了下面build.gradle的相关部分以及错误消息。当我使用 publishing.publications 时,我没有收到错误消息(但我的jar没有发布到远程nexus repo - 我可以在本地发布)。

的build.gradle

apply plugin: 'maven-publish'


publishing {
    publications {
        shadow(MavenPublication) {
            from components.shadow
            groupId 'com.test'
            artifactId 'some-java'
        }
    }
    repositories {
        maven {
            credentials {
                username project.properties['nexusUsername']
                password project.properties['nexusPassword']
            }
            url project.properties['nexus.url.snapshot']
        }
    }

错误

A problem occurred evaluating root project 'some-java'.
> Cannot configure the 'publishing' extension after it has been accessed.

1 个答案:

答案 0 :(得分:0)

尝试在头部声明组和工件 并使用任务jar。 之后使用:

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}