diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 7f57cb0c..c3c473d1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -26,7 +26,7 @@ jobs: java-version: 8 architecture: x64 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp clean package --file pom.xml - name: Upload the build uses: actions/upload-artifact@v3 with: @@ -44,7 +44,7 @@ jobs: java-version: 11 architecture: x64 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp --file pom.xml clean package MacOS-x86_64-Build-JDK17: runs-on: macos-latest @@ -57,7 +57,7 @@ jobs: java-version: 17 architecture: x64 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp --file pom.xml clean package Linux-x86_64-Build-JDK8: runs-on: ubuntu-latest @@ -98,7 +98,7 @@ jobs: restore-keys: | ${{ runner.os }}-pr-${{ env.cache-name }}- ${{ runner.os }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -125,7 +125,7 @@ jobs: run: | export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package - name: Upload the build uses: actions/upload-artifact@v3 @@ -145,7 +145,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -172,7 +172,7 @@ jobs: run: | export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package Linux-Aarch64-Build-JDK17: runs-on: ubuntu-latest @@ -186,7 +186,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -214,7 +214,7 @@ jobs: export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package Linux-ArmV7-Build-JDK8: runs-on: ubuntu-latest @@ -228,7 +228,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -255,7 +255,7 @@ jobs: run: | export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package - name: Upload the build uses: actions/upload-artifact@v3 @@ -275,7 +275,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -302,7 +302,7 @@ jobs: run: | export JAVA_HOME="/jdk" chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package Linux-s390x-Build-JDK8: runs-on: ubuntu-latest @@ -316,7 +316,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -339,7 +339,7 @@ jobs: run: | chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package - name: Upload the build uses: actions/upload-artifact@v3 @@ -359,7 +359,7 @@ jobs: key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.4.0 name: Run commands id: runcmd with: @@ -382,7 +382,160 @@ jobs: run: | chmod +x ./mvnw - ./mvnw -B -ntp clean package + ./mvnw -B --show-version -ntp clean package + + Linux-riscv64-Build-JDK11: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + env: + cache-name: cache-m2-repository-${{ runner.os }}-jdk11-riscv64 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- + + - uses: uraimo/run-on-arch-action@v2.4.0 + name: Run commands + id: runcmd + with: + arch: riscv64 + distro: ubuntu20.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + # Mount the .m2/repository + dockerRunArgs: | + --platform linux/riscv64 + --volume "/home/runner/.m2/repository/:/root/.m2/repository" + # Install dependencies + install: | + apt-get update + apt-get install -q -y curl gnupg2 autoconf automake libtool make tar git cmake build-essential openjdk-11-jdk + + run: | + export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" + chmod +x ./mvnw + ./mvnw -B --show-version -ntp clean package + + - uses: uraimo/run-on-arch-action@v2.4.0 + name: Test on JDK 8 + id: test + with: + arch: aarch64 + distro: ubuntu20.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + # Mount the .m2/repository + dockerRunArgs: | + --platform linux/aarch64 + --volume "/home/runner/.m2/repository/:/root/.m2/repository" + + # Install dependencies + install: | + apt-get update + apt-get install -q -y curl gnupg2 autoconf automake libtool make tar git cmake build-essential openjdk-8-jdk + + run: | + export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" + chmod +x ./mvnw + # Build native-linux-aarch64 only + ./mvnw -B --show-version -ntp clean package -pl :native-linux-aarch64 -DskipTests + # Test with JDK 8 + ./mvnw -B --show-version -ntp surefire:test + + # RISC-V doesn't upload the JDK 8 build because JDK 8 doesn't exist on RISC-V. Instead, we upload + # the JDK 11 build. It should work on JDK 8 as well, as we are testing it on all other platforms. + - name: Upload the build + uses: actions/upload-artifact@v3 + with: + name: Linux-riscv64-Build-JDK11 + path: /home/runner/work/Brotli4j/ + + Linux-riscv64-Build-JDK17: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + env: + cache-name: cache-m2-repository-${{ runner.os }}-jdk17-riscv64 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- + - uses: uraimo/run-on-arch-action@v2.4.0 + name: Run commands + id: runcmd + with: + arch: riscv64 + distro: ubuntu20.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + # Mount the .m2/repository + dockerRunArgs: | + --platform linux/riscv64 + --volume "/home/runner/.m2/repository/:/root/.m2/repository" + # Install dependencies + install: | + apt-get update + apt-get install -q -y curl gnupg2 autoconf automake libtool make tar git cmake build-essential openjdk-17-jdk + + run: | + export MAVEN_OPTS="-Djdk.lang.Process.launchMechanism=vfork" + chmod +x ./mvnw + ./mvnw -B --show-version -ntp clean package + + Linux-riscv64-Build-JDK21: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + env: + cache-name: cache-m2-repository-${{ runner.os }}-jdk21-riscv64 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-pr-${{ matrix.arch }}-pr-${{ env.cache-name }}-pr- + - uses: uraimo/run-on-arch-action@v2.4.0 + name: Run commands + id: runcmd + with: + arch: riscv64 + distro: ubuntu22.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + # Mount the .m2/repository + dockerRunArgs: | + --platform linux/riscv64 + --volume "/home/runner/.m2/repository/:/root/.m2/repository" + + # Install dependencies + install: | + apt-get update + apt-get install -q -y curl gnupg2 autoconf automake libtool make tar git cmake build-essential + + curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh + jabba install 21-custom=tgz+https://api.adoptium.net/v3/binary/latest/21/ea/linux/riscv64/jdk/hotspot/normal/eclipse?project=jdk -o /jdk + + run: | + export JAVA_HOME="/jdk" + chmod +x ./mvnw + ./mvnw -B --show-version -ntp clean package Windows-x86_64-Build-JDK8: runs-on: windows-latest @@ -397,7 +550,7 @@ jobs: - name: Enable Developer Command Prompt uses: ilammy/msvc-dev-cmd@v1.12.0 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp clean package --file pom.xml - name: Upload the build uses: actions/upload-artifact@v3 with: @@ -418,7 +571,7 @@ jobs: - name: Enable Developer Command Prompt uses: ilammy/msvc-dev-cmd@v1.12.0 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp --file pom.xml clean package Windows-x86_64-Build-JDK17: runs-on: windows-latest @@ -433,4 +586,4 @@ jobs: - name: Enable Developer Command Prompt uses: ilammy/msvc-dev-cmd@v1.12.0 - name: Build with Maven - run: mvn -B -ntp clean package --file pom.xml + run: mvn -B --show-version -ntp --file pom.xml clean package diff --git a/all/pom.xml b/all/pom.xml index e52e122c..ec2d50f7 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -64,6 +64,11 @@ native-linux-s390x ${project.version} + + com.aayushatharva.brotli4j + native-linux-riscv64 + ${project.version} + com.aayushatharva.brotli4j native-osx-aarch64 diff --git a/brotli4j/pom.xml b/brotli4j/pom.xml index 4c18b596..6f95e5af 100644 --- a/brotli4j/pom.xml +++ b/brotli4j/pom.xml @@ -110,6 +110,23 @@ + + linux-riscv64 + + + Linux + riscv64 + + + + + com.aayushatharva.brotli4j + native-linux-riscv64 + ${project.parent.version} + + + + windows-x86_64 diff --git a/brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java b/brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java index 5d21f807..19ba205f 100644 --- a/brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java +++ b/brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java @@ -128,6 +128,8 @@ private static String getPlatform() { return "linux-armv7"; } else if ("s390x".equalsIgnoreCase(archName)) { return "linux-s390x"; + } else if ("riscv64".equalsIgnoreCase(archName)) { + return "linux-riscv64"; } } else if (osName.startsWith("Windows")) { if ("amd64".equalsIgnoreCase(archName)) { diff --git a/docker/docker-compose11.yml b/docker/docker-compose11.yml index 5de3cf1e..bd59fc3b 100644 --- a/docker/docker-compose11.yml +++ b/docker/docker-compose11.yml @@ -18,7 +18,7 @@ services: build: <<: *common - command: /bin/bash -cl "mvn -B -ntp clean package --file pom.xml" + command: /bin/bash -cl "mvn -B --show-version -ntp --file pom.xml clean package" shell: <<: *common diff --git a/docker/docker-compose17.yml b/docker/docker-compose17.yml index fc3e8be9..80aec39f 100644 --- a/docker/docker-compose17.yml +++ b/docker/docker-compose17.yml @@ -18,7 +18,7 @@ services: build: <<: *common - command: /bin/bash -cl "mvn -B -ntp clean package --file pom.xml" + command: /bin/bash -cl "mvn -B --show-version -ntp --file pom.xml clean package" shell: <<: *common diff --git a/natives/linux-riscv64/build.sh b/natives/linux-riscv64/build.sh new file mode 100644 index 00000000..84deba17 --- /dev/null +++ b/natives/linux-riscv64/build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +CURPATH=$(pwd) +TARGET_CLASSES_PATH="target/classes/lib/linux-riscv64" +TARGET_PATH="target" + +exitWithError() { + cd ${CURPATH} + echo "*** An error occurred. Please check log messages. ***" + exit $1 +} + +mkdir -p "$TARGET_CLASSES_PATH" + +cd "$TARGET_PATH" +cmake ../../../ || exitWithError $? +make || exitWithError $? +rm -f "$CURPATH/${TARGET_CLASSES_PATH}/libbrotli.so" +cp "./libbrotli.so" "$CURPATH/${TARGET_CLASSES_PATH}" || exitWithError $? + +cd "${CURPATH}" diff --git a/natives/linux-riscv64/pom.xml b/natives/linux-riscv64/pom.xml new file mode 100644 index 00000000..e94a9771 --- /dev/null +++ b/natives/linux-riscv64/pom.xml @@ -0,0 +1,120 @@ + + + + + natives + com.aayushatharva.brotli4j + 1.12.0 + + 4.0.0 + + native-linux-riscv64 + jar + + + com.aayushatharva.brotli4j.linux.riscv64 + + + + + + org.moditect + moditect-maven-plugin + 1.0.0.RC2 + + + add-module-infos + package + + add-module-info + + + 9 + + + module ${javaModuleName} { + requires com.aayushatharva.brotli4j.service; + exports ${javaModuleName} to com.aayushatharva.brotli4j; + provides com.aayushatharva.brotli4j.service.BrotliNativeProvider with + ${javaModuleName}.NativeLoader; + } + + + + --multi-release + 9 + + + + + + + + + + + linux-riscv64 + + + Linux + riscv64 + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + + build-native + process-classes + + exec + + + /bin/bash + + build.sh + + ${project.basedir} + + + + + + + + + + release + + + + resources + + + + + + + diff --git a/natives/linux-riscv64/src/main/java/com/aayushatharva/brotli4j/linux/riscv64/NativeLoader.java b/natives/linux-riscv64/src/main/java/com/aayushatharva/brotli4j/linux/riscv64/NativeLoader.java new file mode 100644 index 00000000..5ca26f97 --- /dev/null +++ b/natives/linux-riscv64/src/main/java/com/aayushatharva/brotli4j/linux/riscv64/NativeLoader.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2020-2023, Aayush Atharva + * + * Brotli4j licenses this file to you under the + * Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ +package com.aayushatharva.brotli4j.linux.riscv64; + +import com.aayushatharva.brotli4j.service.BrotliNativeProvider; + +/** + * Service class to access the native lib in a JPMS context + */ +public class NativeLoader implements BrotliNativeProvider { + + @Override + public String platformName() { + return "linux-riscv64"; + } +} diff --git a/natives/pom.xml b/natives/pom.xml index 0238b9e2..5c8d8076 100644 --- a/natives/pom.xml +++ b/natives/pom.xml @@ -32,6 +32,7 @@ linux-aarch64 linux-armv7 linux-s390x + linux-riscv64 windows-x86_64 osx-x86_64 osx-aarch64 @@ -99,6 +100,19 @@ + + linux-riscv64 + + + Linux + riscv64 + + + + linux-riscv64 + + + windows-x86_64 @@ -145,6 +159,7 @@ linux-aarch64 linux-armv7 linux-s390x + linux-riscv64 windows-x86_64 osx-x86_64 osx-aarch64 diff --git a/pom.xml b/pom.xml index 2d788bb5..322ecdd4 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,18 @@ 1.8 + + + jdk9+ + + [9,) + + + 8 + + + + ossrh @@ -107,6 +119,12 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + org.apache.maven.plugins maven-jar-plugin