My gradle
project is a multi-project
structure. It consists of two subprojects. My build.gradle
in root project as following:
allprojects { apply plugin: 'eclipse' } subprojects { apply plugin: 'java' apply plugin: 'maven-publish' publishing { repositories { maven { name 'myMaven' def suffix = project.version.endsWith("SNAPSHOT") ? "snapshots" : "releases" url baseUrl + suffix } } publications { core(MavenPublication) { artifactId project.name artifact jar } } } } project(':projectA') { ext { sharedManifest = manifest { attributes("Implementation-Title": project.name, "Implementation-Version": 1.0 ) } } jar { manifest = project.manifest { from sharedManifest } } } project('projectB') { ext { sharedManifest = manifest { attributes("Implementation-Title": project.name, "Implementation-Version": 2.0 ) } } jar { manifest = project.manifest { from sharedManifest } } }
After gradle build
, I got three build folders. one at the root directory and other two in the respective subprojects. The root project is just an empty folder without any source code, it is just a multi-project container.
Now I need to eliminate the creation of root build folder since it is of no use. I search on the net and in the gradle docs/forum but did not get any hit.
Is there any way so that gradle stop creating build folder at root level?
1 Answers
Answers 1
Who is responsible for the build
dir creation ?
According to Mark Vieira, a Gradle core dev, each task is responsible for the creation of the ouput dir as long as it creates output.
So basically, it your root project does have a build
dir, it means it's not empty and something is deliberately writing into it.
In my job, I'm managing a big project constituted by a root project, which handles many .gradle
files, settings files etc. and many subprojects with the actual code. When I run gradle clean build
, all subprojects get their own build
dir with libs, binaries etc. but the root project does not end up with any build
dir because no task whatsoever writes output in the root build
dir.
What can I do to remove the root build
dir, whatever task creating it ?
Just set up a buildFinished
hook only for the root project
gradle.buildFinished { project.buildDir.deleteDir() }
0 comments:
Post a Comment