Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: java support for sdk17 #1952

Merged
merged 20 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/acceptance_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ concurrency:

env:
python_version: '3.11'
java_version: '11'
java_distribution: 'temurin'
java_version: '17'
java_distribution: 'zulu'

jobs:
fail_if_pull_request_is_draft: # Fails in order to indicate that pull request needs to be marked as ready to review to pass.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
types: [ prereleased, released ]

env:
java_version: '11'
java_distribution: 'temurin'
java_version: '17'
java_distribution: 'zulu'

jobs:
validate_gradle_wrapper:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/end_to_end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ on:

env:
python_version: '3.11'
java_version: '11'
java_distribution: 'temurin'
java_version: '17'
java_distribution: 'zulu'

jobs:
validate_gradle_wrapper:
Expand Down
46 changes: 38 additions & 8 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
- '.github/workflows/**'

env:
java_version: '11'
java_distribution: 'temurin'
java_version: '17'
java_distribution: 'zulu'

jobs:
formatting:
Expand All @@ -21,25 +21,55 @@ jobs:
with:
java-version: ${{ env.java_version }}
distribution: ${{ env.java_distribution }}

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Check code compliance to google java format standards
uses: gradle/gradle-build-action@v2

- name: Run Spotless Check
run: |
./gradlew spotlessCheck --quiet --continue 2>&1 | tee spotless-output.txt
if grep -q "\.java" spotless-output.txt; then
exit 1
fi

- name: Upload Spotless Output
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
arguments: verGJF
name: spotless-output
path: spotless-output.txt

- name: Extract Affected Files
if: ${{ failure() }}
run: |
grep "\.java" spotless-output.txt > affected-files.txt || true

- name: Comment PR if code does not comply to Google Java style guide
if: ${{ failure() }}
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const files = fs.existsSync('affected-files.txt') ? fs.readFileSync('affected-files.txt', 'utf8').trim().split('\n') : [];
if (files.length === 0) return;

