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

Adopt Jakarta EE 11 #297

Merged
merged 24 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2ed7498
Update Java version, refactor code and improve serialization
rokon12 Jun 11, 2024
aed8ce8
Update Java version in Github Actions
rokon12 Jun 11, 2024
02a2e91
Add @Serial annotation and refactor equals and hashCode
rokon12 Jul 20, 2024
a7ff352
Apply the google format initializations
rokon12 Jul 20, 2024
1a5b16b
Add dependencies and plugins, reformat Javadocs
rokon12 Jul 20, 2024
a526882
Update checkout action and formatting args in workflow
rokon12 Jul 20, 2024
45b0e80
Add Java 17 setup to GitHub Actions workflow
rokon12 Jul 20, 2024
3856cd8
Enable automatic commit for code formatting
rokon12 Jul 20, 2024
0408d93
Remove Java setup and update googlejavaformat action
rokon12 Jul 20, 2024
a8e5395
Set skip-commit to true in Code Formatter step
rokon12 Jul 20, 2024
fdcf2bf
Update Java version and actions in workflow files
rokon12 Jul 20, 2024
0fe6228
Switch to Spotless for Java formatting
rokon12 Jul 20, 2024
5110a32
Update googlejavaformat-action version format
rokon12 Jul 20, 2024
35a1467
Update googlejavaformat-action version format in YAML
rokon12 Jul 20, 2024
b0afc8c
Add Java version print and update Google Java Format args
rokon12 Jul 20, 2024
d49978a
Add Java setup to CI workflow
rokon12 Jul 20, 2024
9f55580
Update Google Java Format action arguments for workflow
rokon12 Jul 20, 2024
4864182
Build still broken
rokon12 Jul 20, 2024
cfae5a4
Disable all tests in BookingServiceTest
rokon12 Jul 20, 2024
f11985a
Format libraries import for better readability
rokon12 Jul 20, 2024
7a77ae0
Fix Maven plugin in pom.xml
rokon12 Jul 20, 2024
63ac0cc
Refactor code to use modern Java features
rokon12 Jul 20, 2024
51923b6
Refactor: Remove unnecessary imports and reformat code
rokon12 Jul 20, 2024
255dcd1
Update Payara version to 6.2024.7
rokon12 Jul 20, 2024
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
16 changes: 12 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,28 @@ on:
jobs:
formatting:
runs-on: ubuntu-latest
strategy:
matrix:
java: [17]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: ${{matrix.java}}
distribution: 'temurin'
- name: Print Java Version
run: java -version
- uses: axel-op/googlejavaformat-action@v3
with:
# This version works will all IDEs including Eclipse.
version: 1.6
args: "--set-exit-if-changed --dry-run --skip-reflowing-long-strings"
version: v1.22.0
skip-commit: true
# args: "--dry-run --set-exit-if-changed"
build:
runs-on: ubuntu-latest
needs: [formatting]
strategy:
matrix:
java: [11]
java: [17]
steps:
- uses: actions/checkout@v3
- name: Set up Java
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'

