简体   繁体   中英

gradle publishing jar into nexus maven repo

I am using gradle v3.4 and maven-publish plugin as well as shadow plugin for creating jar files. I have copied the relevant parts of the build.gradle below as well as the error message. I do not get an error message when I use publishing.publications (but my jar does not get published to the remote nexus repo - I can publish locally).

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']
        }
    }

error

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

Try to declare in the head the group and the artifact And use the task jar . After that use:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM