From d15bd0141cfce0022c21e44e9508c9290801553a Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Wed, 31 Jul 2024 13:19:21 +0200 Subject: [PATCH 1/5] Improve UML legend. --- doc/uml/class-diagram-technical.puml | 10 +++++----- doc/uml/component-diagram-overview.puml | 23 ++++++++++------------- doc/uml/deployment-diagram.puml | 5 ++--- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/doc/uml/class-diagram-technical.puml b/doc/uml/class-diagram-technical.puml index 8bac5341..20770892 100644 --- a/doc/uml/class-diagram-technical.puml +++ b/doc/uml/class-diagram-technical.puml @@ -6,7 +6,7 @@ skinparam package { BackgroundColor<
> gold BorderColor black ArrowColor black - FontName Arial Unicode MS + FontName Arial Unicode MS FontSize 20 } @@ -16,7 +16,7 @@ skinparam class { BackgroundColor<
> gold BorderColor black ArrowColor black - FontName Arial Unicode MS + FontName Arial Unicode MS FontSize 20 } skinparam classFontSize 24 @@ -50,7 +50,7 @@ note "Vererbung" as Vererbung note "Implementierung" as Implementierung note "gerichtete Assoziation" as Assoziation note "generischen Typ binden" as Generics -note "gerichtete Abhängigkeit" as Dependency +note "gerichtete Abhängigkeit:\n<> benutzt\n<> erzeugt\n<> Aufruf" as Dependency class ConcreteObservable { -concreteState: State @@ -97,8 +97,8 @@ Observer <|.. AbstractObserver AbstractObserver <|-- ConcreteObserver : <> \n ConcreteObserver> ConcreteObservable <-left- ConcreteObserver : \t\t -java .up. Package -util .up. Subpackage +java .right. Package +util .down. Subpackage Observable .up. Class Observable .. Vererbung ConcreteObservable .up. Vererbung diff --git a/doc/uml/component-diagram-overview.puml b/doc/uml/component-diagram-overview.puml index 0acd7708..b71ea731 100644 --- a/doc/uml/component-diagram-overview.puml +++ b/doc/uml/component-diagram-overview.puml @@ -7,7 +7,7 @@ skinparam component { BorderColor black FontName Arial Unicode MS FontSize 20 - ArrowFontName Arial Unicode MS + ArrowFontName Arial Unicode MS ArrowFontSize 18 } @@ -42,27 +42,24 @@ anwendung .up.> library : " <>" note "Artefakt" as artefact note "Komponente" as component note "Schnittstelle" as schnittstelle -note "Implementierung" as Implementierung -note "Aufruf" as Use -note "gerichtete Abhängigkeit" as Dependency - -circle " \t\t\t Fassade " as fassade -circle "RestApi " as api +note "Implementierung\neiner Schnittstelle" as Implementierung +note "Aufruf einer\nSchnittstelle" as Use +note "gerichtete Abhängigkeit\nohne Angabe Interface" as Dependency +circle "\t Fassade " as fassade anwendung ..> fassade : " <>" -fassade -- fachkomponente +fassade -up- fachkomponente anwendung .down. Use fassade .up. Use -api .up. schnittstelle +fassade .left. schnittstelle library .up. component -lang .left. artefact +lang .down. artefact -anwendung -up- api : " " -api .down. Implementierung -anwendung .right. Implementierung +fassade .down. Implementierung +fachkomponente .right. Implementierung anwendung .up. Dependency library .down. Dependency diff --git a/doc/uml/deployment-diagram.puml b/doc/uml/deployment-diagram.puml index 0a21eeb3..a4780bc8 100644 --- a/doc/uml/deployment-diagram.puml +++ b/doc/uml/deployment-diagram.puml @@ -20,12 +20,11 @@ skinparam artifact { BackgroundColor #e4e4e4 BorderColor #a0a0a0 ArrowColor black - FontName Arial Unicode MS + FontName Arial Unicode MS FontSize 20 StereotypeFontSize 14 } - node ":MacBook" <> { node ":macOS Monterey" <> { node ":Safari 15.4" <> { @@ -62,7 +61,7 @@ note "Execution Environment" as env ":Server" .. channel ":MacBook" .. channel -W .right. artifact +C .left. artifact @enduml From 9caec27b1063ed4a54f5351359d2d0a1afcc401c Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Wed, 31 Jul 2024 13:19:59 +0200 Subject: [PATCH 2/5] Fix some JavaDoc spellings and remove deprecated method call. --- src/main/java/edu/hm/hafner/util/FilteredLog.java | 2 +- src/main/java/edu/hm/hafner/util/Generated.java | 2 +- src/main/java/edu/hm/hafner/util/PathUtil.java | 11 ++++++----- .../edu/hm/hafner/util/SecureXmlParserFactory.java | 8 +++++--- .../java/edu/hm/hafner/util/TreeStringBuilder.java | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/hm/hafner/util/FilteredLog.java b/src/main/java/edu/hm/hafner/util/FilteredLog.java index b297dbaa..98f10b31 100644 --- a/src/main/java/edu/hm/hafner/util/FilteredLog.java +++ b/src/main/java/edu/hm/hafner/util/FilteredLog.java @@ -14,7 +14,7 @@ /** * Provides a log of info messages and a limited number of error messages. If the number of errors exceeds this limit, - * then subsequent error messages will be skipped. This class is thread-safe and can be used in a distributed + * then further error messages will be skipped. This class is thread-safe and can be used in a distributed * environment. * * @author Ullrich Hafner diff --git a/src/main/java/edu/hm/hafner/util/Generated.java b/src/main/java/edu/hm/hafner/util/Generated.java index a4eaadd8..175d1d9e 100644 --- a/src/main/java/edu/hm/hafner/util/Generated.java +++ b/src/main/java/edu/hm/hafner/util/Generated.java @@ -9,7 +9,7 @@ /** * This annotation is used to mark source code that has been generated or is somehow not relevant for style checking or * code coverage analysis. It is quite similar to the {@code javax.annotation.Generated} annotation. The - * main difference is that it has class retention on so is available for tools that work on bytecode (like JaCoCo, + * main difference is that it has class retention, so it is available for tools that work on bytecode (like JaCoCo, * PIT, or SpotBugs). */ @Retention(CLASS) diff --git a/src/main/java/edu/hm/hafner/util/PathUtil.java b/src/main/java/edu/hm/hafner/util/PathUtil.java index e15fb8dd..9ccadb18 100644 --- a/src/main/java/edu/hm/hafner/util/PathUtil.java +++ b/src/main/java/edu/hm/hafner/util/PathUtil.java @@ -15,7 +15,8 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; /** - * Utilities for {@link Path} instances. + * Utilities for {@link Path} instances. These methods handle file paths in Windows and Unix file system + * implementations transparently. Moreover, these methods do not throw exceptions when illegal paths are specified. * * @author Ullrich Hafner */ @@ -71,7 +72,7 @@ public boolean exists(final String fileName, final String directory) { /** * Returns the string representation of the specified path. The path will be actually resolved in the file system - * and will be returned as fully qualified absolute path. In case of an error, i.e. if the file is not found, the + * and will be returned as a fully qualified absolute path. In case of an error, i.e., if the file is not found, the * provided {@code path} will be returned unchanged (but normalized using the UNIX path separator and upper case * drive letter). * @@ -91,7 +92,7 @@ public String getAbsolutePath(final String path) { /** * Returns the string representation of the specified path. The path will be actually resolved in the file system - * and will be returned as fully qualified absolute path. In case of an error, i.e. if the file is not found, the + * and will be returned as a fully qualified absolute path. In case of an error, i.e., if the file is not found, the * provided {@code path} will be returned unchanged (but normalized using the UNIX path separator and upper case * drive letter). * @@ -140,7 +141,7 @@ public String getRelativePath(final Path base, final String path) { * UNIX path separator and upper case drive letter). * * @param base - * the base directory that should be to get the absolute path for + * the base directory that should be to get the absolute path for * @param path * the path to get the absolute path for * @@ -163,7 +164,7 @@ public String getRelativePath(final String base, final String path) { * UNIX path separator and upper case drive letter). * * @param base - * the base directory that should be to get the absolute path for + * the base directory that should be to get the absolute path for * @param path * the path to get the absolute path for * diff --git a/src/main/java/edu/hm/hafner/util/SecureXmlParserFactory.java b/src/main/java/edu/hm/hafner/util/SecureXmlParserFactory.java index 408b3b14..7bbba769 100644 --- a/src/main/java/edu/hm/hafner/util/SecureXmlParserFactory.java +++ b/src/main/java/edu/hm/hafner/util/SecureXmlParserFactory.java @@ -292,7 +292,7 @@ public void parse(final Reader reader, final Charset charset, final DefaultHandl * @param charset * the charset to use when reading the content * - * @return the file content as document + * @return the file content as a document * @throws ParsingException * if the file could not be parsed */ @@ -306,8 +306,10 @@ public Document readDocument(final Reader reader, final Charset charset) { } } - private InputSource createInputSource(final Reader reader, final Charset charset) { - return new InputSource(new ReaderInputStream(reader, charset)); + private InputSource createInputSource(final Reader reader, final Charset charset) throws IOException { + var inputStream = ReaderInputStream.builder().setReader(reader).setCharset(charset).get(); + + return new InputSource(inputStream); } /** diff --git a/src/main/java/edu/hm/hafner/util/TreeStringBuilder.java b/src/main/java/edu/hm/hafner/util/TreeStringBuilder.java index 8f399c7f..5169bbf5 100644 --- a/src/main/java/edu/hm/hafner/util/TreeStringBuilder.java +++ b/src/main/java/edu/hm/hafner/util/TreeStringBuilder.java @@ -6,7 +6,7 @@ /** * Builds {@link TreeString}s that share common prefixes. Call {@link #intern(String)} and you get the {@link - * TreeString} that represents the same string, but as you interns more strings that share the same prefixes, those + * TreeString} that represents the same string, but as you intern more strings that share the same prefixes, those * {@link TreeString}s that you get back start to share data. * *

From 063b5d8e2726c9f5cb887a346fd9de113eff43ff Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Wed, 31 Jul 2024 13:20:10 +0200 Subject: [PATCH 3/5] Improve UML legend. --- doc/uml/sequence-diagram.puml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/uml/sequence-diagram.puml b/doc/uml/sequence-diagram.puml index f16d521c..e6dd5493 100644 --- a/doc/uml/sequence-diagram.puml +++ b/doc/uml/sequence-diagram.puml @@ -24,7 +24,7 @@ skinparam actor { BackgroundColor<

> gold BorderColor black ArrowColor black - FontName Arial Unicode MS + FontName Arial Unicode MS FontSize 20 LifeLineBorderColor black @@ -50,6 +50,7 @@ participant "blau:ZweiteKlasse" as blau activate unnamed Akteur -> unnamed: start(1, 3, 2) create rot + unnamed -->> rot : new unnamed -> rot: synchronerAufruf({1, 3, 2}) activate rot From 700343fb6dccc4ec875aaf28abe0a19cd93e4c81 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Wed, 31 Jul 2024 15:26:04 +0200 Subject: [PATCH 4/5] Fix docker image permissions for .m2 folder. --- bin/jenkins.sh | 17 ++++++++++------- docker-compose.yaml | 11 +++++++++-- docker/images/java-agent/Dockerfile | 5 ++++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/bin/jenkins.sh b/bin/jenkins.sh index d9b691e4..0cd2d4c9 100755 --- a/bin/jenkins.sh +++ b/bin/jenkins.sh @@ -1,12 +1,15 @@ -#!/bin/bash +# Make sure that docker runs with the current UID to avoid permission problems on volume docker/volumes/jenkins-home +CURRENT_UID="$(id -u)" +export CURRENT_UID -docker pull jenkins/jenkins:lts-jdk21 +CURRENT_GID="$(id -g)" +export CURRENT_GID -docker compose build --pull +CURRENT_USER="$(id -u):$(id -g)" +export CURRENT_USER -# Make sure that docker runs with the current UID to avoid permission problems on volume docker/volumes/jenkins-home -CURRENT_UID="$(id -u):$(id -g)" -export CURRENT_UID -echo Running docker compose with user ID $CURRENT_UID +echo Running docker compose with user ID $CURRENT_USER +docker pull jenkins/jenkins:lts-jdk21 +docker compose build --pull docker compose up --always-recreate-deps diff --git a/docker-compose.yaml b/docker-compose.yaml index a2df4ec5..02db2e59 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,6 +5,9 @@ services: container_name: codingstyle-jenkins build: context: docker/images/jenkins-controller + args: + - uid=${CURRENT_UID} + - gid=${CURRENT_GID} image: codingstyle/jenkins-controller volumes: - ./docker/volumes/jenkins-home:/var/jenkins_home # Mounts the local jenkins_home volume to the /var/jenkins_home path inside the container @@ -14,7 +17,7 @@ services: environment: - TRY_UPGRADE_IF_NO_MARKER=true - JAVA_OPTS= -Dstapler.jelly.noCache=true -Dhudson.remoting.ClassFilter=com.google.common.collect.ImmutableListMultimap -DexecutableWar.jetty.disableCustomSessionIdCookieName=true -DexecutableWar.jetty.sessionIdCookieName=codingstyle - user: ${CURRENT_UID} + user: ${CURRENT_USER} restart: unless-stopped depends_on: key-generator: @@ -47,7 +50,11 @@ services: java-agent: container_name: codingstyle-java-agent - build: docker/images/java-agent + build: + context: docker/images/java-agent + args: + - uid=${CURRENT_UID} + - gid=${CURRENT_GID} image: codingstyle/java-agent depends_on: key-generator: diff --git a/docker/images/java-agent/Dockerfile b/docker/images/java-agent/Dockerfile index 2bb4ad6f..45553a68 100644 --- a/docker/images/java-agent/Dockerfile +++ b/docker/images/java-agent/Dockerfile @@ -24,4 +24,7 @@ RUN curl -sS -L -O --output-dir /tmp/ --create-dirs https://archive.apache.org/ export PATH=${M2_HOME}/bin:${PATH}" > /etc/profile.d/maven.sh ENV M2_HOME="/opt/maven" ENV PATH="${M2_HOME}/bin/:${PATH}" -RUN echo "PATH=${PATH}" >> /etc/environment && chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}" + +RUN echo "PATH=${PATH}" >> /etc/environment && \ + mkdir -pv "${JENKINS_AGENT_HOME}/.m2/repository" && \ + chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}" From 894522ac1d43f57e6e74500fa268f78c3f24f8af Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Tue, 6 Aug 2024 15:24:11 +0200 Subject: [PATCH 5/5] Do not use a volume for .m2. --- docker-compose.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 02db2e59..810e15bd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,8 +6,8 @@ services: build: context: docker/images/jenkins-controller args: - - uid=${CURRENT_UID} - - gid=${CURRENT_GID} + - CURRENT_UID=${CURRENT_UID} + - CURRENT_GID=${CURRENT_GID} image: codingstyle/jenkins-controller volumes: - ./docker/volumes/jenkins-home:/var/jenkins_home # Mounts the local jenkins_home volume to the /var/jenkins_home path inside the container @@ -53,8 +53,8 @@ services: build: context: docker/images/java-agent args: - - uid=${CURRENT_UID} - - gid=${CURRENT_GID} + - CURRENT_UID=${CURRENT_UID} + - CURRENT_GID=${CURRENT_GID} image: codingstyle/java-agent depends_on: key-generator: @@ -70,7 +70,6 @@ services: retries: 5 volumes: - agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only - - ${HOME}/.m2/repository:/home/jenkins/.m2/repository # Mounts the local Maven repository to the /home/jenkins/.m2 path inside the container volumes: agent-ssh-dir: