Skip to content

Upgrade to Jakarta 10 #174

Upgrade to Jakarta 10

Upgrade to Jakarta 10 #174

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: NetLicensing Client - CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: [self-hosted]
container: maven:3-amazoncorretto-17
env:
# This is needed, as java doesn't respect the environment variable $HOME, but gets the
# user home by other means from the system. The default user in the above container is
# 'root' with the home at '/root', while GitHub runner overrides $HOME to the mounted
# '/github/home'. As a result, maven uses the ~/.m2 at a different location than assumed
# by the standard GitHub actions like 'actions/setup-java', causing caching of the maven
# local repository not working.
# TODO(2K): This can be better solved by preparing a custom image for the container.
MAVEN_OPTS: -Duser.home=/github/home
strategy:
fail-fast: false
matrix:
java-version: [11, 17]
include:
- java-version: 11
jdk-suffix: ""
- java-version: 17
jdk-suffix: -jdk17
steps:
- uses: actions/checkout@v3
- name: Prepare maven settings.xml
run: |
mkdir -p ~/.m2
cat << EOF >~/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>nlic-snapshots</id>
<username>${{ secrets.SNAPSHOTS_USER }}</username>
<password>${{ secrets.SNAPSHOTS_PASS }}</password>
</server>
</servers>
</settings>
EOF
- name: Calculate branch suffix
run: |
if [ "$GITHUB_REF_NAME" = "master" ]
then
# No suffix when running against "master" branch
BRANCH_SUFFIX=${{ matrix.jdk-suffix }}
else
# When running from pull request, use "-pr-<N>" suffix, where <N> is a PR number
BRANCH_SUFFIX=${{ matrix.jdk-suffix }}-pr-${GITHUB_REF_NAME//\/merge/}
fi
echo "Branch suffix: '$BRANCH_SUFFIX'"
echo "BRANCH_SUFFIX=$BRANCH_SUFFIX" >> "$GITHUB_ENV"
- name: Build with Maven
run: |
mvn -B clean deploy \
-Drepo.snapshots.url=${{ secrets.SNAPSHOTS_URL }} \
-Dsha1=$BRANCH_SUFFIX \
-Djava.version=${{ matrix.java-version }}
- name: Run Demo App
run: |
ls -la NetLicensingClient-demo/target/
java -jar NetLicensingClient-demo/target/netlicensing-client-demo.jar -r CallEveryAPIMethod