Publish Snapshot vs Publish Release in Gradle With Continuous Integration

☆樱花仙子☆ 提交于 2019-11-29 21:03:08
Rene Groeschke

You can configure the snapshot and the release repository in the 'Upload' task (e.g. the uploadArchives) task:

uploadArchives {  
    repositories {  
        mavenDeployer {  
            repository(url: 'http://myCompanyRepo.com:8081/releases') {  
                authentication(userName: 'admin', password: 'password');  
            }  
            snapshotRepository(url: 'http://myCompanyRepo.com:8081/snapshots') {
                authentication(userName: 'admin', password: 'password');  
            }  
        }  
    }  
}

For *-SNAPSHOT versions the snapshotRepository is used. Otherwise the releases repo is used.

Paolo Fulgoni

If you want to use the new maven-publish plugin, you can upload to different repositories using an if statement:

apply plugin: 'maven-publish'

...

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            credentials {
                username "anonymous"
            }

            if(project.version.endsWith('-SNAPSHOT')) {
                url "http://example/artifactory/libs-snapshot-local"
            } else {
                url "http://example/artifactory/libs-release-local"
            }
        }
    }
}

Reference: maven-publish and setting snapshotRepository and releaseRepository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!