我有一个引用许多JAR的buildscript块:
buildscript {
dependencies { classpath "com.github.kulya:jmeter-gradle-plugin:1.3.4-2.13" }
dependencies { classpath "com.eriwen:gradle-css-plugin:2.14.0" }
dependencies { classpath "com.eriwen:gradle-js-plugin:2.14.1" }
dependencies { classpath "com.google.javascript:closure-compiler:v20160208" }
dependencies { classpath "org.akhikhl.gretty:gretty:+" }
}
task copyWarGradlePlugins(type: Copy) {
destinationDir = file(project.buildDir.name + '/warGradlePlugins')
from (buildscript.configurations.classpath)
}
我想复制(到我的WAR文件)一些引用的JAR(例如gradle-css-plugin,gradle-js-plugin,closure-compiler的依赖项)但不是其他的(例如gretty,jmeter-gradle-plugin) )。
如何排除例如jmeter-gradle-plugin及其所有依赖项?
更新:
有超过150个JAR。按文件名排除它们是不实际/可维护的。
答案 0 :(得分:0)
buildscript {
dependencies { classpath "com.github.kulya:jmeter-gradle-plugin:1.3.4-2.13" }
dependencies { classpath "com.eriwen:gradle-css-plugin:2.14.0" }
dependencies { classpath "com.eriwen:gradle-js-plugin:2.14.1" }
dependencies { classpath "com.google.javascript:closure-compiler:v20160208" }
dependencies { classpath "org.akhikhl.gretty:gretty:+" }
}
task copyWarGradlePlugins(type: Copy) { copy ->
destinationDir = file(project.buildDir.name + '/warGradlePlugins')
copy.from(buildscript.configurations.classpath) { copySpec ->
// exclusions are based on the file name as here you will be handed
// DefaultFileVisitDetails type
copySpec.exclude { it.name.startsWith 'gretty' }
copySpec.exclude { it.name.startsWith 'closure-compiler' }
}
}