fix #239 - require JDK 8 and JDK 11 tests

This commit is contained in:
Daniel Muehlbachler 2020-01-21 12:00:32 +01:00
parent 936cf1c56c
commit c5418674b1
6 changed files with 114 additions and 23 deletions

View file

@ -19,6 +19,25 @@ jobs:
root: .
paths: [ . ]
compile-jdk11:
docker: [{ image: 'circleci/openjdk:11-node' }]
resource_class: medium+
steps:
- checkout
- restore_cache: { key: 'gradle-wrapper-v2-jdk11-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
- restore_cache: { key: 'gradle-cache-v2-jdk11-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
- run: ./gradlew --profile --parallel --stacktrace resolveConfigurations
- save_cache:
key: 'gradle-wrapper-v2-jdk11-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}'
paths: [ ~/.gradle/wrapper ]
- save_cache:
key: 'gradle-cache-v2-jdk11-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}'
paths: [ ~/.gradle/caches ]
- run: ./gradlew --profile --parallel --stacktrace classes testClasses
- persist_to_workspace:
root: .
paths: [ . ]
check:
docker: [{ image: 'circleci/openjdk:8-node' }]
resource_class: medium+
@ -35,6 +54,22 @@ jobs:
- store_test_results: { path: build/test-results }
- store_artifacts: { path: build/reports/tests }
check-jdk11:
docker: [{ image: 'circleci/openjdk:11-node' }]
resource_class: medium+
steps:
- attach_workspace: { at: . }
- restore_cache: { key: 'gradle-wrapper-v2-jdk11-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }
- restore_cache: { key: 'gradle-cache-v2-jdk11-{{ checksum "versions.props" }}-{{ checksum "build.gradle" }}' }
- restore_cache: { key: 'graal-cache' }
- run: sudo apt-get update && sudo apt-get install build-essential zlib1g-dev
- run: ./gradlew --profile --parallel --stacktrace --continue check
- save_cache:
key: 'graal-cache'
paths: [ ~/.gradle/caches/com.palantir.graal ]
- store_test_results: { path: build/test-results }
- store_artifacts: { path: build/reports/tests }
trial-publish:
docker: [{ image: 'circleci/openjdk:8-node' }]
steps:
@ -65,10 +100,17 @@ workflows:
requires: [ compile ]
filters: { tags: { only: /.*/ } }
- compile-jdk11:
filters: { tags: { only: /.*/ } }
- check-jdk11:
requires: [ compile-jdk11 ]
filters: { tags: { only: /.*/ } }
- trial-publish:
requires: [ compile ]
- publish:
requires: [ check ]
requires: [ check, check-jdk11 ]
filters: { tags: { only: /.*/ }, branches: { only: develop } }

View file

@ -158,7 +158,7 @@ public abstract class BaseGraalCompileTask extends DefaultTask {
if (!Files.exists(startCmd.getParent())) {
Files.createDirectories(startCmd.getParent());
}
Files.writeString(startCmd, cmdContent);
Files.write(startCmd, cmdContent.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException(e);
}

View file

@ -16,23 +16,24 @@
package com.palantir.gradle.graal;
import java.util.Arrays;
import java.util.List;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import java.util.Arrays;
import java.util.List;
/**
* Contains options and settings for tuning GraalVM use.
*/
public class GraalExtension {
private static final String WINDOWS_7_ENV_PATH = "C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\SetEnv.cmd";
private static final String WINDOWS_7_ENV_PATH = "C:\\Program Files\\Microsoft SDKs\\"
+ "Windows\\v7.1\\Bin\\SetEnv.cmd";
private static final String DEFAULT_VS_VERSION = "2019";
private static final String DEFAULT_VS_EDITION = "Community";
private static final String DEFAULT_VS_VARS_PATH = "C:\\Program Files (x86)\\Microsoft Visual Studio\\{version}\\{edition}\\VC\\Auxiliary\\Build\\vcvars64.bat";
private static final String DEFAULT_VS_VARS_PATH = "C:\\Program Files (x86)\\Microsoft Visual Studio\\"
+ "{version}\\{edition}\\VC\\Auxiliary\\Build\\vcvars64.bat";
private static final String DEFAULT_DOWNLOAD_BASE_URL = "https://github.com/oracle/graal/releases/download/";
private static final String DOWNLOAD_BASE_URL_GRAAL_19_3 = "https://github.com/graalvm/graalvm-ce-builds/releases/download/";
@ -138,7 +139,7 @@ public class GraalExtension {
return vsVarsPath.orElse(getDefaultVsVarsPath());
}
private final String getDefaultVsVarsPath() {
private String getDefaultVsVarsPath() {
return Integer.parseInt(javaVersion.get()) >= 11
? DEFAULT_VS_VARS_PATH
.replaceAll("\\{version}", vsVersion.getOrElse(DEFAULT_VS_VERSION))

View file

@ -16,9 +16,11 @@
package com.palantir.gradle.graal
import com.palantir.gradle.graal.util.JavaVersionUtil
import nebula.test.IntegrationSpec
import nebula.test.functional.ExecutionResult
import spock.lang.IgnoreIf
import spock.lang.Requires
import static com.palantir.gradle.graal.Platform.OperatingSystem.LINUX
import static com.palantir.gradle.graal.Platform.OperatingSystem.MAC
@ -26,6 +28,7 @@ import static com.palantir.gradle.graal.Platform.OperatingSystem.WINDOWS
class GradleGraalEndToEndSpec extends IntegrationSpec {
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 8 })
def 'test default version nativeImage'() {
setup:
directory("src/main/java/com/palantir/test")
@ -86,6 +89,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
output.getAbsolutePath().execute().text.equals("hello, world (modified)!" + System.lineSeparator())
}
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 8 })
def 'test version 19.3.0 nativeImage'() {
setup:
directory("src/main/java/com/palantir/test")
@ -147,6 +151,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
output.getAbsolutePath().execute().text.equals("hello, world (modified)!" + System.lineSeparator())
}
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 11 })
def 'test version 19.3.0 nativeImage Java 11'() {
setup:
directory("src/main/java/com/palantir/test")
@ -210,6 +215,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
}
// there is no RC version for Windows
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 8 })
@IgnoreIf({ Platform.operatingSystem() == WINDOWS })
def 'test 1.0.0-rc5 nativeImage'() {
setup:
@ -272,6 +278,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
output.getAbsolutePath().execute().text.equals("hello, world (modified)!" + System.lineSeparator())
}
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 8 })
def 'allows specifying additional properties on default version'() {
setup:
directory("src/main/java/com/palantir/test")
@ -321,6 +328,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
output.getAbsolutePath().execute().text.toLowerCase().contains("<html")
}
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 8 })
def 'can build shared libraries on default version'() {
setup:
directory("src/main/java/com/palantir/test")
@ -343,6 +351,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
dylibFile.exists()
}
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 8 })
def 'can build shared libraries on version 19.3.0'() {
setup:
directory("src/main/java/com/palantir/test")
@ -366,6 +375,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
dylibFile.exists()
}
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 11 })
def 'can build shared libraries on version 19.3.0 Java 11'() {
setup:
directory("src/main/java/com/palantir/test")
@ -391,6 +401,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
}
// there is no RC version for Windows
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 8 })
@IgnoreIf({ Platform.operatingSystem() == WINDOWS })
def 'can build shared libraries on 1.0.0-rc5'() {
setup:
@ -415,19 +426,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
dylibFile.exists()
}
def getSharedLibPrefixByOs() {
switch (Platform.operatingSystem()) {
case MAC:
return "dylib"
case LINUX:
return "so"
case WINDOWS:
return "dll"
default:
throw new IllegalStateException("No GraalVM support for " + Platform.operatingSystem())
}
}
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 8 })
def 'should not allow empty mainClass on nativeImage'() {
buildFile << '''
apply plugin: 'com.palantir.graal'
@ -448,6 +447,7 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
result.standardError.contains("No value has been specified for property 'mainClass'")
}
@Requires({ JavaVersionUtil.runtimeMajorVersion() == 8 })
def 'should not allow to add -H:Name'() {
buildFile << '''
apply plugin: 'com.palantir.graal'
@ -469,4 +469,18 @@ class GradleGraalEndToEndSpec extends IntegrationSpec {
then:
result.standardError.contains("Use 'outputName' instead of")
}
def getSharedLibPrefixByOs() {
switch (Platform.operatingSystem()) {
case MAC:
return "dylib"
case LINUX:
return "so"
case WINDOWS:
return "dll"
default:
throw new IllegalStateException("No GraalVM support for " + Platform.operatingSystem())
}
}
}