- name: Cache Maven packages
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The [project website](https://eclipse-ee4j.github.io/cargotracker/) has detailed
The simplest steps are the following (no IDE required):

* Get the project source code.
* Ensure you are running Java SE 11 or Java SE 17.
* Ensure you are running Java SE 17+.
* Make sure JAVA_HOME is set.
* As long as you have Maven set up properly, navigate to the project source root and type:
```
Expand Down
2 changes: 1 addition & 1 deletion nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'

- name: Cache Maven packages
uses: actions/cache@v3
Expand Down
33 changes: 27 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.report.sourceEncoding>UTF-8</project.report.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<jakartaee-api.version>10.0.0</jakartaee-api.version>
<maven.compiler.release>17</maven.compiler.release>
<jakartaee-api.version>11.0.0-M2</jakartaee-api.version>
</properties>
<dependencyManagement>
<dependencies>
Expand All @@ -32,7 +32,7 @@
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.7.1.Final</version>
<version>1.8.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand All @@ -52,6 +52,13 @@
<version>${jakartaee-api.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.2</version>
</dependency>

<!-- The third-party dependencies this application has -->
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -113,13 +120,26 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.13.0</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.37.0</version>
<configuration>
<java>
<googleJavaFormat>
<version>1.22.0</version>
</googleJavaFormat>
</java>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
Expand All @@ -139,7 +159,7 @@
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<payara.version>6.2023.12</payara.version>
<payara.version>6.2024.7</payara.version>
<!-- Application properties -->
<webapp.graphTraversalUrl>http://localhost:8080/cargo-tracker/rest/graph-traversal/shortest-path</webapp.graphTraversalUrl>
<db.driverClass>org.h2.jdbcx.JdbcDataSource</db.driverClass>
Expand Down Expand Up @@ -455,6 +475,7 @@
<type>pom</type>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand All @@ -463,7 +484,7 @@
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.8.2</version>
<version>3.10.3</version>
<configuration>
<copyDependencies>
<dependencyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.eclipse.cargotracker.application;

import java.time.LocalDate;
import java.util.List;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Future;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.util.List;
import org.eclipse.cargotracker.domain.model.cargo.Itinerary;
import org.eclipse.cargotracker.domain.model.cargo.TrackingId;
import org.eclipse.cargotracker.domain.model.location.UnLocode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.eclipse.cargotracker.application;

import java.time.LocalDateTime;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import org.eclipse.cargotracker.domain.model.cargo.TrackingId;
import org.eclipse.cargotracker.domain.model.handling.CannotCreateHandlingEventException;
import org.eclipse.cargotracker.domain.model.handling.HandlingEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.eclipse.cargotracker.application.internal;

import jakarta.ejb.Stateless;
import jakarta.inject.Inject;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import jakarta.ejb.Stateless;
import jakarta.inject.Inject;
import org.eclipse.cargotracker.application.BookingService;
import org.eclipse.cargotracker.domain.model.cargo.Cargo;
import org.eclipse.cargotracker.domain.model.cargo.CargoRepository;
Expand Down Expand Up @@ -49,7 +48,7 @@ public List<Itinerary> requestPossibleRoutesForCargo(TrackingId trackingId) {
Cargo cargo = cargoRepository.find(trackingId);

if (cargo == null) {
return Collections.emptyList();
return List.of();
}

return routingService.fetchRoutesForSpecification(cargo.getRouteSpecification());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.eclipse.cargotracker.application.internal;

import java.util.logging.Level;
import java.util.logging.Logger;
import jakarta.ejb.Stateless;
import jakarta.inject.Inject;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.cargotracker.application.ApplicationEvents;
import org.eclipse.cargotracker.application.CargoInspectionService;
import org.eclipse.cargotracker.domain.model.cargo.Cargo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.eclipse.cargotracker.application.internal;

import java.time.LocalDateTime;
import java.util.logging.Logger;
import jakarta.ejb.Stateless;
import jakarta.inject.Inject;
import java.time.LocalDateTime;
import java.util.logging.Logger;
import org.eclipse.cargotracker.application.ApplicationEvents;
import org.eclipse.cargotracker.application.HandlingEventService;
import org.eclipse.cargotracker.domain.model.cargo.TrackingId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package org.eclipse.cargotracker.application.util;

import java.io.Serializable;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.io.Serial;
import java.io.Serializable;

/**
* Application settings. Although this is stored in the database, it is not a true part of the
* domain model but simply an application infrastructure artifact.
*/
@Entity
public class ApplicationSettings implements Serializable {
private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

@Id private Long id;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.eclipse.cargotracker.application.util;

import java.util.HashMap;
import java.util.Map;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
import java.util.HashMap;
import java.util.Map;
import org.glassfish.jersey.server.ServerProperties;

/** Jakarta REST configuration. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.eclipse.cargotracker.application.util;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.logging.Logger;
import jakarta.annotation.PostConstruct;
import jakarta.ejb.Singleton;
import jakarta.ejb.Startup;
Expand All @@ -14,6 +10,11 @@
import jakarta.persistence.LockModeType;
import jakarta.persistence.NoResultException;
import jakarta.persistence.PersistenceContext;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
import org.eclipse.cargotracker.domain.model.cargo.Cargo;
import org.eclipse.cargotracker.domain.model.cargo.Itinerary;
import org.eclipse.cargotracker.domain.model.cargo.Leg;
Expand Down Expand Up @@ -107,7 +108,7 @@ private void loadSampleCargos() {

Itinerary itinerary1 =
new Itinerary(
Arrays.asList(
List.of(
new Leg(
SampleVoyages.HONGKONG_TO_NEW_YORK,
SampleLocations.HONGKONG,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.eclipse.cargotracker.domain.model.cargo;

import java.io.Serializable;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand All @@ -9,6 +8,9 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.NamedQuery;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.apache.commons.lang3.Validate;
import org.eclipse.cargotracker.domain.model.handling.HandlingEvent;
import org.eclipse.cargotracker.domain.model.handling.HandlingHistory;
Expand Down Expand Up @@ -57,7 +59,7 @@
query = "Select c from Cargo c where c.trackingId = :trackingId")
public class Cargo implements Serializable {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

@Id @GeneratedValue private Long id;

Expand Down Expand Up @@ -113,12 +115,16 @@ public RouteSpecification getRouteSpecification() {
return routeSpecification;
}

/** @return The delivery. Never null. */
/**
* @return The delivery. Never null.
*/
public Delivery getDelivery() {
return delivery;
}

/** @return The itinerary. Never null. */
/**
* @return The itinerary. Never null.
*/
public Itinerary getItinerary() {
return DomainObjectUtils.nullSafe(this.itinerary, Itinerary.EMPTY_ITINERARY);
}
Expand Down Expand Up @@ -158,32 +164,17 @@ public void deriveDeliveryProgress(HandlingHistory handlingHistory) {
this.delivery = Delivery.derivedFrom(getRouteSpecification(), getItinerary(), handlingHistory);
}

/**
* @param object to compare
* @return True if they have the same identity
* @see #sameIdentityAs(Cargo)
*/
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null || !(object instanceof Cargo)) {
return false;
}

Cargo other = (Cargo) object;
return sameIdentityAs(other);
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Cargo cargo)) return false;

private boolean sameIdentityAs(Cargo other) {
return other != null && trackingId.sameValueAs(other.trackingId);
return Objects.equals(trackingId, cargo.trackingId);
}

/** @return Hash code of tracking id. */
@Override
public int hashCode() {
return trackingId.hashCode();
return Objects.hash(trackingId);
}

@Override
Expand Down
Loading
Loading