美文网首页
Gradle 配置--上传私服

Gradle 配置--上传私服

作者: 花绽放水流年 | 来源:发表于2016-09-20 16:07 被阅读0次

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    

相关文章

网友评论

      本文标题:Gradle 配置--上传私服

      本文链接:https://www.haomeiwen.com/subject/ivjoettx.html