I am creating a project which creates Jar files out of it and i wanted some of the jars to be excluded from the final jar created from the project.
I am trying as below, even though i have given providedCompile, those jars also included in the final jar.
Tried with providedRuntime, i was getting compile time error. also i want ignore Tomcat related jars, can anyone help me?
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"
}
}
Note: I have tried with provided-base plugin and other suggestions given in the google
Thanks for your help
I was able to resolve using jar method as below
jar {
from {
(configurations.runtime - configurations.providedCompile).collect {
it.isDirectory() ? it : it
}
}
}
this jar method create simple jar excluding providedCompile jars but build task still add jar. need to use 'jar' task
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.