Skip to content

Commit

Permalink
Merge pull request #18 from maptic/feature/openjdk18-matsim-15
Browse files Browse the repository at this point in the history
Feature/openjdk18 matsim 15
  • Loading branch information
munterfi authored Oct 9, 2022
2 parents 5223ec0 + b7f74d5 commit 79cb109
Show file tree
Hide file tree
Showing 9 changed files with 612 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 18
uses: actions/setup-java@v2
with:
java-version: "11"
java-version: "18"
distribution: "adopt"
cache: maven
- name: Build with Maven
Expand Down
573 changes: 570 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 15.0-2022w40-1

* Update to JDK 18.
* Bump MATSim version to 15.0.

## v14.0-1

* Bump MATSim version to 14.0.
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG APP_DIR=/opt/matsim

FROM maven:3.6.0-jdk-11-slim AS build
FROM maven:3.8.6-openjdk-18-slim AS build
ARG APP_DIR
WORKDIR ${APP_DIR}
COPY . ./
Expand All @@ -12,9 +12,9 @@ RUN mvn -f pom.xml -DskipTests clean package \
&& figlet -f slant "MATSim $(cat VERSION.txt)" > BANNER.txt \
&& echo "Image build date: $(date --iso-8601=seconds)" >> BANNER.txt

FROM openjdk:11-jre-slim
FROM openjdk:18-slim
ARG APP_DIR
LABEL maintainer="Merlin Unterfinger <info@munterfinger.ch>"
LABEL maintainer="Merlin Unterfinger <merlin.unterfinger@maptic.ch>"
WORKDIR ${APP_DIR}
COPY docker-entrypoint.sh ./
COPY --from=build ${APP_DIR}/*.txt ./resources/
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

<groupId>ch.maptic</groupId>
<artifactId>matsim-docker</artifactId>
<version>14.0-1</version>
<version>15.0-2022w40</version>

<name>matsim-docker</name>
<url>http://www.maptic.ch</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<matsim.version>14.0</matsim.version>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<matsim.version>15.0-2022w40</matsim.version>
</properties>

<repositories>
Expand All @@ -27,9 +27,9 @@

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/ch/maptic/matsim/docker/DockerEntrypoint.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ch.maptic.matsim.docker;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Scenario;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
Expand All @@ -10,22 +11,22 @@

public class DockerEntrypoint {

static Logger logger = Logger.getLogger(DockerEntrypoint.class);
private static final Logger logger = LogManager.getLogger(DockerEntrypoint.class);

public static void main(String[] args) {

String inputPath = Environment.getMatsimInputPath();
String outputPath = Environment.getMatsimOutputPath();
String matsimVersion = Environment.getMatsimVersion();

logger.info(String.format("Starting MATSim %s in Docker container.", matsimVersion));
logger.info("Starting MATSim {} in Docker container.", matsimVersion);
if (args == null || args.length == 0 || args[0] == null) {
args = new String[] { String.format("%s/%s", inputPath, "config.xml") };
} else {
args[0] = String.format("%s/%s", inputPath, args[0]);
}

logger.info(String.format("Loading config with args: %s", String.join(", ", args)));
logger.info("Loading config with args: {}", String.join(", ", args));
Config config = ConfigUtils.loadConfig(args);
config.controler().setOutputDirectory(outputPath);
config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/ch/maptic/matsim/docker/Environment.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package ch.maptic.matsim.docker;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

class Environment {

static Logger logger = Logger.getLogger(Environment.class);
private static final Logger logger = LogManager.getLogger(Environment.class);

private Environment() {
}

public static String getMatsimInputPath() {
return getEnvVar("MATSIM_INPUT");
Expand All @@ -20,7 +24,7 @@ public static String getMatsimVersion() {

private static String getEnvVar(String name) {
String value = System.getenv(name);
logger.debug(String.format("Getting environment variable %s: %s.", name, value));
logger.debug("Getting environment variable {}: {}.", name, value);
return value;
}
}
15 changes: 8 additions & 7 deletions src/test/java/ch/maptic/matsim/docker/DockerEntrypointTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package ch.maptic.matsim.docker;

import org.junit.Assert;
import org.junit.Test;
import org.apache.log4j.Logger;
import static org.junit.jupiter.api.Assertions.fail;

import org.apache.logging.log4j.LogManager;
import org.junit.jupiter.api.Test;

/**
* Unit test for DockerEntrypoint.
Expand All @@ -18,8 +19,8 @@ public void testDockerEntrypoint() {
DockerEntrypoint.main(null);

} catch (Exception ee) {
Logger.getLogger(this.getClass()).fatal("there was an exception: \n" + ee);
Assert.fail();
LogManager.getLogger(this.getClass()).fatal("there was an exception: \n" + ee);
fail();
}
}

Expand All @@ -30,8 +31,8 @@ public void testDockerEntrypointArgs() {
DockerEntrypoint.main(args);

} catch (Exception ee) {
Logger.getLogger(this.getClass()).fatal("there was an exception: \n" + ee);
Assert.fail();
LogManager.getLogger(this.getClass()).fatal("there was an exception: \n" + ee);
fail();
}
}
}
9 changes: 5 additions & 4 deletions src/test/java/ch/maptic/matsim/docker/EnvironmentTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package ch.maptic.matsim.docker;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

/**
* Unit test for Environment.
Expand All @@ -13,7 +14,7 @@ public class EnvironmentTest {

@Test
public void testEnvironment() {
Assert.assertEquals("test/input", Environment.getMatsimInputPath());
Assert.assertEquals("test/output", Environment.getMatsimOutputPath());
assertEquals("test/input", Environment.getMatsimInputPath());
assertEquals("test/output", Environment.getMatsimOutputPath());
}
}

0 comments on commit 79cb109

Please sign in to comment.