Reputation: 19877
In the Gradle samples (included with version 2.2.1) there is a java/multiproject project.
The settings.gradle
file defines the following projects:
include "shared", "api", "services:webservice", "services:shared"
Note that services
is not itself a project, merely a directory which contains the webservice
and shared
projects.
When I run the command gradle build
from the root directory, I notice that after gradle successfully builds it creates inside the /services
directory a /build
directory containing /lib
and a /tmp
directories.
Inside of /services/build/lib
is a jar: services-1.0.jar
which contains very little; specifically just a META-INF/MANIFEST.MF
file containing:
Manifest-Version: 1.0
provider: gradle
So what is causing Gradle to build a jar for this non-project? And how can I prevent this behavior in my similarly structured multiproject project?
/services
isn't a project, I don't want to create anything inside /build
folder at all. Yes I could just delete it, but I would like to avoid the unnecessary work of building this jar/running any tasks on this non-project in the first place.
Upvotes: 5
Views: 2241
Reputation: 84884
To be honest I've no reasonable idea why gradle builds this folder. I guess that because it's a kind of a transient
folder. However it can be excluded by adding the following piece of code to main build.gradle
script:
project(':services').jar { onlyIf { false } }
Desired effect (services.jar
elimination) can be also obtained with the following settings.gradle
content:
include "shared", "api", "services/webservice", "services/shared"
File instead of project paths are included.
Upvotes: 4
Reputation: 9386
My guess would be that this is a combination of the next 2 gradle rules:
When you're including subprojects in the build.settings file using the include
keyword according to Gradle Documentation here:
the inclusion of the path 'services:hotels:api' will result in creating 3 projects: 'services', 'services:hotels' and 'services:hotels:api'.
In simple words, this means that the inclusion of services::webservice will also build the services project
The bulid.gradle file in your root that applies the 'java' plugin. According to Gradle Documentation here every configuration defined in the root.gradle takes effect for all sub projects. This means that it will also hold as the default configuration for the services project. As the 'java' plugin was applied a jar will be created, but as there is no src/main folder under the services directory nothing will be compiled and the jar will include only a META-INF/MANIFEST.MF
file.
Upvotes: 3