Skip to content

Commit

Permalink
Merge pull request #855 from cherylking/java21
Browse files Browse the repository at this point in the history
Java 21 support
  • Loading branch information
cherylking committed Oct 20, 2023
2 parents 8f3178b + 7351a9d commit 5650daa
Show file tree
Hide file tree
Showing 35 changed files with 126 additions and 93 deletions.
28 changes: 13 additions & 15 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
matrix:
# test against latest update of each major Java version, as well as specific updates of LTS versions:
RUNTIME: [ol, wlp]
RUNTIME_VERSION: [23.0.0.6, 23.0.0.9]
java: [17, 11, 8]
RUNTIME_VERSION: [23.0.0.10]
java: [21, 17, 11, 8]
exclude:
- java: 8
RUNTIME_VERSION: 23.0.0.6
- java: 17
RUNTIME_VERSION: 23.0.0.6
RUNTIME: wlp
- java: 11
RUNTIME: ol
name: ${{ matrix.RUNTIME }} ${{ matrix.RUNTIME_VERSION }}, Java ${{ matrix.java }}, Linux
steps:
# Checkout repos
Expand Down Expand Up @@ -65,8 +65,8 @@ jobs:
# Install dependencies
- name: Install ci.ant and ci.common
run: |
mvn -V clean install -f ci.ant --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false
mvn -V clean install -f ci.common --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false
mvn -V clean install -f ci.ant --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -DskipTests
mvn -V clean install -f ci.common --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -DskipTests
# Run tests
- name: Run tests with Gradle on Ubuntu
run:
Expand Down Expand Up @@ -95,15 +95,13 @@ jobs:
matrix:
# test against latest update of each major Java version, as well as specific updates of LTS versions:
RUNTIME: [ol, wlp]
RUNTIME_VERSION: [23.0.0.6, 23.0.0.9]
java: [17, 11, 8]
RUNTIME_VERSION: [23.0.0.10]
java: [21, 17, 11, 8]
exclude:
- java: 8
RUNTIME_VERSION: 23.0.0.6
- java: 8
RUNTIME: ol
- java: 11
RUNTIME: wlp
- java: 17
RUNTIME_VERSION: 23.0.0.6
name: ${{ matrix.RUNTIME }} ${{ matrix.RUNTIME_VERSION }}, Java ${{ matrix.java }}, Windows
steps:
# Checkout repos
Expand Down Expand Up @@ -140,11 +138,11 @@ jobs:
# Install ci.ant
- name: Install ci.ant
working-directory: C:/ci.ant
run: mvn -V clean install --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false
run: mvn -V clean install --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -DskipTests
# Install ci.common
- name: Install ci.common
working-directory: C:/ci.common
run: mvn -V clean install --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false
run: mvn -V clean install --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -DskipTests
# Run tests
- name: Run tests with Gradle on Windows
working-directory: C:/ci.gradle
Expand Down
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ configurations {
}

