关于什么任务的混乱 - 所有打印出来

时间:2013-01-31 15:19:37

标签: gradle

当我执行" gradle tasks --all"

时,我有这个
assemble - Assembles the outputs of this project. [jar]
toneserver:assemble - Assembles the outputs of this project. [toneserver:jar, webserver:jar]
    toneserver:copyJars
    toneserver:zip
webserver:assemble - Assembles the outputs of this project. [webserver:jar]
    webserver:versionFile
    webserver:zip

我真的不知道的是我有toneserver:zip取决于toneserver:jar我有webserver:zip取决于webserver:jar但是这个任务--all并没有显示那些依赖。为什么是这样?以及如何让它真正显示依赖关系?

我的完整gradle文件位于下方(是的,我需要将所有项目中的apply插件仍然移动到子项目部分和其他

allprojects {

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

   //override gradle's default output directory(build) on every project as it conflicts with 
   //our build script called build causing failures.
   buildDir = 'output'

   repositories {
      mavenCentral()
   }

   if (project.hasProperty('myVersion')) {
     project.ext.realVersion = project.myVersion
     project.version = project.myVersion
   } else {
     project.ext.realVersion = 'Developer-Build'
     project.version = 'Developer-Build'
   }

    test {
        beforeTest { desc -> 
            println "Executing test ${desc.name} [${desc.className}]"
        }
    }

   task hello << { task -> println "I'm $task.project.name" }
   build << { task -> println "MASTER: I'm building now" } //"building with classpath=$sourceSets.main.compileClasspath.files"
}

project(':webserver') {
    //play does not follow maven/gradle standard of src/main/java and src/test/java :( :(
    //so we override the directories here...(we should put test in the sourceSets.test.java.srcDirs instead)
    sourceSets.main{
        java.srcDirs = ['app', 'test']
        resources.srcDirs = ['app']
    }

    dependencies {
        compile fileTree(dir: 'lib', include: '*.jar')
        compile fileTree(dir: 'play-1.2.4/framework/lib', include: '*.jar')
        compile fileTree(dir: 'play-1.2.4/framework', include: 'play-*.jar')
    }

    //MOVE this into allprojects to be run by both toneserver and webserver to put a file there...
    task versionFile() << {
        File f = new File('webserver/output/version');
        f.mkdirs()
        File v = new File(f, 'version'+project.ext.realVersion)
        println('output version file='+v.getAbsolutePath())
        v.createNewFile()
    }

    task zip(type: Zip) {
        archiveName 'dashboard-'+project.version+'.zip'
        from('output/version') {
            into('webserver')
        }
        from('..') {
            exclude '**/*.pyc'
            exclude '**/*.class'
            exclude '**/samples-and-tests/**'
            exclude '**/play-1.2.4/documentation/**'
            exclude 'webserver/conf/logback.xml'
            include 'webserver/run*.sh'
            include 'webserver/lib/**'
            include 'webserver/app/**'
            include 'webserver/conf/**'
            include 'webserver/play-1.2.4/**'
            include 'webserver/public/**'
        }
        rename 'prod.(.*)', '$1'
    }
    zip.dependsOn('versionFile')
    zip.dependsOn('jar')
    assemble.dependsOn('zip')

    //playframework has it's own generation of .classpath and .project fils so do not 
    //overwrite their versions.  NEED to call "play.bat eclipsify" here...
    task eclipse(overwrite: true) << {
        if (System.properties['os.name'].toLowerCase().contains('windows')) {
            println "*** WINDOWS "
            def result = exec {
                commandLine 'cmd', '/c', 'play-1.2.4\\play.bat eclipsify' 
            }
        } else {
            println "*** NOT WINDOWS "
            def result = exec {
                commandLine './play-1.2.4/play eclipsify'
            }
        }
    }
}

project(':toneserver') {
    project.ext.genLibDir = file('output/thirdpartylibs')

    configurations {
        all*.exclude module: 'log4j'
    }

    dependencies {
        compile 'com.google.inject:guice:3.0'
        compile 'com.google.protobuf:protobuf-java:2.4.1'

        //weird, why is their maven not working(we drop it in the directory instead)...
        //compile 'org.asteriskjava:asterisk-java:1.0.0.M3'   

        //to be erased as soon as we get the chance...(we should try this NOW and see if it is needed anymore)
        compile 'commons-configuration:commons-configuration:1.8'
        compile 'org.bouncycastle:bcpg-jdk16:1.46'

        compile project(':webserver')

        //gradle is not sucking in transitive dependencies when they exist in another project so we suck them
        //in ourselves here...
        compile fileTree(dir: '../webserver/play-1.2.4/framework/lib', include: '*.jar')
        compile fileTree(dir: '../webserver/lib', include: '*.jar')
        compile fileTree(dir: '../webserver/play-1.2.4/framework', include: 'play-*.jar')

        compile 'org.bouncycastle:bcpg-jdk16:1.46'

        testCompile 'junit:junit:4.11'
    }

    task generateSources {
        project.ext.outputDir = file("$buildDir/generated-src")
        outputDir.exists() || outputDir.mkdirs()
        if (System.properties['os.name'].toLowerCase().contains('windows')) {
            println "*** WINDOWS "
            def result = exec {
                commandLine 'cmd', '/c', '..\\tools\\protoc\\protoc.exe', '--java_out=output\\generated-src', 'src\\schemas\\agentbridge.proto'
            }
        } else {
            throw new RuntimeException("DARN, protoc only works on windows :( :( right now")
        }
    }
    compileJava.dependsOn("generateSources")
    sourceSets {
        main {
            java {
                srcDir 'output/generated-src'
            }
        }
    }

    tasks.eclipse.dependsOn("generateSources")

    task copyJars(type: Copy) {
        from(configurations.compile) {}
        into genLibDir
    }

task initconfig(type:Copy) {
   from('src/staging/toneserver') {
      include '**/*'
   }

   into 'output/staging'
}

    task zip(type: Zip) {
        archiveName 'toneserver-'+project.version+'.zip'
        from('src/staging') {
            include 'toneserver/**'
        }
        from('output/thirdpartylibs') {
            into('toneserver/lib')
        }
        from('output/version') {
            into('webserver')
        }
    }

    zip.dependsOn('copyJars')
    zip.dependsOn('jar')
    assemble.dependsOn('zip')
}

//overwrite the eclipse target so that no .classpath ends up in stserver directory
task eclipse(overwrite: true) {
}

1 个答案:

答案 0 :(得分:2)

gradle tasks --all显示所有任务,但只显示第一级任务依赖项。我同意有一种可视化整个任务图的方法是有用的,但这并不是Gradle目前提供的开箱即用的东西。