gradle 发布jar包到nexus

本文介绍使用Gradle将项目打包并部署至Nexus仓库的过程,包括配置Maven插件、定义项目信息、设置仓库认证及生成不同类型的归档文件。
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

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值