我正在创建一个项目,用它创建Jar文件,我希望将一些jar从项目创建的最后jar中排除出来。
我正在尝试如下所示,即使我已经给出了providedCompile,这些jar也包含在最后的jar中。
尝试使用providedRuntime,我得到了编译时错误。我也想忽略Tomcat相关的罐子,有人能帮我吗?
apply plugin: "spring-boot"
apply plugin: "java"
apply plugin: "groovy"
apply plugin: "eclipse"
apply plugin: "idea"
repositories {
mavenLocal()
mavenCentral
}
configurations {
providedCompile
compile.extendsFrom providedCompile
}
jar {
exclude ("*db/**")
}
dependencies {
compile ("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}") {
exclude group:"org.springframework.boot", module: "spring-boot-starter-tomcat"
}
providedCompile "com.oracle:ojdbc6:11.2.0"
providedCompile "javax.servlet:javax.servlet-api:${servletApiVersion}"
// hc-commons jars
providedCompile "com.test.hc-commons:hc-commons-exception:${hcCommonsVersion}"
providedCompile "com.test.hc-commons:hc-commons-utils:${hcCommonsVersion}"
providedCompile "com.test.hc-commons:hc-commons-typeconverters:${hcCommonsVersion}"
providedCompile "com.test.hc-commons:hc-commons-mailing:${hcCommonsVersion}"
compile ("org.springframework.boot:spring-boot-starter-velocity:${springBootVersion}") {
exclude group:"org.springframework.boot", module: "spring-boot-starter-tomcat"
}
}注意:我尝试了提供的基本插件和在google中给出的其他建议。
谢谢你的帮忙
发布于 2015-09-04 17:48:54
我能够使用jar方法解析,如下所示
jar {
from {
(configurations.runtime - configurations.providedCompile).collect {
it.isDirectory() ? it : it
}
}
}这个jar方法创建简单的jar,不包括providedCompile jar,但是构建任务仍然添加jar。需要使用“jar”任务
https://stackoverflow.com/questions/32380335
复制相似问题