Gradle 配置--上傳私服

Gradle has a built in dependency management component that supports the Maven repositoryformat. In order to configure a Gradle project to resolvedependencies
declared inbuild.gradle
file, amaven
repository as shown in Listing: Gradle Repositories Configuration has to be declared.

**Listing: Gradle Repositories Configuration. **

repositories { 
   maven { 
       url "http://localhost:8081/repository/maven-public/"
   }
}```

These minimal settings allow Gradle to download the declared dependencies.
To deploy build outputs to a repository with theuploadArchives
task, user authentication can be declared ine.g.,gradle.properties
:

nexusUrl=http://localhost:8081
nexusUsername=admin
nexusPassword=admin123```
and then used in the uploadArchives task with a mavenDeployer configuration from the Maven plugin:

uploadArchives { 
    repositories { 
        mavenDeployer { 
            repository(url: "${nexusUrl}/repository/maven-releases/") { 
                authentication(userName: nexusUsername, password: nexusPassword) 
            } 
            snapshotRepository(url: "${nexusUrl}/repository/maven-snapshots") { 
                authentication(userName: nexusUsername, password: nexusPassword) 
            } 
        }
     }
}

Full example projects can be found in thegradle
folder of thedocumentation book examples project in thenexus-3.0.x
branch. A full build of thesimple-project
, including downloading the declared dependencies and uploading thebuild output to the repository manager can be invoked with

cd gradle/simple-project
gradle upload    
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容