gradle 发布jar包到nexus

时间:2022-02-17 12:46:19
apply plugin: 'maven'

uploadArchives {
    repositories {
        mavenDeployer {
            pom.groupId = "com.www.bdp"
            pom.version = "1.0-SNAPSHOT"
            pom.artifactId = "api"
            pom.project {  

                name project.name  
                packaging 'jar'  
                description '基础平台jar包,主要用于hessian调用'  
              
 
                licenses {  
                    license {  
                        name 'The Apache Software License, Version 2.0'  
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'  
                        distribution '放在内网不开源了'  
                    }  
                }  
 
                developers {  
                    developer {  
                        id 'xianlinbox'  
                        name 'Liu Xiannings'  
                    }  
                }
            }

            repository(url: "http://192.168.31.31:8082/nexus/content/repositories/snapshots/") {
                authentication(userName: "admin", password: "admin123")
            }
        }
    }
}

//参见Part 2, 为项目生成**.jar/**-javadoc.jar/**-sources.jar  
task javadocJar(type: Jar, dependsOn: javadoc) {  
    classifier = 'javadoc'
    from 'build/docs/javadoc'
}  
 
task sourcesJar(type: Jar) {
    classifier = 'sources'  
    from sourceSets.main.allSource  
}  
 
artifacts {  
    archives jar  
    archives javadocJar  
    archives sourcesJar  
}




结果显示:

Uploading: com/mmhlive/bdp/api/1.0-SNAPSHOT/api-1.0-20151228.060918-2.jar to repository re
tp://192.168.31.31:8082/nexus/content/repositories/snapshots/
Transferring 2K from remote
Uploaded 2K
Uploading: com/mmhlive/bdp/api/1.0-SNAPSHOT/api-1.0-20151228.060918-2-sources.jar to repos
te at http://192.168.31.31:8082/nexus/content/repositories/snapshots/
Transferring 1K from remote
Uploaded 1K
Uploading: com/mmhlive/bdp/api/1.0-SNAPSHOT/api-1.0-20151228.060918-2-javadoc.jar to repos
te at http://192.168.31.31:8082/nexus/content/repositories/snapshots/
Transferring 40K from remote
Uploaded 40K

BUILD SUCCESSFUL

Total time: 14.703 secs