Skip to content

Commit

Permalink
fix: upgrade gradle to 8.11.1 and set java version used to 21. (#9623)
Browse files Browse the repository at this point in the history
* fix: upgrade gradle spring boot and support openjdk versions

* fix: upgrade gradle spring boot and support openjdk versions

* #fix address PR comments, update all plugins to latest version

* copy changes over to examples/jib-sync

* fix: set source and target compability to 21

* set target jdk to 17

* fix: set java version used in the gradle test to 21. Change the image used in skaffold.yaml so that the ccompiled java application runs in java V21 environment instead of V11.

* run only problematic test and add debug logging

* add debug line

* add vebosity flag

* add debugging code

* add debugging code

* more debug lines

* more debug lines

* more debug lines

* more debug lines

* call gradle directly to get debug error

* Run skaffold dev to see output

* Run TestDevAutoSync.

* remove XDG_CONFIG_HOM environment variable

* remove XDG_CONFIG_HOM environment variable

* run skaffold test

* re-enable all tests and sync the two copies of build.gradle

* update jib-gradle example

* add databind dependency which is needed by netty

* Sync changes in integration/examples/jib-gradle to examples/jib-gradle

* remove jib.fromImage specification in build.gradle since the base image is defined in the skaffold.yaml

* fix jib-gradle/skaffold.yaml, set apiVersion to v4beta11

* use setup-java action to set the java version
  • Loading branch information
alphanota authored Jan 7, 2025
1 parent 4a8c428 commit 00a3b42
Show file tree
Hide file tree
Showing 29 changed files with 568 additions and 399 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/integration-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
minikube_version: [1.34.0]
gcloud_sdk_version: [502.0.0]
container_structure_tests_version: [1.19.3]
java: [21]
integration_test_partitions: [0, 1, 2, 3]
steps:

Expand All @@ -37,6 +38,12 @@ jobs:
go-version: 1.23.*
id: go

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}

# Retrieve build locations with `go env`
# <https://markphelps.me/posts/speed-up-your-go-builds-with-actions-cache/>
- id: go-cache-paths
Expand Down Expand Up @@ -129,4 +136,4 @@ jobs:
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
skaffold config set --global collect-metrics false
IT_PARTITION=${{ matrix.integration_test_partitions }} make integration-tests
IT_PARTITION=${{ matrix.integration_test_partitions }} make integration-tests
17 changes: 9 additions & 8 deletions examples/jib-gradle/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
plugins {
id 'groovy'
id 'io.micronaut.application' version '3.6.3'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.google.cloud.tools.jib' version '3.3.1'
id 'io.micronaut.application' version '4.4.4'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.google.cloud.tools.jib' version '3.4.4'
}

// the configuration was mostly generated from micronaut cli.
java {
sourceCompatibility = JavaVersion.toVersion("11")
targetCompatibility = JavaVersion.toVersion("11")
sourceCompatibility = JavaVersion.toVersion("21")
targetCompatibility = JavaVersion.toVersion("21")
}

version '0.1'
Expand All @@ -19,6 +20,8 @@ repositories {

dependencies {
implementation 'io.micronaut:micronaut-http-server-netty'
// This is a depedency of `micronaut-http-server-netty`.
implementation 'io.micronaut:micronaut-jackson-databind'
implementation 'jakarta.annotation:jakarta.annotation-api'
implementation 'io.micronaut:micronaut-inject'
implementation 'io.micronaut:micronaut-runtime'
Expand All @@ -40,6 +43,4 @@ micronaut {
incremental(true)
annotations("example.micronaut.*")
}
}

jib.from.image = 'openjdk:11'
}
2 changes: 1 addition & 1 deletion examples/jib-gradle/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
micronautVersion=3.7.4
micronautVersion=4.6.3
Binary file modified examples/jib-gradle/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion examples/jib-gradle/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
38 changes: 25 additions & 13 deletions examples/jib-gradle/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,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/platforms/jvm/plugins-application/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 +82,12 @@ 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"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +134,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
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=SC2039,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=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# 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
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# 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, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
23 changes: 13 additions & 10 deletions examples/jib-gradle/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand All @@ -26,6 +28,7 @@ if "%OS%"=="Windows_NT" setlocal

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

Expand All @@ -42,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
4 changes: 3 additions & 1 deletion examples/jib-gradle/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
rootProject.name = 'micronaut-jib'
plugins {
id 'io.micronaut.platform.catalog' version '4.4.4'
}
7 changes: 5 additions & 2 deletions examples/jib-gradle/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ kind: Config
build:
artifacts:
- image: skaffold-jib-gradle
jib: {}
jib:
type: gradle
fromImage: gcr.io/distroless/java21-debian12:debug


# optional profile to run the jib build on Google Cloud Build
profiles:
Expand All @@ -13,5 +16,5 @@ profiles:
# gcb doesn't use the gradle wrapper in the application project to build, users need to provide a gradle image
# that can run all tasks defined in build.gradle file as the default one provided by cloudBuilders might be too
# old.
gradleImage: gradle:7.5.1-jdk17-alpine@sha256:6b00b5e05d3d65e7a7b2efd68fdc08242407d83ba0387fa12ee9e8c09a4188d1
gradleImage: gradle:jdk21-corretto@sha256:06346c0949f4ca2e5e2691504b63528bc55a5745627259e93686fdcdcb565a07
}
26 changes: 12 additions & 14 deletions examples/jib-sync/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.0.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.7.RELEASE'
id 'com.google.cloud.tools.jib' version '3.3.1'
id 'org.springframework.boot' version '3.4.1'
id 'io.spring.dependency-management' version '1.1.7'
id 'com.google.cloud.tools.jib' version '3.4.4'
}

repositories {
mavenCentral()
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 21
targetCompatibility = 21

dependencies {
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-actuator"
if (project.hasProperty('sync')) {
implementation "org.springframework.boot:spring-boot-devtools"
}
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-actuator"
if (project.hasProperty('sync')) {
implementation "org.springframework.boot:spring-boot-devtools"
}

testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation "org.springframework.boot:spring-boot-starter-test"
}

jib.from.image = 'openjdk:17'
Binary file modified examples/jib-sync/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion examples/jib-sync/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 00a3b42

Please sign in to comment.