const actionsDashboardUrl = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}`;

const commentBody = `### 🚨 Code Formatting Issue 🚨\n\n`
+ `This contribution does not follow the conventions set by the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).\n\n`
+ `Please run the following command at the root of the project to fix formatting errors:\n\n`
+ "```sh\n./gradlew spotlessApply\n```\n\n"
+ `<details><summary><strong>🗂️ Affected files</strong></summary>\n\n${files.map(file => `- \`${file.trim()}\``).join('\n')}</details>\n\n`
+ `[Go to the Actions Dashboard to download the full Spotless output](${actionsDashboardUrl})\n\n`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "This contribution does not follow the conventions set by the [Google Java style guide](https://google.github.io/styleguide/javaguide.html). Please run the following command line at the root of the project to fix formatting errors: ```./gradlew goJF```."
})
body: commentBody
});
2 changes: 1 addition & 1 deletion .github/workflows/package_installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ env:
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
MACOS_NOTARIZATION_PWD: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
java_version: '17.0'
java_version: '17'
java_distribution: 'zulu'

jobs:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/publish_assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

env:
java_version: '17.0'
java_version: '17'
java_distribution: 'zulu'

jobs:
Expand Down Expand Up @@ -101,7 +101,6 @@ jobs:

- name: Build and Publish to Sonatype
run: |
# The gradle java verifying plugin does not work with java 17.
# Don't verify since it has already been done when the PR was created.
./gradlew publish --rerun-tasks -x verifyGoogleJavaFormat
./gradlew publish --rerun-tasks -x spotlessCheck

2 changes: 1 addition & 1 deletion .github/workflows/stg_web_client_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
NODE_VERSION: "20"
java_version: '17.0'
java_version: '17'
java_distribution: 'zulu'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stg_web_svc_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
NODE_VERSION: "20"
java_version: '17.0'
java_version: '17'
java_distribution: 'zulu'

jobs:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test_pack_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java_version: [ 11, 17 ]
java_version: [ '17' ]
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java_version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java_version }}
distribution: 'temurin'
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
Expand All @@ -37,7 +37,6 @@ jobs:
- name: Run tests on Java ${{ matrix.java_version }} and ${{ matrix.os }}
uses: gradle/gradle-build-action@v2
with:
# We run test aggregation with --continue to make sure all tests run, even if some fail.
arguments: testAggregateTestReport --continue
- name: Persist aggregated test reports on failure - Java ${{ matrix.java_version }} on ${{ matrix.os }}
if: ${{ failure() }}
Expand All @@ -51,15 +50,15 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java_version: [ 11, 17 ]
java_version: [ '17' ]
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java_version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java_version }}
distribution: 'temurin'
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
Expand All @@ -75,20 +74,21 @@ jobs:
with:
name: Application - CLI executable - Java ${{ matrix.java_version }} JAR file -- ${{ matrix.os }}
path: cli/build/libs/gtfs-validator-*-cli.jar

doc:
needs: [test]
runs-on: ${{ matrix.os }}
strategy:
matrix:
java_version: [ 11, 17 ]
java_version: [ '17' ]
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java_version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java_version }}
distribution: 'temurin'
distribution: 'zulu'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
Expand All @@ -102,5 +102,5 @@ jobs:
- name: Persist javadoc
uses: actions/upload-artifact@v4
with:
name: Documentation - javadoc - Java ${{ matrix.java_version }} - ${{ matrix.java_version }}
path: build/docs/javadoc/
name: Documentation - javadoc - Java ${{ matrix.java_version }} - ${{ matrix.os }}
path: build/docs/javadoc/
2 changes: 1 addition & 1 deletion .github/workflows/web_client_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
NODE_VERSION: "20"
java_version: '17.0'
java_version: '17'
java_distribution: 'zulu'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/web_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
NODE_VERSION: "20"
java_version: '17.0'
java_version: '17'
java_distribution: 'zulu'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/web_svc_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
NODE_VERSION: "20"
java_version: '17.0'
java_version: '17'
java_distribution: 'zulu'

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gradle:7-jdk11-alpine AS build
FROM eclipse-temurin:17-jdk-noble AS build

COPY --chown=gradle:gradle . /build
WORKDIR /build
Expand All @@ -9,7 +9,7 @@ RUN ./gradlew shadowJar \
-Prelease.forceVersion="${VERSION_TAG%-SNAPSHOT}"


FROM openjdk:11-slim
FROM eclipse-temurin:17-jdk-noble AS runtime
COPY --from=build /build/cli/build/libs/gtfs-validator-*-cli.jar /gtfs-validator-cli.jar
WORKDIR /

Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Several users have reported issues with the validator when processing their GTFS
1. Requests that come with custom user agents.
2. Requests originating from non-browser sources.

To facilitate easier debugging and logging, we have made our user agent header explicit. The user agent string follows the format: "MobilityData GTFS-Validator/{validatorVersion} (Java {java version})". In cases where the `validatorVersion` is null, the `{validatorVersion}` segment in the user agent string will be left blank. The string "MobilityData GTFS-Validator/5.0.1 (Java 11.0.1)" serves as an example of the User Agent string.
To facilitate easier debugging and logging, we have made our user agent header explicit. The user agent string follows the format: "MobilityData GTFS-Validator/{validatorVersion} (Java {java version})". In cases where the `validatorVersion` is null, the `{validatorVersion}` segment in the user agent string will be left blank. The string "MobilityData GTFS-Validator/5.0.1 (Java 17.0.8)" serves as an example of the User Agent string.

# Using the Desktop app
### Setup
Expand Down Expand Up @@ -85,8 +85,13 @@ Before running validation, tap the `Advanced` button to configure other aspects
* The country code used for phone number validation.

# Using the command line
### Setup
1. Install [Java 11 or higher](https://www.oracle.com/java/technologies/javase-downloads.html). To check which version of Java is installed on your computer, type the following command in the terminal: `java --version`.
### Setup
1. Install Java 17 or higher. To check which version of Java is installed on your computer, type the following command in the terminal: `java --version`. You can download Java from one of the following sources:
- **[Eclipse Adoptium (Temurin)](https://adoptium.net/temurin/releases/)** – Open-source & widely used
- **[Amazon Corretto](https://aws.amazon.com/corretto/)** - AWS-supported, optimized for cloud
- **[Azul Zulu](https://www.azul.com/downloads/)** - Enterprise ready
- **[Microsoft Build of OpenJDK](https://learn.microsoft.com/en-us/java/openjdk/download/)** - Microsoft's JDK
- **[Oracle JDK](https://www.oracle.com/java/technologies/javase-downloads.html)** - Official Java from Oracle
2. Navigate to the [Releases page](https://github.com/MobilityData/gtfs-validator/releases) and download the latest `Gtfs Validator` CLI jar (not OS-specific). It is located in the **Assets** section of the release, and it looks like `gtfs-validator-vX.X.X_cli.jar`
3. Open the terminal on your computer
4. Navigate to the directory containing the jar file. You can do this by typing the following command in the terminal:`cd {directory path}`, where {directory path} is the absolute or relative path to the directory. You can then make sure you're in the right directory by typing `pwd` in the terminal (this stands for *present working directory*). You can also make sure the jar file is there by typing `ls` in the terminal (this stands for *list* and will display the list of files in this directory). More about commands to navigate file and directories [here](https://help.ubuntu.com/community/UsingTheTerminal#File_.26_Directory_Commands).
Expand Down
2 changes: 1 addition & 1 deletion app/gui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
plugins {
id 'application'
id 'java'
id 'com.github.johnrengelman.shadow' version '5.2.0'
alias(libs.plugins.shadow.jar)
}

mainClassName = 'org.mobilitydata.gtfsvalidator.app.gui.Main'
Expand Down
16 changes: 12 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ plugins {
id 'maven-publish'
id 'signing'
id 'test-report-aggregation'
id 'com.github.sherter.google-java-format' version '0.9'
id "io.freefair.aggregate-javadoc" version "6.4.3"
id "pl.allegro.tech.build.axion-release" version "1.13.6"
id "pl.allegro.tech.build.axion-release" version "1.15.3"
alias(libs.plugins.spotless)
}

// Setup and configure properties that are consistent across all projects, including sub-modules.
Expand All @@ -48,8 +48,8 @@ allprojects {

tasks.withType(JavaCompile) {
// All Java projects should target the same compatibility version.
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

// Our source files should be encoded in UTF-8, regardless of the platform (e.g. Windows).
compileJava.options.encoding = "UTF-8"
Expand Down Expand Up @@ -80,6 +80,7 @@ allprojects {

subprojects {
apply plugin: 'java'
apply plugin: libs.plugins.spotless.get().pluginId

// Cannot publish a SNAPSHOT. The provided sonatype url will not accept it.
tasks.withType(PublishToMavenRepository).all { task ->
Expand All @@ -101,6 +102,13 @@ subprojects {
from sourceSets.main.allSource
}

spotless {
java {
googleJavaFormat("1.25.2")
target("src/**/*.java")
}
}

// These modules require the same publishing configuration, apart from the name of the module
// Also we want to limit artefact publishing to these modules.
if (project.name == 'main' ||
Expand Down
2 changes: 1 addition & 1 deletion cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/

plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'application'
id 'java'
alias(libs.plugins.shadow.jar)
}

applicationDefaultJvmArgs = [ "-Xmx8G" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ public boolean getExportNoticeSchema() {
return exportNoticeSchema;
}

/** @return true if CLI parameter combination is legal, otherwise return false */
/**
* @return true if CLI parameter combination is legal, otherwise return false
*/
public boolean validate() {
if (getExportNoticeSchema() && abortAfterNoticeSchemaExport()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public Double getValidationTimeSeconds() {
public List<MemoryUsage> getMemoryUsageRecords() {
return memoryUsageRecords;
}

/**
* Determines if two validation reports are equal regardless of the order of the fields in the set
* of {@code NoticeReport}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ private MemoryUsageRegister() {
runtime = Runtime.getRuntime();
}

/** @return the singleton instance of the memory usage register. */
/**
* @return the singleton instance of the memory usage register.
*/
public static MemoryUsageRegister getInstance() {
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
public final class CsvFileLoader extends TableLoader {

private CsvFileLoader() {}

// Create the singleton and add a method to obtain it
private static final CsvFileLoader INSTANCE = new CsvFileLoader();

Expand Down
Loading
Loading