2017-04-24 38 views
0

我已經buildscript塊引用許多JAR文件:如何複製一些buildscript classpath JAR但排除Gradle中的其他人?

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-插件的依賴關係,gradle這個JS-插件,封閉編譯器)而不是其他(例如gretty,jmeter-gradle-plugin)。

如何排除例如jmeter-gradle-plugin及其所有依賴項?

更新:
有150多個JAR。通過文件名排除它們是不實際/可維護的。

回答

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' } 
    } 
} 
+0

有150多個JAR。通過名稱排除它們是不實際的或可維護的, – isobretatel

相關問題