Joint compilation of Java/Scala in 6.1

In 6.1, we got a new feature to model compilation order for java/scala.
Can this feature also be used to model an interdependence from java to scala and vice versa (e.g. some java classes depend on scala and some scala classes depend on java)?

My guess is that it cannot be used, but still wanted to inquire (might be worth mentioning in user guide).

I’m currently using the sourcesets to model that

    val sourceSets = the<SourceSetContainer>()
sourceSets {
    named("main") {
        withConvention(ScalaSourceSet::class) {
            scala {
                setSrcDirs(listOf("src/main/scala", "src/main/java"))
            }
        }
        java {
            setSrcDirs(emptyList<String>())
        }
    }

    named("test") {
        withConvention(ScalaSourceSet::class) {
            scala {
                setSrcDirs(listOf("src/test/scala", "src/test/java"))
            }
        }
        java {
            setSrcDirs(emptyList<String>())
        }
    }
}

@AHeise you are right, the feature cannot be used for that.

The thing you are doing right now is joint compilation of Scala and Java, which means the Scala compile task is taking care of both Scala and Java compilation. This is a separate feature (which is also available for Groovy). And it is the correct feature to use for your use case.

The compile order feature in 6.1 is just for ordering compilation performed by different tasks (which is not joined). This is mostly interesting if you want to combine Scala, Groovy, and Kotlin in some way for which no joint compilation exists.

Thank you. That’s what I thought. Just didn’t want to avoid passing on a new cool feature to improve build times.

1 Like