gradle不能在Jar Type任务中使用特定的jar文件

时间:2016-04-26 07:55:33

标签: java android gradle jar

这是我的full code,我的罐子就像:

task roJar(type: Jar, dependsOn: assembleRelease) << {
    destinationDir = new File("/tmp/ro-adr")
    archiveName = "ro-adr.jar"
    from(new File(buildDir, "intermediates/classes/release/ro/adr")) {
        exclude("R\$*")
    }
    from(new File(buildDir, "intermediates/bundles/release/res"))
}

当我调用roJar并检查输出jar文件时,它不存在,完整输出是:

roroco@roroco ~/Dropbox/jvs/ro-adr $ gd roJar
args:["roJar"] ---- gd.rb:10
gradle -x test --daemon roJar -s
:adr:preBuild UP-TO-DATE
:adr:preReleaseBuild UP-TO-DATE
:adr:compileReleaseNdk UP-TO-DATE
:adr:compileLint
:adr:copyReleaseLint UP-TO-DATE
:adr:checkReleaseManifest
:adr:preDebugAndroidTestBuild UP-TO-DATE
:adr:preDebugBuild UP-TO-DATE
:adr:preDebugUnitTestBuild UP-TO-DATE
:adr:preReleaseUnitTestBuild UP-TO-DATE
:ro:compileJava UP-TO-DATE
:ro:processResources UP-TO-DATE
:ro:classes UP-TO-DATE
:ro:jar UP-TO-DATE
:adr:prepareComAndroidSupportAnimatedVectorDrawable2321Library UP-TO-DATE
:adr:prepareComAndroidSupportAppcompatV72321Library UP-TO-DATE
:adr:prepareComAndroidSupportDesign2321Library UP-TO-DATE
:adr:prepareComAndroidSupportRecyclerviewV72321Library UP-TO-DATE
:adr:prepareComAndroidSupportSupportV42321Library UP-TO-DATE
:adr:prepareComAndroidSupportSupportVectorDrawable2321Library UP-TO-DATE
:adr:prepareComAndroidSupportTestEspressoEspressoCore221Library UP-TO-DATE
:adr:prepareComAndroidSupportTestEspressoEspressoIdlingResource221Library UP-TO-DATE
:adr:prepareComAndroidSupportTestExposedInstrumentationApiPublish041Library UP-TO-DATE
:adr:prepareComAndroidSupportTestRules041Library UP-TO-DATE
:adr:prepareComAndroidSupportTestRunner041Library UP-TO-DATE
:adr:prepareOrgAdwLibraryDiscreteSeekbar101Library UP-TO-DATE
:adr:prepareReleaseDependencies
:adr:compileReleaseAidl UP-TO-DATE
:adr:compileReleaseRenderscript UP-TO-DATE
:adr:generateReleaseBuildConfig UP-TO-DATE
:adr:generateReleaseAssets UP-TO-DATE
:adr:mergeReleaseAssets UP-TO-DATE
:adr:generateReleaseResValues UP-TO-DATE
:adr:generateReleaseResources UP-TO-DATE
:adr:mergeReleaseResources UP-TO-DATE
:adr:processReleaseManifest UP-TO-DATE
:adr:processReleaseResources UP-TO-DATE
:adr:generateReleaseSources UP-TO-DATE
:adr:compileReleaseJavaWithJavac UP-TO-DATE
:adr:extractReleaseAnnotations UP-TO-DATE
:adr:mergeReleaseProguardFiles UP-TO-DATE
:adr:packageReleaseRenderscript UP-TO-DATE
:adr:packageReleaseResources UP-TO-DATE
:adr:processReleaseJavaRes UP-TO-DATE
:adr:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:adr:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
:adr:mergeReleaseJniLibFolders UP-TO-DATE
:adr:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:adr:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
:adr:bundleRelease UP-TO-DATE
:adr:compileReleaseSources UP-TO-DATE
:adr:assembleRelease
:adr:roJar
archivePath:/tmp/ro-adr/ro-adr.jar

BUILD SUCCESSFUL

Total time: 1.948 secs
roroco@roroco ~/Dropbox/jvs/ro-adr $ lsa /tmp/ro-adr/ro-adr.jar
ls: cannot access /tmp/ro-adr/ro-adr.jar: No such file or directory

更新

即使我简化了任务:

task roJar(type: Jar) << {
//    destinationDir = new File("/tmp/ro-adr")
    archiveName = "ro-adr.jar"
    from("/home/roroco/Dropbox/jvs/ro-adr/adr/build.gradle")
//    from(new File(buildDir, "intermediates/classes/release/ro/adr")) {
//        exclude("R\$*")
//    }
//    from(new File(buildDir, "intermediates/bundles/release/res"))
}

它仍然无法运作,我找不到任何jar

更新

我发现原因是&#34;&lt;&lt;&#;&#34;当我发现它时,一切正常,谁能告诉我原因?

1 个答案:

答案 0 :(得分:0)

<< { }doLast { }的快捷方式,因此您未在配置时配置任务,但在执行时为时已晚。请参阅https://docs.gradle.org/current/userguide/userguide_single.html#N10BF6,尤其是第14.7节的最后一段。