Gradle build 里Copy任务执行了没效果
初用gradle呀 ,碰到一个问题,Android项目,在app模块的build.gradle里边,Android节点里,写了一个Copy类型的task,如下:
task copyCode(type: Copy){
println("Copy JavaA..........1")
delete 'src/main/javaB/1.txt'
from 'src/main/javaA/1.txt'
into 'src/main/javaB'
println("Copy JavaA..........2")
}
单在AS 运行这个task, 或者切到命令行下执行命令:
gradlew copyCode
会打印出log:
> Configure project :app
Copy JavaA..........1
Copy JavaA..........2
并可以执行copy文件的动作,使用AS build或者执行命令gradle build,或者gradle assembleDebug,
也会打印出:
Copy JavaA..........1
Copy JavaA..........2
但是并没有执行文件的copy操作,文件并没有被copy过去。这是为什么呢?
大家能否指点呀,谢谢~
下面是没执行Copy动作的log,
Copy JavaA..........1
Copy JavaA..........2
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE
:app:transformDexArchiveWithDexMergerForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:transformNativeLibsWithStripDebugSymbolForDebug UP-TO-DATE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug
:app:packageDebug UP-TO-DATE
:app:assembleDebug UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:checkReleaseManifest UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:createReleaseCompatibleScreenManifests UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:splitsDiscoveryTaskRelease UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:javaPreCompileRelease UP-TO-DATE
:app:compileReleaseJavaWithJavac UP-TO-DATE
:app:compileReleaseNdk NO-SOURCE
:app:compileReleaseSources UP-TO-DATE
:app:mergeReleaseShaders UP-TO-DATE
:app:compileReleaseShaders UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:transformClassesWithPreDexForRelease UP-TO-DATE
:app:transformDexWithDexForRelease UP-TO-DATE
:app:mergeReleaseJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE
:app:transformNativeLibsWithStripDebugSymbolForRelease UP-TO-DATE
:app:processReleaseJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:app:packageRelease UP-TO-DATE
:app:lintVitalRelease SKIPPED
:app:assembleRelease UP-TO-DATE
:app:assemble UP-TO-DATE
:app:lint
Ran lint on variant debug: 3 issues found
Ran lint on variant release: 3 issues found
Wrote HTML report to file:///C:/work/code/AS_WorkSplace/ODM/app/build/reports/lint-results.html
Wrote XML report to file:///C:/work/code/AS_WorkSplace/ODM/app/build/reports/lint-results.xml
:app:preDebugUnitTestBuild UP-TO-DATE
:app:javaPreCompileDebugUnitTest UP-TO-DATE
:app:compileDebugUnitTestJavaWithJavac UP-TO-DATE
:app:mockableAndroidJar UP-TO-DATE
:app:processDebugUnitTestJavaRes NO-SOURCE
:app:testDebugUnitTest UP-TO-DATE
:app:preReleaseUnitTestBuild UP-TO-DATE
:app:javaPreCompileReleaseUnitTest UP-TO-DATE
:app:compileReleaseUnitTestJavaWithJavac UP-TO-DATE
:app:processReleaseUnitTestJavaRes NO-SOURCE
:app:testReleaseUnitTest UP-TO-DATE
:app:test UP-TO-DATE
:app:check
:app:build
BUILD SUCCESSFUL in 9s
57 actionable tasks: 2 executed, 55 up-to-date