Gradle 配置--上传私服

2016-09-20  本文已影响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    
上一篇 下一篇

猜你喜欢

热点阅读