Skip to content

Commit

Permalink
Update Java versions in build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
swismer committed Jun 30, 2023
1 parent 8e9fa53 commit d6f1e83
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 121 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [9, 10, 11, 12, 13]
java: [8, 11, 17, 18, 19, 20]
name: Java ${{ matrix.java }} build
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -34,7 +34,7 @@ jobs:
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
- uses: actions/setup-java@v1
with:
java-version: 9
java-version: 11
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand Down
253 changes: 134 additions & 119 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>8</maven.compiler.release>
</properties>

<scm>
Expand All @@ -49,132 +48,148 @@
</repository>
</distributionManagement>

<build>
<plugins>
<!-- Ensure the project is compiling with JDK 9+ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>enforce-jdk-paths</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.9,)</version>
<message>A JDK 9+ installation is required to compile this Maven project</message>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- Mark Java 9 sources as a source directory, but disable to prevent adding to java-7-compile task -->
<!-- This signals to IDEs that the java9 directory should be added as a source directory -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>none</phase>
<goals>
<goal>add-source</goal>
</goals>

<profiles>
<profile>
<!-- simple profile for Java 8, ony for testing backwards compatibility -->
<activation>
<jdk>1.8</jdk>
</activation>
<id>jdk8</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<sources>
<source>${project.basedir}/src/main/java9</source>
</sources>
<source>1.8</source>
<target>1.8</target>
</configuration>
</execution>
</executions>
</plugin>
<!-- Compile multi-release JAR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<executions>
<!-- disable default compilation phase, as it is used to signal the correct Java version to IDES-->
<!-- specifying `< java 9` will not allow IDEs to properly interpret module-info.java -->
<execution>
<id>default-compile</id>
<phase>none</phase>
<goals>
<goal>compile</goal>
</goals>
</plugin>
</plugins>
</build>
</profile>
<!-- main profile -->
<profile>
<activation>
<jdk>[1.9,)</jdk>
</activation>
<id>jdk9</id>
<properties>
<maven.compiler.release>8</maven.compiler.release>
</properties>
<build>
<plugins>
<!-- Mark Java 9 sources as a source directory, but disable to prevent adding to java-7-compile task -->
<!-- This signals to IDEs that the java9 directory should be added as a source directory -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>none</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/main/java9</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Compile multi-release JAR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<executions>
<!-- disable default compilation phase, as it is used to signal the correct Java version to IDES-->
<!-- specifying `< java 9` will not allow IDEs to properly interpret module-info.java -->
<execution>
<id>default-compile</id>
<phase>none</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<!-- indicate at least Java 9 language level -->
<release>9</release>
</configuration>
</execution>
<!-- compile sources for Java 8 -->
<execution>
<id>java-8-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</execution>
<!-- compile module-info for Java 9, stored under META-INF/versions/9/module-info.class -->
<execution>
<id>java-9-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>9</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<!-- Mark artifact as a multi-release JAR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<!-- indicate at least Java 9 language level -->
<release>9</release>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
</execution>
<!-- compile sources for Java 8 -->
<execution>
<id>java-8-compile</id>
<goals>
<goal>compile</goal>
</goals>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<configuration>
<release>${maven.compiler.release}</release>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
<!-- compile module-info for Java 9, stored under META-INF/versions/9/module-info.class -->
<execution>
<id>java-9-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<release>9</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</execution>
</executions>
</plugin>
<!-- Mark artifact as a multi-release JAR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
Expand Down

0 comments on commit d6f1e83

Please sign in to comment.