I feel like I’m missing something trivial but can’t figure out what’s wrong. I have a multi-module build like this:
rootBuildFile << """
"""
sharedBuildFile << """
apply plugin: 'java'
"""
serverBuildFile << """
apply plugin: 'java'
dependencies {
compile project(":shared")
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
configurations.compile.dependencies.each {
from files(it.dependencyProject.sourceSets.main.allSource)
}
}
"""
rootSettingsFile << """
include 'shared', 'server'
"""
Basically, I have root module and two submodules where :server
needs :shared
. I want to create a task that will build an uber-jar with sources from both projects. The issue is this setup fails during project evaluation with Could not get unknown property 'sourceSets' for project ':shared'
which means :shared
was not evaluate yet at the point it’s accessed and java
plugin was not applied yet. Placing the task into afterEvaluate {}
does not help and only defers the issue until configuration phase: A problem occurred configuring project ':server'
. Applying java
in subprojects
helps but creates an expectation that either every subproject is java-based, or would require filtering and knowledge about specific subprojects in a root one which is suboptimal.
Is there any way to have it evaluated/configured before that?