Reputation: 3958
I have buildscript block that references many JARs:
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)
}
I want to copy (to my WAR file) some of the referenced JARs (e.g. dependencies of gradle-css-plugin, gradle-js-plugin, closure-compiler) but not others (e.g. gretty, jmeter-gradle-plugin).
How do I exclude for example jmeter-gradle-plugin and all its dependencies?
UPDATE:
There are 150+ JARs. Excluding them by file name is not practical/maintainable.
Upvotes: 0
Views: 597
Reputation: 11413
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' }
}
}
Upvotes: 0