compileJava {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileTestJava {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileGroovy {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileTestGroovy {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

def libertyAntVersion = "1.9.13"
def libertyCommonVersion = "1.8.29"
def libertyAntVersion = "1.9.14-SNAPSHOT"
def libertyCommonVersion = "1.8.30-SNAPSHOT"

dependencies {
implementation gradleApi()
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
25 changes: 18 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand All @@ -205,6 +210,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.openliberty.tools.gradle.tasks


import io.openliberty.tools.common.plugins.util.AbstractContainerSupportUtil
import io.openliberty.tools.common.plugins.util.InstallFeatureUtil
import io.openliberty.tools.common.plugins.util.InstallFeatureUtil.ProductProperties
import io.openliberty.tools.common.plugins.util.PluginExecutionException
Expand Down Expand Up @@ -109,6 +110,7 @@ public class AbstractFeatureTask extends AbstractServerTask {
private class InstallFeatureTaskUtil extends InstallFeatureUtil {
public InstallFeatureTaskUtil(File installDir, File buildDir, String from, String to, Set<String> pluginListedEsas, List<ProductProperties> propertiesList, String openLibertyVerion, String containerName, List<String> additionalJsons) throws PluginScenarioException, PluginExecutionException {
super(installDir, buildDir, from, to, pluginListedEsas, propertiesList, openLibertyVerion, containerName, additionalJsons)
setContainerEngine(this);
}

@Override
Expand Down Expand Up @@ -291,5 +293,16 @@ public class AbstractFeatureTask extends AbstractServerTask {
return util
}

protected void setContainerEngine(AbstractContainerSupportUtil util) throws PluginExecutionException {
String LIBERTY_DEV_PODMAN = "liberty.dev.podman";
Map<String, Object> projectProperties = project.getProperties();
if (!projectProperties.isEmpty() && projectProperties.containsKey(LIBERTY_DEV_PODMAN)) {
Object isPodman = projectProperties.get(LIBERTY_DEV_PODMAN);
if (isPodman != null) {
util.setIsDocker(!(Boolean.parseBoolean(isPodman.toString())));
logger.debug("liberty.dev.podman was set to: " + (Boolean.parseBoolean(isPodman.toString())));
}
}
}

}
13 changes: 10 additions & 3 deletions src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.openliberty.tools.gradle.tasks

import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.internal.file.DefaultFilePropertyFactory
Expand Down Expand Up @@ -360,7 +361,7 @@ class DevTask extends AbstractFeatureTask {
boolean libertyDebug, boolean pollingTest, boolean container, File containerfile, File containerBuildContext,
String containerRunOpts, int containerBuildTimeout, boolean skipDefaultPorts, boolean keepTempContainerfile,
String mavenCacheLocation, String packagingType, File buildFile, boolean generateFeatures
) throws IOException {
) throws IOException, PluginExecutionException {
super(buildDir, serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, projectDirectory, /* multi module project directory */ projectDirectory,
resourceDirs, hotTests, skipTests, false /* skipUTs */, false /* skipITs */, skipInstallFeature, artifactId, serverStartTimeout,
verifyAppStartTimeout, appUpdateTimeout, ((long) (compileWait * 1000L)), libertyDebug,
Expand All @@ -378,6 +379,8 @@ class DevTask extends AbstractFeatureTask {
project.configurations.getByName('libertyFeature').dependencies.each {
dep -> this.existingLibertyFeatureDependencies.add(dep.name)
}

setContainerEngine(this)
}

@Override
Expand Down Expand Up @@ -1171,14 +1174,18 @@ class DevTask extends AbstractFeatureTask {
File buildFile = project.getBuildFile();

// Instantiate util before any child gradle tasks launched so it can help find available port if needed
this.util = new DevTaskUtil(project.buildDir, serverInstallDir, getUserDir(project, serverInstallDir),
try {
this.util = new DevTaskUtil(project.buildDir, serverInstallDir, getUserDir(project, serverInstallDir),
serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, project.getRootDir(),
resourceDirs, hotTests.booleanValue(), skipTests.booleanValue(), skipInstallFeature.booleanValue(), artifactId, serverStartTimeout.intValue(),
verifyAppStartTimeout.intValue(), verifyAppStartTimeout.intValue(), compileWait.doubleValue(),
libertyDebug.booleanValue(), pollingTest.booleanValue(), container.booleanValue(), containerfile, containerBuildContext, containerRunOpts,
containerBuildTimeout, skipDefaultPorts.booleanValue(), keepTempContainerfile.booleanValue(), localMavenRepoForFeatureUtility,
getPackagingType(), buildFile, generateFeatures.booleanValue()
);
);
} catch (IOException | PluginExecutionException e) {
throw new GradleException("Error initializing dev mode.", e)
}

ProjectConnection gradleConnection = initGradleProjectConnection();
BuildLauncher gradleBuildLauncher = gradleConnection.newBuild();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class BaseDevTest extends AbstractIntegrationTest {
gradlew = new File("gradlew")
}

StringBuilder command = new StringBuilder(gradlew.getAbsolutePath() + " libertyDev");
StringBuilder command = new StringBuilder(gradlew.getAbsolutePath() + " --warning-mode none libertyDev");
if (params != null) {
command.append(" " + params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class BaseGenerateFeaturesTest extends AbstractIntegrationTest {
gradlew = new File("gradlew");
}

StringBuilder command = new StringBuilder(gradlew.getAbsolutePath() + " " + processCommand);
StringBuilder command = new StringBuilder(gradlew.getAbsolutePath() + " --warning-mode none " + processCommand);

System.out.println("Running command: " + command.toString());
ProcessBuilder builder = buildProcess(command.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class TestEclipseFacetsWar extends AbstractIntegrationTest{
if (attributes.getAt('facet').equals('jst.web') && attributes.getAt('version').equals('3.0')) {
hasJstWebFacet = true
}
if (attributes.getAt('facet').equals('jst.java') && attributes.getAt('version').equals('1.7')) {
if (attributes.getAt('facet').equals('jst.java') && attributes.getAt('version').equals('1.8')) {
hasJavaFacet = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ buildscript {
apply plugin: 'war'
apply plugin: 'liberty'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava.options.encoding = 'UTF-8'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ buildscript {
apply plugin: 'war'
apply plugin: 'liberty'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava.options.encoding = 'UTF-8'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ buildscript {
apply plugin: 'war'
apply plugin: 'liberty'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava.options.encoding = 'UTF-8'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ buildscript {
apply plugin: 'war'
apply plugin: 'liberty'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava.options.encoding = 'UTF-8'

Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/sample.servlet/TestStripVersion.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ buildscript {
apply plugin: 'war'
apply plugin: 'liberty'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava.options.encoding = 'UTF-8'

Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/sample.servlet/testAppConfig.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ buildscript {
apply plugin: 'war'
apply plugin: 'liberty'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava.options.encoding = 'UTF-8'

Expand Down
Loading

0 comments on commit 5650daa

Please sign in to comment.