View file

@ -75,7 +75,7 @@ class GradleGraalPluginIntegrationSpec extends IntegrationSpec {
server.takeRequest().requestUrl.toString() =~ "http://(localhost|127\\.0\\.0\\.1):${server.port}" +
"/oracle/graal/releases/download//vm-1.0.0-rc3/graalvm-ce-1.0.0-rc3-(macos|linux)-amd64.tar.gz"
file("cacheDir/1.0.0-rc3/8/graalvm-ce-java8-1.0.0-rc3-amd64.tar.gz").text == '<<tgz>>'
file("cacheDir/1.0.0-rc3/8/graalvm-ce-1.0.0-rc3-amd64.tar.gz").text == '<<tgz>>'
}
// for Windows the download is a .zip, this is tested below
@ -108,7 +108,7 @@ class GradleGraalPluginIntegrationSpec extends IntegrationSpec {
server.takeRequest().path =~
"/oracle/graal/releases/download//vm-19.0.0/graalvm-ce-(darwin|linux)-amd64-19.0.0.tar.gz"
file("cacheDir/19.0.0/8/graalvm-ce-java8-19.0.0-amd64.tar.gz").text == '<<tgz>>'
file("cacheDir/19.0.0/8/graalvm-ce-19.0.0-amd64.tar.gz").text == '<<tgz>>'
}
@Requires({ Platform.operatingSystem() == Platform.OperatingSystem.WINDOWS })

View file

@ -0,0 +1,34 @@
/*
* (c) Copyright 2018 Palantir Technologies Inc. All rights reserved.
*
* 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 com.palantir.gradle.graal.util;
public class JavaVersionUtil {
public static int runtimeMajorVersion() {
String version = System.getProperty("java.version");
if (version.startsWith("1.")) {
version = version.substring(2, 3);
} else {
int dot = version.indexOf(".");
if (dot != -1) {
version = version.substring(0, dot);
}
}
return Integer.parseInt(version);
}
private JavaVersionUtil() {}
}