Gradle的学习

https://www.yiibai.com/gradle/

task hello{
    doLast{
      println 'hello workd!'
    }
}

task upper << {
   String expString = 'YiiBai gradle tutorials'
   println "Original: " + expString
   println "Upper case: " + expString.toUpperCase()
   }
  

task count << {
   4.times { 
      print "$it " 
   }
}

task groovyJDKMethod << {
   String myName = "Yiibai";
   myName.each() { 
      println "${it}" 
   };
}



task intro(dependsOn: hello) << {
    println "I'm Gradle"
}

task taskX(dependsOn: 'taskY') << {
    println 'taskX'
}
task taskY << {
    println 'taskY'
}

task hello1 <<
{
println hello1.name
println project.hello1.name
}


task hello2 <<
{
println tasks.hello2.name
println tasks['hello2'].name
}

task task3 << {
   println 'task3'
}
task task4 << {
   println 'task4'
}
task3.dependsOn task4


//build.gradle 注释也可以用双斜杠

task taskX1 << {
   println 'taskX'
}

taskX1.dependsOn {
   tasks.findAll { 
     task -> task.name.startsWith('lib') 
   }
}
task lib1 << {
   println 'lib1'
}
task lib2 << {
   println 'lib2'
}
task notALib << {
   println 'notALib'
}

//1.这个是怎么玩的?
task copy(type: Copy) {
   description 'Copies the resource directory to the target directory.'
   from 'resources'
   into 'target'
   include('**/*.txt', '**/*.xml', '**/*.properties')
   println("description applied")
}

task compile << {
    println 'We are doing the compile.'
}

compile.doFirst {
    // Here you would put arbitrary conditions in real life.
    // But this is used in an integration test so we want defined behavior.
    if (true) { throw new StopExecutionException() }
}
task myTask(dependsOn: 'compile') << {
   println 'I am not affected'
}


//声明依赖关系

apply plugin: 'java'

repositories {
   mavenCentral()
}

dependencies {
   compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
   testCompile group: 'junit', name: 'junit', version: '4.+'
}


repositories {
   maven {
      url "http://repo.mycompany.com/maven2"
   }
}

apply plugin: 'maven'

uploadArchives {
   repositories {
      mavenDeployer {
         repository(url: "file://localhost/tmp/myRepo/")
      }
   }
}


 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值