[英]Code for different Java versions with Gradle
Can I possibly make Gradle compile one part of my app for Java version 1.8 and the other for 1.7?我可以让 Gradle 为 Java 版本 1.8 编译我的应用程序的一部分,而另一部分为 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.我的情况是我正在写一个库,其中一部分将用于版本为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.编辑:如果可能的话,建议任何相关术语,因为我现在什至想不出谷歌查询。
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 : Java-1.7-项目构建文件:
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.