Skip to content

Commit

Permalink
Add Maven profiles
Browse files Browse the repository at this point in the history
* to support building and packaging artifacts targeting different versions of the JDK/JRE
* default build target Java 8
* other variants activated by detecting installed version of JDK (or explicit override)
* Java 17 and Java 21 set properties that affect dependency and plugin versions of Square's Wire and Spring Boot
* Added Github Action workflows to get signal and feedback on activated Maven profiles
  * tests are skipped (for now)
  • Loading branch information
pacphi committed Oct 6, 2023
1 parent a38a980 commit a076e79
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 13 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '35 3 * * 6'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: liberica
java-version: 17

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
26 changes: 26 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Java CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17, 21 ]
name: Java ${{ matrix.java }} build
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: liberica
java-version: ${{ matrix.java }}
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: ./mvnw clean install -DskipTests -Dgpg.skip
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ bin/
.settings/
.factorypath
.gradle
.vscode
.history
*.log
2 changes: 1 addition & 1 deletion cloudfoundry-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</dependency>
<dependency>
<groupId>com.squareup.wire</groupId>
<artifactId>wire-runtime-jvm</artifactId>
<artifactId>wire-runtime${wire.suffix}</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
97 changes: 85 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,23 @@
</modules>

<properties>
<java.version>17</java.version>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<dependencies.version>2.7.16</dependencies.version>

<commons-compress.version>1.24.0</commons-compress.version>
<commons-lang3.version>3.13.0</commons-lang3.version>
<dependencies.version>3.1.4</dependencies.version>
<evo-inflector.version>1.3</evo-inflector.version>
<immutables.version>2.10.0-rc1</immutables.version>
<java-semver.version>0.9.0</java-semver.version>
<jjwt.version>0.11.5</jjwt.version>
<wire.version>4.9.1</wire.version>
<mockito.version>5.5.0</mockito.version>
<junit-jupiter.version>5.10.0</junit-jupiter.version>
<mockito.version>5.5.0</mockito.version>
<snakeyaml.version>2.2</snakeyaml.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<wire.version>2.2.0</wire.version>
<wire.plugin.version>2.2.0</wire.plugin.version>
<wire.suffix></wire.suffix>
</properties>

<dependencyManagement>
Expand All @@ -87,7 +91,7 @@
</dependency>
<dependency>
<groupId>com.squareup.wire</groupId>
<artifactId>wire-runtime-jvm</artifactId>
<artifactId>wire-runtime${wire.suffix}</artifactId>
<version>${wire.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -131,7 +135,7 @@
<plugin>
<groupId>com.squareup.wire</groupId>
<artifactId>wire-maven-plugin</artifactId>
<version>3.0.2</version>
<version>${wire.plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
Expand All @@ -145,11 +149,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<!-- @see https://github.com/immutables/immutables/issues/1339#issuecomment-1016125673 -->
<configuration>
<fork>true</fork>
<compilerArgs combine.children="append">
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Xlint:-options</arg>
<arg>-Xlint:-processing</arg>
<arg>-Xlint:-serial</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<source>${java.version}</source>
Expand Down Expand Up @@ -180,7 +185,7 @@
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goals>
<goal>jar</goal>
</goals>
</execution>
Expand Down Expand Up @@ -303,6 +308,74 @@
<module>test-service-broker</module>
</modules>
</profile>

<profile>
<id>jdk-17</id>
<activation>
<jdk>17</jdk>
</activation>
<properties>
<java.version>17</java.version>
<dependencies.version>3.1.4</dependencies.version>
<wire.version>4.9.1</wire.version>
<wire.plugin.version>3.0.2</wire.plugin.version>
<wire.suffix>-jvm</wire.suffix>
</properties>
<build>
<finalName>${project.artifactId}-jdk17-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<!-- @see https://github.com/immutables/immutables/issues/1339#issuecomment-1016125673 -->
<configuration>
<fork>true</fork>
<compilerArgs combine.children="append">
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>jdk-21</id>
<activation>
<jdk>21</jdk>
</activation>
<properties>
<java.version>21</java.version>
<dependencies.version>3.1.4</dependencies.version>
<wire.version>4.9.1</wire.version>
<wire.plugin.version>3.0.2</wire.plugin.version>
<wire.suffix>-jvm</wire.suffix>
</properties>
<build>
<finalName>${project.artifactId}-jdk21-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<!-- @see https://github.com/immutables/immutables/issues/1339#issuecomment-1016125673 -->
<configuration>
<fork>true</fork>
<compilerArgs combine.children="append">
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit a076e79

Please sign in to comment.