gradle学习第二篇

 

   此篇主要是在对现有项目构建由maven切换gradle需要注意的地方

providedCompile 

    jar包/依赖代码 仅在编译的时候需要,但是在运行时不需要依赖

   前提:apply plugin: 'war'

 providedCompile 'com.hand:hap-core:3.5.4-RELEASE:classes'

     如果要使之生效,需要添加如下配置

//设置providedCompile
configurations {
    providedCompile
}

sourceSets.main.compileClasspath += configurations.providedCompile
sourceSets.test.compileClasspath += configurations.providedCompile
sourceSets.test.runtimeClasspath += configurations.providedCompile

uploadArchives 上传war包及源码 

前提:apply plugin: 'maven-publish'

         apply plugin: 'maven'

//打包源码
task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

artifacts {
    archives sourcesJar
}
//上传资源配置
uploadArchives {
    repositories {
        mavenDeployer {
            //上传资源到Maven私服
            def nexusUrl ="http://172.16.20.103:8081/repository/maven-releases/"
            if(project.version.endsWith("-SNAPSHOT")) {
                nexusUrl = "http://172.16.20.103:8081/repository/maven-snapshots/"
            }
            repository(url: nexusUrl) {
                authentication(userName:"admin",password:"admin123")
            }
            pom.version ="$project.version"
            pom.artifactId ="$project.name"
            pom.groupId ="$project.group"
        }
    }
}

profile命令指定配置文件

def env = System.getProperty("profile") ?: "dev"

//gradle war  -Dprofile=uat
sourceSets {
    main {
        resources {
            srcDirs = ["src/main/resources", "src/main/resources/profiles/$env"]
        }
    }
}

 

命令idea中配置如下

 

 overlays插件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值