Gradle Build stand alone project running jar files

1. Gradle 配置文件配置

build.gradle 

apply plugin: 'java'
apply plugin: 'eclipse'


sourceCompatibility = 1.7
version = '1.0.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart',
                   'Implementation-Version': version
    }
}


repositories {
    mavenCentral()
   //  maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}


dependencies {
    //logback 
    compile 'org.slf4j:slf4j-api:1.7.12'
  compile 'org.slf4j:jcl-over-slf4j:1.7.12'
compile 'ch.qos.logback:logback-classic:1.1.3'

compile 'org.apache.httpcomponents:httpclient:4.5.3'
compile 'org.apache.httpcomponents:httpclient-cache:4.5.3'

    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    compile fileTree(dir: 'libs', include: '*.jar')
    testCompile group: 'junit', name: 'junit', version: '4.+'
}


test {
    systemProperties 'property': 'value'
}






task constant {
ext.buildPath="/build/target/TestProject"
ext.targetBin=buildPath+"/bin"
ext.targetConf=buildPath+"/conf"
ext.targetLibs=buildPath+"/libs"
ext.targetLogs=buildPath+"/logs"

ext.testPath="/build/target/TestProject"

ext.devEvn="dev"
ext.uatEvn="uat"
ext.proEvn="pro"
ext.testEvn="test"
}
task variable {
ext.binPath="build/bin"
ext.confPath="build/resources/main"
ext.libPath="build/libs"
}


task cleanTarget(dependsOn:build) << {
delete constant.buildPath
file(constant.buildPath).mkdirs()
file(constant.targetBin).mkdirs()
file(constant.targetConf).mkdirs()
file(constant.targetLibs).mkdirs()
file(constant.targetLogs).mkdirs()
}


task copyResource(dependsOn:cleanTarget) << {
copy{
from configurations.runtime
into constant.targetLibs
}


copy{
from variable.binPath
into constant.targetBin
}
    
copy{
from variable.confPath
   into constant.targetConf
}

copy{
from variable.libPath
    into constant.targetLibs
}


}






task buildDev(dependsOn:[clean,copyResource]) << {
}


task buildUat(dependsOn:[clean,copyResource]) << {
}


task buildPro(dependsOn:[clean,copyResource]) << {
}




task copyJars(type: Copy) {
  from configurations.runtime
  into 'build/libs' 
}


test {
    systemProperties 'property': 'value'
}


uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}


2. 运行Gradle task, build 项目jar file

 cmd 命令运行



相应的jar files 生成


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值