Publish Snapshot vs Publish Release in Gradle With Continuous Integration

后端 未结 2 1983
别那么骄傲
别那么骄傲 2020-12-23 09:56

I\'m just learning Gradle, coming from both an Ant+Ivy and Maven background and I\'m trying to wrap my head around the proper way to publish a release version of my software

相关标签:
2条回答
  • 2020-12-23 10:37

    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

    0 讨论(0)
  • 2020-12-23 10:39

    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.

    0 讨论(0)
提交回复
热议问题