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

Upgrade to JDK 17 #2

Merged
merged 3 commits into from
Aug 14, 2023
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
30 changes: 15 additions & 15 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name: Template CI/CD
- master

env:
JDK_VERSION: 11
JDK_VERSION: 17
JDK_DISTRIBUTION: 'adopt'
USER: QubitPi
EMAIL: jack20220723@gmail.com
Expand All @@ -39,18 +39,18 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actionshub/markdownlint@main
# markdown-link-check:
# name: Markdown Link Check
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: gaurav-nelson/github-action-markdown-link-check@v1
# with:
# use-verbose-mode: "yes"
markdown-link-check:
name: Markdown Link Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-verbose-mode: "yes"

tests:
name: Unit & Integration Tests
needs: [yaml-lint, markdown-lint]
needs: [yaml-lint, markdown-lint, markdown-link-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -77,10 +77,6 @@ jobs:
restore-keys: ${{ runner.os }}-m2
- name: Run unit & integration tests
run: mvn -B clean verify
- name: Set up JDK 17 for Sonar Scan
uses: actions/setup-java@v1
with:
java-version: 17
- name: Sonar Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -128,6 +124,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK ${{ env.JDK_VERSION }}
uses: actions/setup-java@v3
with:
java-version: ${{ env.JDK_VERSION }}
distribution: ${{ env.JDK_DISTRIBUTION }}
- name: Build App WAR file so that Docker can pickup during image build
run: mvn clean package
- name: Set up QEMU
Expand Down Expand Up @@ -155,7 +156,6 @@ jobs:

hashicorp:
name: Publish Jersey WS AMI Image and Deploy it to EC2 through HashiCorp
if: ${{ github.event.repository.name != 'astraios' }}
needs: tests
runs-on: ubuntu-latest
defaults:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# 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.
FROM jetty:11.0.14-jdk11
FROM jetty:jdk17

LABEL maintainer="Jiaqi (Jack) Liu"
LABEL maintainer-email="jack20220723@gmail.com"
Expand Down
14 changes: 11 additions & 3 deletions docs/docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,16 @@ Running Webservice in Standalone Jetty (Production)

### Download Jetty

At [download page](https://www.eclipse.org/jetty/download.php), pick up a `.tgz` distribution. Since this template
requires Java 11+, we will use "11.0.15" release as an example:
At [download page](https://www.eclipse.org/jetty/download.php), pick up a `.tgz` distribution. **It is very important
to pick up Jetty server version that matches JDK version**. For JDK **17**, it's been tested that Jetty _11.0.15_ works

:::note

During testing, the embedded Jetty version is also 11.0.15

:::

Hence, we will use "11.0.15" release as an example:

![Error loading download-jetty.png](./img/download-jetty.png)

Expand Down Expand Up @@ -134,7 +142,7 @@ Lastly, drop the [WAR file](#packaging) into **/path/to/jetty-base/webapps** dir
mv /path/to/war-file /path/to/jetty-base/webapps/ROOT.war
```

### Running Jersey Template Webservice
### Running Astraios

```bash
java -jar $JETTY_HOME/start.jar
Expand Down
Binary file modified docs/docs/img/download-jetty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 28 additions & 12 deletions docs/docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,37 @@ Prepare for Local Development

```bash
brew update
brew install java11
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
brew install maven
brew install openjdk@17
```

At the end of the last command prompt, something like the below will show up:

```bash
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn ...openjdk@17/libexec/openjdk.jdk .../JavaVirtualMachines/openjdk-17.jdk

openjdk@17 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have openjdk@17 first in your PATH, run:
echo 'export PATH=".../openjdk@17/bin:$PATH"' >> .../.bash_profile

For compilers to find openjdk@17 you may need to set:
export CPPFLAGS="-I.../openjdk@17/include"
```

Make sure to execute the `sudo ln -sfn`, `echo 'export PATH=...`, and the `export CPPFLAGS=` commands above

:::tip

Maven uses a separate JDK version, which can be seen via `mvn -v`. If it's not JDK 11, we should have Maven point
to our JDK 11 using [JAVA_HOME](https://stackoverflow.com/a/2503679):
Maven uses a separate JDK version, which can be seen via `mvn -v`. If it's not JDK 17, we should have Maven point
to our JDK 17 using [JAVA_HOME](https://stackoverflow.com/a/2503679):

```bash
$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home

$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
```

:::
Expand All @@ -33,9 +49,9 @@ If we see something similar after typing the command with the version flag below

```bash
$ java --version
openjdk 11.0.10 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9)
OpenJDK 64-Bit Server VM (build 11.0.10+9, mixed mode)
openjdk 17.0.10 2021-01-19
OpenJDK Runtime Environment (build 17.0.10+9)
OpenJDK 64-Bit Server VM (build 17.0.10+9, mixed mode)
```

### Installing Docker Engine
Expand Down Expand Up @@ -64,9 +80,9 @@ Modifying Templates

- Update [endpoint package] accordingly

[Docker-based integration tests]: https://github.com/paion-data/astraios/blob/master/src/test/groovy/com/paiondata/ws/jersey/template/DataServletITSpec.groovy
[Docker-based integration tests]: https://github.com/paion-data/astraios/blob/master/src/test/groovy/com/paiondata/astraios/DataServletITSpec.groovy

[endpoint package]: https://github.com/paion-data/astraios/blob/master/src/main/java/com/paiondata/ws/jersey/template/application/ResourceConfig.java
[endpoint package]: https://github.com/paion-data/astraios/blob/master/src/main/java/com/paiondata/astraios/application/ResourceConfig.java

[astraios]: https://github.com/paion-data/astraios
[astraios Dockerfile]: https://github.com/paion-data/astraios/blob/master/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion hashicorp/instances/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ resource "aws_instance" "astraios" {
tags = {
Name = "ES2 Instance Name"
}
security_groups = ["Security Group Name"]
security_groups = ["Paion Data Astraios"]

user_data = <<-EOF
#!/bin/bash
Expand Down
16 changes: 8 additions & 8 deletions hashicorp/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ set -x
sudo apt update && sudo apt upgrade -y
sudo apt install software-properties-common -y

# Install JDK 11 - https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-20-04#installing-the-default-jre-jdk
# Install JDK 17 - https://www.rosehosting.com/blog/how-to-install-java-17-lts-on-ubuntu-20-04/
sudo apt update
sudo apt install default-jre -y
sudo apt install default-jdk -y
sudo apt install openjdk-17-jdk openjdk-17-jre

# Install Maven
sudo apt install maven -y
Expand All @@ -32,11 +31,12 @@ cd REPO
mvn clean package -Dmaven.test.skip
cd ../

# Install and configure Jetty (version 11) container
wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/11.0.15/jetty-home-11.0.15.tar.gz
tar -xzvf jetty-home-11.0.15.tar.gz
rm jetty-home-11.0.15.tar.gz
export JETTY_HOME=/home/ubuntu/jetty-home-11.0.15
# Install and configure Jetty (version 17) container
JETTY_VERSION=11.0.15
wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/$JETTY_VERSION/jetty-home-$JETTY_VERSION.tar.gz
tar -xzvf jetty-home-$JETTY_VERSION.tar.gz
rm jetty-home-$JETTY_VERSION.tar.gz
export JETTY_HOME=/home/ubuntu/jetty-home-$JETTY_VERSION
mkdir jetty-base
cd jetty-base
java -jar $JETTY_HOME/start.jar --add-module=annotations,server,http,deploy
Expand Down
50 changes: 22 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>

<version.validation.api>3.0.1</version.validation.api>
<version.jcip.annotations>1.0</version.jcip.annotations>
Expand All @@ -45,7 +45,7 @@
<version.servlet>6.0.0</version.servlet>
<version.jersey>3.1.1</version.jersey>
<version.groovy>4.0.6</version.groovy>
<version.jetty>11.0.14</version.jetty>
<version.jetty>11.0.15</version.jetty>

<version.maven.war.plugin>3.2.2</version.maven.war.plugin>
<version.maven.javadoc.plugin>3.5.0</version.maven.javadoc.plugin>
Expand Down Expand Up @@ -82,6 +82,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-bom</artifactId>
<version>${version.jetty}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -193,6 +200,11 @@
<artifactId>logback-classic</artifactId>
<version>${version.logback}</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-logback</artifactId>
<version>6.25.2</version>
</dependency>

<!-- Testing -->
<dependency>
Expand Down Expand Up @@ -221,13 +233,16 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${version.jetty}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${version.jetty}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -259,7 +274,7 @@
</resources>

<plugins>
<!-- Use Java 11 -->
<!-- Use Java 17 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -337,27 +352,6 @@
</executions>
</plugin>

<!-- Groovy checkstyle -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>codenarc-maven-plugin</artifactId>
<version>0.22-1</version>
<configuration>
<sourceDirectory>${project.basedir}</sourceDirectory>
<maxPriority1Violations>0</maxPriority1Violations>
<maxPriority2Violations>0</maxPriority2Violations>
<maxPriority3Violations>0</maxPriority3Violations>
</configuration>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>codenarc</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Unite Test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -425,7 +419,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.8</version>
</plugin>
</plugins>
</build>
Expand Down
Loading