When applying a multi-project Gradle structure to our project, my settings.gradle looks like this:
include "source:compA:api"
include "source:compA:core"
include "source:compB"
gradle projects give me
Root project 'tmp'
\--- Project ':source'
+--- Project ':source:compA'
| +--- Project ':source:compA:api'
| \--- Project ':source:compA:core'
\--- Project ':source:compB'
This is exactly the directory structure!
In my root directory I have a build.gradle which applies the java plugin to all subprojects:
subprojects {
apply plugin: 'java'
}
When building I end up having artifacts for :source:compA which are empty because this is actually not a project just the subdirectories api and core are proper Java projects.
What’s the best way to avoid having an empty artifact?
You can try using the trick they use in Gradle’s own settings.gradle file. Note how each of the sub projects are located in the
'subprojects/${projectName}'folder, but thesubprojectsfolder itself is not a project.So in your case you’d do something like:
I have intentionally omitted the colon between
compAandapito make suresource:compAdoes not get evaluated as a project container.Alternatively, you can try excluding the
source:compAproject from having thejavaplugin applied to it, by doing something like:Edit:
Alternatively you can try something like this (adjust to your liking):