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    
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容