`

Gradle notes

 
阅读更多

eclipse{
 classpath{
  defaultOutputDir = file('eclipse-bin')

  file{
   whenMerged{ cp ->
    def e = cp.entries.find{
     (it.getKind() == 'src') && (it.path == 'src')
    }

    def includes = (sourceSets.main.java.includes << sourceSets.main.resources.includes).flatten()
    includes.each{
     if(!e.includes.contains(it)){
      e.includes.add(it)
    }}}} }}

 

task copyToLib(type: Copy){
 into "${buildDir}/libs"
 from configurations.runtime
}

build.dependsOn(copyToLib)

task wrapper(type: Wrapper) {
 gradleVersion = '2.1'
 archiveBase = 'PROJECT'
 archivePath = 'gradle/wrapper/archive'
 distributionBase = 'PROJECT'
 distributionPath = 'gradle/wrapper/dist'
 distributionUrl = '../../tools/gradle/gradle-2.1-bin.zip'
 jarFile = "${project.projectDir}/gradle/wrapper/gradle-wrapper.jar"
}

 

task

startdb2 << {

 

def processBuilder = new ProcessBuilder(['cmd','/c','startHsqlDB.cmd'])

 

processBuilder.directory(new File("./"))

 

processBuilder.start()

 

}

 

task startdb(type: Exec){

workingDir "./"

doFirst(){

print "start the hsql database."

}

commandLine 'cmd', '/c', 'startHsqlDB.cmd'

standardOutput = new ByteArrayOutputStream(

//ext.output = { return standardOutput.toString() }

}

task

deployToTomcat(type: Exec, dependsOn: 'war'){

workingDir "./"

doFirst(){

print "start to deploy to tomcat..."

}

commandLine 'cmd', '/c', 'deploy2tomcat.cmd'

standardOutput = new ByteArrayOutputStream()

ext.output = { return standardOutput.toString() }

}

 


task deploy2tomcat(dependsOn: ':web:war') {
    doFirst{
        println "Executing TASK ${name}"
    }
    doLast{
        //project(':web').deployToTomcat.execute()
        def processBuilder = new ProcessBuilder(["cmd","/c","deploy2tomcat.cmd"])
        processBuilder.directory(new File("./"))
       
        //processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE)
        processBuilder.redirectErrorStream(true);
       
       
        Process process = processBuilder.start()
        BufferedInputStream bis = new BufferedInputStream(process.getInputStream());
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream()
       
        def buf = new byte[1024]
        def len = -1;

        while( (len=bis.read(buf)) > 0 ){
           
            bos.write(buf, 0, len)
            println "WRITE " + len
        }
       
        println bos.toString()

        bis.close()
        bos.close()
        process.destroy()
        println 'Finished deploying WAR to tomcat...'
    }
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics