我有这个 gradle 构建文件。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
classpath 'com.eriwen:gradle-css-plugin:1.2.1'
classpath 'com.eriwen:gradle-js-plugin:1.5.1'
}
}
apply plugin: 'android'
apply plugin: 'js'
apply plugin: 'css'
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/cordova-2.7.0.jar')
compile files('libs/libGoogleAnalyticsV2.jar')
}
task MinifyJSForRelease {
tasks.add(name:"copyTask2", type:Copy){
from 'assets/'
into 'build/minifiedassets/assets'
}
it.dependsOn copyTask2
def tester = fileTree(dir:"build/minifiedassets/assets", include:"**/*.js");
println tester
tester.eachWithIndex {File file, idx ->
tasks.add(name: "makeMinifyJS${idx}", type: com.eriwen.gradle.js.tasks.MinifyJsTask) {
source = file
dest = "${file.path}"
closure {
compilerOptions.languageIn = "ECMASCRIPT5"
}
}
}
it.dependsOn tasks.matching { Task task -> task.name.startsWith("makeMinifyJS")}
}
build.dependsOn MinifyJSForRelease
android {
compileSdkVersion 17
buildToolsVersion "17"
signingConfigs {
release {
storeFile file('keystores/mobilecoe_android.keystore')
storePassword "mobilecoe"
keyAlias "MobileCoE"
keyPassword "mobilecoe"
}
}
defaultConfig {
minSdkVersion 10
targetSdkVersion 16
}
buildTypes {
debug {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
release {
signingConfig signingConfigs.release
zipAlign true
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['build/minifiedassets/assets']
}
instrumentTest.setRoot('tests')
}
}
}
}
我想像第一件事一样运行任务MinifyJSForRelease
,将资产文件夹复制到我想要的位置,然后在完成后我想缩小 JS 文件。现在,当我运行任务时,它会复制文件夹但没有到达末尾,下一个函数说它没有什么可以缩小的,但是如果我第二次运行任务(当文件夹已被复制时),它会阻止它并执行所有操作。
我做错了什么?我需要:
- 复制文件夹
- 获取文件夹并缩小其 js 文件
有人可以帮我吗?