首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Gradle中复制一些buildscript类路径JAR,但排除其他的?

如何在Gradle中复制一些buildscript类路径JAR,但排除其他的?
EN

Stack Overflow用户
提问于 2017-04-25 00:06:13
回答 1查看 431关注 0票数 0

我有引用了很多JAR的buildscript块:

代码语言:javascript
复制
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文件)一些引用的WAR(例如gradle-css-plugin,gradle-js-plugin的依赖项,闭包编译器),而不是其他的(例如gretty,jmeter gradle-plugin)。

例如,我如何排除jmeter gradle-plugin及其所有依赖项?

更新:

这里有150+罐子。按文件名排除它们是不实际的,也是不可维护的。

EN

回答 1

Stack Overflow用户

发布于 2017-04-25 01:27:57

代码语言:javascript
复制
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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43592915

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档