我需要从gradle任务中执行一些特定的grunt任务。 以下是我的gradle任务:
task gruntDefaultTask(type: GruntTask, dependsOn: 'npmInstall') {
group = 'build'
args = ["default", "--debug"]
}
task updateFingerPrint (type: GruntTask) {
group = 'build'
doLast {
fileTree("${project.projectDir}/build/fingerprint").filter { it.isFile() }.files.name.each { name ->
def splittedModule = name.split(".min-")
def moduleName = splittedModule[0]
def fingerPrint = splittedModule[1].split("\\.")[0]
println "Executing fingerprinting updates"
args = ["updateFingerPrints", moduleName, fingerPrint]
}
}
}
这是我在Gruntfile.js中的咕unt任务
grunt.registerTask('updateFingerPrints', function(args) {
console.log('Attempting to update FingerPrints to ' + args);
if ( !args) {
grunt.log.error('No Fingerprints found.')
return;
}
if (pkg['version'] === args) {
grunt.log.error('Version number same as current version.')
return;
}
if (!/^\d+.\d+.\d+$/.test(args)) {
grunt.log.error('! Invalid version number format. Must be in d.d.d format. Eg: 1.0.0');
return;
}
pkg['fingerprint'] = args;
pkg['modifiedAt'] = ((new Date()).valueOf().toString());
grunt.file.write('package.json', JSON.stringify(pkg, null, 2));
grunt.log.write('\n\n#################Successfully changed FingerPrint Information. ########################\n');
grunt.log.write('1. FingerPrint: ' + pkg['version'] + '\n');
grunt.log.write('2. ModifiedAt: ' + pkg['modifiedAt'] + '\n');
grunt.log.write('########################################################################################\n');
});
每次执行gradle tasks updateFingerPrint
时,它不会执行updateFingerPrint grunt任务,而是执行grunt默认任务
下面是我的默认任务:
grunt.registerTask('default', 'build component with dependencies included (distribution scope)',
[
'build',
'minify',
'clean_temp'
]
);
:
如何执行updateFingerPrint gradle任务以执行grunt updateFingerPrint任务。谢谢