I am working on a Gradle Project that uses multiple Sourcesets to build different WARs.
Everything works fine from command line. Gradle builds the WARs correctly. But in IntelliJ it says for every *.java file under src/k that it can not resolve the dependencies from src/main.
I tried to fix it by adding the directories as SourceDirs using the idea-gradle plug in but that did not work, unfortenetly.
plugins {
id 'org.gretty' version '2.2.0'
id 'war'
id 'idea'
}
configurations {
kCompile.extendsFrom compile
kRuntime.extendsFrom runtime
}
sourceSets {
main {}
k {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDirs = ['src/main/java', 'src/k/java/']
}
resources {
compileClasspath += main.output
runtimeClasspath += main.output
srcDirs = ['src/main/resources', 'src/k/resources']
}
output.resourcesDir = 'build/resources/main'
output.classesDir = 'build/classes/java/main'
}
}
idea {
module {
sourceDirs += file('src/main/java')
sourceDirs += file('src/k/java')
downloadJavadoc = true
downloadSources = false
}
}
repositories {
mavenCentral()
jcenter()
}
gretty {
servletContainer = 'tomcat85'
}
dependencies {
...
}
task kWar(type: War) {
appendix = "k"
from sourceSets.k.output
}
farm {
webapp "build/libs/App-k.war", contextPath: '/k'
}
project.afterEvaluate {
farmRunWar.dependsOn kWar
farmRunWar.shouldRunAfter kWar
}
I found a fix where I had to add the dependency for main manually to k in Intellij via File > Project Structure > App_k > + > module dependency > App_main > ok. Is there a way to tell Intellij to do this with the idea gradle-plug-in ?