forked from akhikhl/gretty
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from mr-serjey/master
Make Gretty aware of Gradle Java Toolchain (v4.x)
- Loading branch information
Showing
30 changed files
with
674 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ build | |
*.iws | ||
bin/ | ||
.DS_Store | ||
.docker-gradle/ |
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,45 @@ | ||
FROM ubuntu as base | ||
RUN apt-get update | ||
|
||
FROM base as base-utils | ||
ENV _BASH_UTILS_DIR=/root/.bashrc.d | ||
COPY <<-EOF $_BASH_UTILS_DIR/0_on_bash_ready.bash | ||
shopt -s expand_aliases | ||
export _on_bash_ready_i=\$(find $_BASH_UTILS_DIR -type f | wc -l) | ||
function on_bash_ready (){ | ||
((_on_bash_ready_i++)) | ||
local file="$_BASH_UTILS_DIR/\${_on_bash_ready_i}.bash" | ||
echo "\$@" >> \$file && \ | ||
sed -i 's/\r\$//' \$file && \ | ||
source \$file | ||
} | ||
EOF | ||
RUN sed -i 's/\r$//' $_BASH_UTILS_DIR/0_on_bash_ready.bash | ||
RUN echo "while read -r FILE; do source \$FILE; done < <( find $_BASH_UTILS_DIR -name '*.bash' | sort)" >> ~/.profile | ||
SHELL ["/bin/bash", "-l", "-c"] | ||
|
||
|
||
FROM base-utils as firefox | ||
RUN apt-get install -y wget | ||
RUN install -d -m 0755 /etc/apt/keyrings | ||
RUN wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null | ||
RUN echo 'deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main' | tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null | ||
RUN apt-get update && apt-get install -y firefox-devedition-l10n-eu | ||
RUN ln -s /usr/bin/firefox-devedition /usr/bin/firefox | ||
|
||
|
||
FROM firefox as firefox-sdkman | ||
RUN apt-get install -y curl unzip zip findutils | ||
RUN curl -s "https://get.sdkman.io?rcupdate=false" | bash | ||
RUN on_bash_ready source /root/.sdkman/bin/sdkman-init.sh | ||
|
||
FROM firefox-sdkman as firefox-jdk | ||
ARG JAVA_VERSIONS="8.0.412-amzn" | ||
ENV JAVA_VERSIONS="$JAVA_VERSIONS" | ||
RUN on_bash_ready 'alias install_jdk="sdk install java $1"' | ||
RUN for version in ${JAVA_VERSIONS//,/ } ; do install_jdk $version ; done | ||
|
||
|
||
FROM firefox-jdk as firefox-jdk-gradle | ||
ARG GRADLE_VERSION="6.9.4" | ||
RUN sdk install gradle $GRADLE_VERSION |
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,61 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
function build_docker_gradlew_image(){ | ||
docker build -t "docker_gradlew" . \ | ||
--build-arg JAVA_VERSIONS="$_javas" \ | ||
--build-arg GRADLE_VERSION="$_gradle" | ||
} | ||
|
||
function run_docker(){ | ||
build_docker_gradlew_image "$*" | ||
|
||
local working_dir="-w //project/${_working_dir}" | ||
|
||
local project_volume="-v //$(realpath .)://project" | ||
|
||
local gradle_home_volume="" | ||
if [ "$_gradle_home" ]; then | ||
gradle_home_volume="-v //$(realpath $_gradle_home)://root/.gradle" | ||
fi | ||
|
||
local params="$DOCKER_ARGS $project_volume $working_dir $gradle_home_volume" | ||
|
||
|
||
echo "RUNNING:" docker run --rm -it $params docker_gradlew "$@" | ||
docker run --rm -it $params docker_gradlew "$@" | ||
} | ||
|
||
function run_docker_gradle() { | ||
run_docker bash -lc "gradle $*" | ||
} | ||
|
||
|
||
JDK["8"]="8.0.412-amzn" | ||
JDK["11"]="11.0.23-amzn" | ||
JDK["17"]="17.0.11-amzn" | ||
JDK["21"]="21.0.3-amzn" | ||
|
||
GRADLE["6"]="6.9.4" | ||
GRADLE["7"]="7.6.4" | ||
GRADLE["8"]="8.6" | ||
|
||
POSITIONAL_ARGS=() | ||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
-j|--java) export _javas+=",${JDK[$2]:=$2}" && shift 2 ;; | ||
-g|--gradle) export _gradle=${GRADLE[$2]:=$2} && shift 2 ;; | ||
-h|--gradle-home) export _gradle_home=$2 && shift 2 ;; | ||
-w|--working-dir) export _working_dir=$2 && shift 2 ;; | ||
-b|--bash) export _bash="Yes" && shift 1 ;; | ||
|
||
*) POSITIONAL_ARGS+=("$1") && shift ;; | ||
esac | ||
done | ||
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters | ||
|
||
if [ "$_bash" ]; then | ||
run_docker bash -l | ||
else | ||
run_docker_gradle "${@}" | ||
fi |
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,71 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
export common_gradle_args="--console=plain --no-daemon -Porg.gradle.java.installations.auto-download=false -PgeckoDriverPlatform=linux64" | ||
|
||
#ci.yml plugin build step | ||
./docker_gradlew.sh \ | ||
--java 11 \ | ||
--gradle 7 \ | ||
--gradle-home .docker-gradle \ | ||
$common_gradle_args \ | ||
publishToPrivateRepo | ||
|
||
#ci.yml matrix case #1 | ||
./docker_gradlew.sh \ | ||
--java 11 \ | ||
--gradle 7 \ | ||
--gradle-home .docker-gradle \ | ||
--working-dir integrationTests \ | ||
$common_gradle_args \ | ||
testAll | ||
|
||
#ci.yml matrix case #2 | ||
./docker_gradlew.sh \ | ||
--java 17 \ | ||
--gradle 7 \ | ||
--gradle-home .docker-gradle \ | ||
--working-dir integrationTests \ | ||
$common_gradle_args \ | ||
testAll | ||
|
||
#ci.yml matrix case #3 | ||
./docker_gradlew.sh \ | ||
--java 17 \ | ||
--gradle 8 \ | ||
--gradle-home .docker-gradle \ | ||
--working-dir integrationTests \ | ||
$common_gradle_args \ | ||
testAll | ||
|
||
# a set of tests with java toolchain: | ||
|
||
#ci.yml matrix case #1 + toolchain java v17 | ||
./docker_gradlew.sh \ | ||
--java 17 --java 11 \ | ||
--gradle 7 \ | ||
--gradle-home .docker-gradle \ | ||
--working-dir integrationTests \ | ||
$common_gradle_args \ | ||
-PtoolchainJavaVersion=17 \ | ||
testAllJavaToolchain | ||
|
||
#ci.yml matrix case #2 + toolchain java v21 | ||
./docker_gradlew.sh \ | ||
--java 21 --java 17 \ | ||
--gradle 7 \ | ||
--gradle-home .docker-gradle \ | ||
--working-dir integrationTests \ | ||
$common_gradle_args \ | ||
-PtoolchainJavaVersion=21 \ | ||
testAllJavaToolchain | ||
|
||
#ci.yml matrix case #3 + toolchain java v21 | ||
./docker_gradlew.sh \ | ||
--java 21 --java 17 \ | ||
--gradle 8 \ | ||
--gradle-home .docker-gradle \ | ||
--working-dir integrationTests \ | ||
$common_gradle_args \ | ||
-PtoolchainJavaVersion=21 \ | ||
testAllJavaToolchain |
45 changes: 45 additions & 0 deletions
45
...tionTest/src/main/groovy/org/akhikhl/gretty/internal/integrationTests/AnyJavaVersion.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,45 @@ | ||
package org.akhikhl.gretty.internal.integrationTests; | ||
|
||
import java.util.Objects; | ||
|
||
public class AnyJavaVersion implements Comparable<AnyJavaVersion> { | ||
private int majorVersion; | ||
|
||
private AnyJavaVersion(int majorVersion) { | ||
this.majorVersion = majorVersion; | ||
} | ||
|
||
public int getMajorVersion() { | ||
return majorVersion; | ||
} | ||
|
||
public boolean isJava9Compatible() { | ||
return majorVersion >= 9; | ||
} | ||
|
||
public boolean isJava10Compatible() { | ||
return majorVersion >= 10; | ||
} | ||
|
||
@Override | ||
public int compareTo(AnyJavaVersion o) { | ||
return Integer.compare(this.majorVersion, o.majorVersion); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
AnyJavaVersion that = (AnyJavaVersion) o; | ||
return majorVersion == that.majorVersion; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(majorVersion); | ||
} | ||
|
||
public static AnyJavaVersion of(Integer integer) { | ||
return new AnyJavaVersion(Objects.requireNonNull(integer)); | ||
} | ||
} |
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
Oops, something went wrong.