Reputation: 341
Can I possibly make Gradle compile one part of my app for Java version 1.8 and the other for 1.7? My situation is I'm writing a library, part of which will be used in a project where the version is 1.7.
I realize now that I could have broken logic in my thoughts, but the question still stands. Or, if possible, suggest something completely different.
EDIT: And if possible suggest any relevant terms, because I can't even think of a google query now.
Upvotes: 1
Views: 297
Reputation: 2502
Suppose you have a multi project build with the following directory structure:
Root project build file:
plugins {
java
}
allprojects {
group = "com.company.example"
version = "0.0.1"
apply {
plugin("java")
}
repositories {
mavenCentral()
}
}
configure(subprojects.filter { it.name != "java-1.7" }) {
java.sourceCompatibility = org.gradle.api.JavaVersion.VERSION_11
}
Java-1.7-project build file:
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
Upvotes: 2