My gradle configuration is such that all the dependencies and application jars go in the libs folder. The build directory has following sub-directories classes
, dependency-cache,
libs
, resources
and tmp
. I want the gradle to only generate libs and resources and not the others. What gradle configuration is required to do this?
My current gradle file:
plugins {
id 'java'
}
sourceCompatibility = 1.8
task copyToLib(type: Copy) {
into libsDir
from configurations.runtime
}
jar {
dependsOn copyToLib
manifest {
attributes(
'Main-Class': 'ApiTesting'
)
}
}
repositories {
mavenCentral()
}
dependencies {
...
}
The initial reaction to your question is: why are these extra folders in build
a problem?
But thinking more about it, the best answer is: do not fight the tool.
Instead of preventing it to work according to conventions, you should design your downstream tasks to not care. If you need a very special format for further consumption, either inside or outside the build, it is trivial to add a Copy
or Sync
task that will create that structure from the regular build
output into a tailored custom location. Which can be yet another build
subfolder.
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.