-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat toolchain requirements as inputs
- Loading branch information
Benjamin Muskalla
committed
Nov 18, 2020
1 parent
331c1ee
commit f056aa3
Showing
7 changed files
with
164 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ects/platform-jvm/src/main/java/org/gradle/jvm/toolchain/internal/JavaToolchainInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2020 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.gradle.jvm.toolchain.internal; | ||
|
||
import org.gradle.api.tasks.Input; | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion; | ||
import org.gradle.jvm.toolchain.JavaToolchainSpec; | ||
|
||
public class JavaToolchainInput { | ||
|
||
private final JavaToolchainSpec spec; | ||
|
||
public JavaToolchainInput(JavaToolchainSpec spec) { | ||
this.spec = spec; | ||
} | ||
|
||
@Input | ||
JavaLanguageVersion getLanguageVersion() { | ||
return spec.getLanguageVersion().get(); | ||
} | ||
|
||
@Input | ||
String getVendor() { | ||
return spec.getVendor().get().toString(); | ||
} | ||
|
||
@Input | ||
String getImplementation() { | ||
return spec.getImplementation().get().toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...tform-jvm/src/test/groovy/org/gradle/jvm/toolchain/internal/JavaToolchainInputTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright 2020 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.gradle.jvm.toolchain.internal | ||
|
||
|
||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.gradle.jvm.toolchain.JvmImplementation | ||
import org.gradle.jvm.toolchain.JvmVendorSpec | ||
import org.gradle.util.TestUtil | ||
import spock.lang.Specification | ||
|
||
class JavaToolchainInputTest extends Specification { | ||
|
||
def "optional properties are using defaults"() { | ||
given: | ||
def baseSpec = new DefaultToolchainSpec(TestUtil.objectFactory()) | ||
def diffSpec = new DefaultToolchainSpec(TestUtil.objectFactory()) | ||
baseSpec.languageVersion.set(JavaLanguageVersion.of(11)) | ||
diffSpec.languageVersion.set(JavaLanguageVersion.of(11)) | ||
def base = new JavaToolchainInput(baseSpec) | ||
def diff = new JavaToolchainInput(diffSpec) | ||
|
||
expect: | ||
base.languageVersion == diff.languageVersion | ||
base.vendor == diff.vendor | ||
base.implementation == diff.implementation | ||
} | ||
|
||
def "language version is stable"() { | ||
given: | ||
def base = new JavaToolchainInput(newSpec(11)) | ||
def diff = new JavaToolchainInput(newSpec(11)) | ||
|
||
expect: | ||
base.languageVersion == diff.languageVersion | ||
base.vendor == diff.vendor | ||
base.implementation == diff.implementation | ||
} | ||
|
||
def "change in language version is a different input"() { | ||
given: | ||
def base = new JavaToolchainInput(newSpec(11)) | ||
def diff = new JavaToolchainInput(newSpec(14)) | ||
|
||
expect: | ||
base.languageVersion != diff.languageVersion | ||
base.vendor == diff.vendor | ||
base.implementation == diff.implementation | ||
} | ||
|
||
def "change in vendor is a different input"() { | ||
given: | ||
def base = new JavaToolchainInput(newSpec(11, "adoptopenjdk")) | ||
def diff = new JavaToolchainInput(newSpec(11, "amazon")) | ||
|
||
expect: | ||
base.languageVersion == diff.languageVersion | ||
base.vendor != diff.vendor | ||
base.implementation == diff.implementation | ||
} | ||
|
||
def "change in implementation is a different input"() { | ||
given: | ||
def base = new JavaToolchainInput(newSpec(11, "adoptopenjdk", JvmImplementation.VENDOR_SPECIFIC)) | ||
def diff = new JavaToolchainInput(newSpec(11, "adoptopenjdk", JvmImplementation.J9)) | ||
|
||
expect: | ||
base.languageVersion == diff.languageVersion | ||
base.vendor == diff.vendor | ||
base.implementation != diff.implementation | ||
} | ||
|
||
def newSpec(int languageVersion, String vendor = "ibm", JvmImplementation impl = JvmImplementation.VENDOR_SPECIFIC) { | ||
def spec = new DefaultToolchainSpec(TestUtil.objectFactory()) | ||
spec.languageVersion.set(JavaLanguageVersion.of(languageVersion)) | ||
spec.vendor.set(JvmVendorSpec.matching(vendor)) | ||
spec.implementation.set(impl) | ||
spec | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters