Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent Gradle from building a non-project directory?

Tags:

gradle

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.

like image 578
Tom Tresansky Avatar asked Mar 16 '23 19:03

Tom Tresansky


1 Answers

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.

like image 97
Opal Avatar answered Mar 21 '23 15:03

Opal