Skip to content

Commit

Permalink
[Build] Setup Maven toolchains and run Maven build with Java-17
Browse files Browse the repository at this point in the history
but still target 11.
The subsequent Maven-plugin update requires Java-17 to run the build
itself.
  • Loading branch information
iils-hwellmann committed Jan 10, 2024
1 parent 2169f5b commit 0a0c2d4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .github/actions/setup-java-for-deployment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ runs:
- name: Set up JDK 11 for Maven Central Repository deployment
uses: actions/setup-java@v3
with:
java-version: '11'
# Also generates a corresponding Maven toolchains.xml
java-version: |
11
17
distribution: 'temurin'
cache: 'maven' # Cache Maven dependencies between workflow runs
# Properties for deployment to OSSRH:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}

- run: mvn -f symja_android_library -B -U -P publish-to-maven-central deploy -Dgpg.skip=true
- run: mvn -f symja_android_library -B -U -P publish-to-maven-central,exact-target-jdk deploy -Dgpg.skip=true
# Deployment of all modules is deferred to the last module by nexus-staging-maven-plugin
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Java
uses: ./.github/actions/setup-java-for-deployment

- run: mvn -f symja_android_library -B -U verify
- run: mvn -f symja_android_library -B -U -Pexact-target-jdk verify

- uses: actions/upload-artifact@v4
with:
Expand Down
33 changes: 32 additions & 1 deletion symja_android_library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down Expand Up @@ -457,7 +462,7 @@
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>publish-to-maven-central</releaseProfiles>
<releaseProfiles>publish-to-maven-central,exact-target-jdk</releaseProfiles>
<arguments>-Drelease.build=true</arguments>
</configuration>
</plugin>
Expand Down Expand Up @@ -599,6 +604,32 @@
</plugins>
</build>
<profiles>
<profile>
<id>exact-target-jdk</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>${java.version}</version>
</jdk>
</toolchains>
</configuration>
</plugin>

</plugins>
</build>
</profile>
<profile>
<id>publish-to-maven-central</id>
<build>
Expand Down

0 comments on commit 0a0c2d4

Please sign in to comment.