Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to change OpenJDK versions from 11 to 8 #42

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,37 @@ prod-deploy-requires: &prod-deploy-requires
ui-tests-system-images;android-29;default;x86,
ui-tests-system-images;android-29;google_apis;x86_64,
test-emulator-commands,
test-start-emulator-and-run-tests
test-start-emulator-and-run-tests,
test-java-version
]

jobs:
test-java-version:
parameters:
executor:
type: executor
description: |
Which Android image/executor to use. Choose between 'android-docker'
and 'android-machine'.
java-version:
type: integer
description: |
Version to use in the change-java-version job
executor: <<parameters.executor>>
steps:
- checkout
- android/change-java-version:
java-version: << parameters.java-version >>
- run:
command: |
JAVA_VER="$( java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 )"
JAVAC_VER="$( javac -version 2>&1 | head -1 | cut -f 2- -d ' ' | sed '/^1\./s///' | cut -d'.' -f1 )"
if [ "$JAVA_VER" -ne <<parameters.java-version>> ] || [ "$JAVAC_VER" -ne <<parameters.java-version>> ]; then
echo "Job failed because either the java version or javac version was not changed."
exit 1
EricRibeiro marked this conversation as resolved.
Show resolved Hide resolved
fi
name: check for correctness

test-ndk-install:
parameters:
executor:
Expand Down Expand Up @@ -126,6 +153,17 @@ jobs:
workflows:
test-deploy:
jobs:
- test-java-version:
name: "Test OpenJDK version change"
executor:
name: android/android-docker
tag: "2021.10.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would still be nice to have updated but I won't hold back this PR for it.

matrix:
parameters:
java-version:
- 8
- 11
- 13
- test-ndk-install:
name: "Test NDK Install on Android Docker"
matrix:
Expand Down
35 changes: 35 additions & 0 deletions src/commands/change-java-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
description: |
Change default java version from OpenJDK v11.
parameters:
java-version:
type: integer
default: 8
description: |
The version of OpenJDK to change to
steps:
- run:
command: |
CURRENT_JAVA_VER="$( java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 )"
CURRENT_JAVAC_VER="$( javac -version 2>&1 | head -1 | cut -f 2- -d ' ' | sed '/^1\./s///' | cut -d'.' -f1 )"
echo "Current Java Version: $CURRENT_JAVA_VER"
echo "Current Java Compiler Version : $CURRENT_JAVAC_VER"
if [ "$CURRENT_JAVA_VER" -ne <<parameters.java-version>> ]; then
if [ <<parameters.java-version>> -eq 8 ] || [ <<parameters.java-version>> -eq 11 ]; then
if [ <<parameters.java-version>> -eq 8 ]; then
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
else
sudo update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
fi
sudo update-alternatives --set javac /usr/lib/jvm/java-<<parameters.java-version>>-openjdk-amd64/bin/javac
else
sudo apt install openjdk-<<parameters.java-version>>-jdk
fi
echo "export JAVA_HOME=/usr/lib/jvm/java-<<parameters.java-version>>-openjdk-amd64" >>~/.bashrc
echo "export PATH=$JAVA_HOME/bin:$PATH" >>~/.bashrc
fi
NEW_JAVA_VER="$( java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 )"
NEW_JAVAC_VER="$( javac -version 2>&1 | head -1 | cut -f 2- -d ' ' | sed '/^1\./s///' | cut -d'.' -f1 )"
echo "New Java Version : $NEW_JAVA_VER"
echo "New Java Compiler Version : $NEW_JAVAC_VER"
name: change OpenJDK version