diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 871f5e7f4abe076c9bfed43e55edc3abaf932539..8112c4edd5e95dfd2699674fd275ae33082385db 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,8 +5,8 @@ stages: # List of stages for jobs, and their order of execution variables: EXLIBRIS_SDK_DIR: "/exlibris" - ROSETTASDK: "${EXLIBRIS_SDK_DIR}/8.1/lib/" - IMAGE_TARGET: "${HARBOR_HOST}/${HARBOR_PROJECT}/bookworm_${HARBOR_PROJECT}" + ROSETTASDK: "${EXLIBRIS_SDK_DIR}/8.2/" + IMAGE_TARGET: "$CI_REGISTRY_IMAGE/bullseye_subapp" FF_USE_FASTZIP: "true" # These can be specified per job or per pipeline ARTIFACT_COMPRESSION_LEVEL: "fast" @@ -35,7 +35,7 @@ build-env-job: # This job runs in the build stage, which runs first. # docu: https://docs.gitlab.com/ee/ci/docker/using_kaniko.html, this is basically copy-pasted from there script: - mkdir -p /kaniko/.docker - - echo -n "{\"auths\":{\"${HARBOR_HOST}\":{\"auth\":\"$(echo -n ${HARBOR_USERNAME}:${HARBOR_PASSWORD} | base64 -w0)\"}}}" > /kaniko/.docker/config.json + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(printf "%s:%s" "$CI_REGISTRY_USER" "$CI_REGISTRY_PASSWORD" | base64 | tr -d '\n')\"},\"$(printf "%s" "$CI_DEPENDENCY_PROXY_SERVER" | cut -d':' -f1)\":{\"auth\":\"$(printf "%s:%s" "$CI_DEPENDENCY_PROXY_USER" "$CI_DEPENDENCY_PROXY_PASSWORD" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json # In this task, Kaniko executor is called to build the Image based on the Dockerfile provided with "--dockerfile". - echo "CI_PROJECT_DIR=${CI_PROJECT_DIR}" - >- @@ -47,7 +47,7 @@ build-env-job: # This job runs in the build stage, which runs first. --cache=true --cache-repo=${CI_REGISTRY_IMAGE} --cache-copy-layers=true - --snapshot-mode=redo + --snapshotMode=redo --use-new-run --ignore-var-run @@ -57,9 +57,15 @@ test-job: tags: - "docker" script: - - ls -lha /exlibris/ - - ROSETTASDK=$ROSETTASDK make -e check_prerequisites - - ROSETTASDK=$ROSETTASDK make -e test + - ROSETTASDK=$ROSETTASDK mvn test + +bughunting-job: + stage: test + timeout: 3h + tags: + - "docker" + script: + - ROSETTASDK=$ROSETTASDK mvn spotbugs:check packaging-job: stage: packaging @@ -67,10 +73,10 @@ packaging-job: tags: - "docker" script: - - ROSETTASDK=$ROSETTASDK make -e + - ROSETTASDK=$ROSETTASDK mvn install artifacts: paths: - - ./*.jar + - target/*.jar include: - template: Security/Secret-Detection.gitlab-ci.yml diff --git a/Makefile b/Makefile deleted file mode 100644 index 673b13cc9531c93a9bf1af89f5dc4e397e3e6674..0000000000000000000000000000000000000000 --- a/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -# Andreas Romeyke, SLUB Dresden -# erzeugt Submission-Application, die vorbereitete Verzeichnisse per Java SDK -# von ExLibris an Rosetta übergibt. - -# Pfad zu Java -JAVAPATH=$(wildcard /usr/lib/jvm/java-1.17.0-openjdk-*/bin/) -JAVARELEASE=17 - -# Verwendete Rosetta-Version -ROSETTAVERSION:=8.1.0 - -# Pfad zum Rosetta-SDK -ROSETTASDK:=/exlibris/dps/d4_1/system.dir/dps-sdk-${ROSETTAVERSION}/lib/ -# Pfad zum Rosetta-SDK, Deposit-Module -ROSETTASDKDEPOSIT:=${ROSETTASDK}/../dps-sdk-projects/dps-sdk-deposit/lib -ROSETTASDKPLUGINS:=${ROSETTASDK}/../../bundled_plugins/ -ROSETTASDKJARS=$(shell find ${ROSETTASDKDEPOSIT} -name "*.jar") - -# classpath -JUNITCLASSPATH:=./java/:/usr/share/java/junit4.jar:/usr/share/java/spring3-beans-3.x.jar:/usr/share/java/spring3-core-3.x.jar:$(shell find ${ROSETTASDKDEPOSIT} -name "*.jar" -print |xargs echo |sed -e "s/ /:/g") -CLASSPATH:=${ROSETTASDKDEPOSIT}/dps-sdk-${ROSETTAVERSION}.jar - -# sources -SOURCES:=java/org/slub/rosetta/dps/repository/plugin/storage/nfs/SLUBStoragePlugin.java java/org/slub/rosetta/dps/repository/plugin/storage/nfs/TestSLUBStoragePlugin.java -OBJS:=$(SOURCES:.java=.class) -JAR:=SLUBStoragePlugin.jar -BUILD:=build/ - -all: $(BUILD) $(JAR) - -help: - @echo "erzeugt Storage-Plugin für Rosetta von Exlibris" - @echo "" - @echo "Das Argument 'clean' löscht temporäre Dateien, 'help' gibt diese Hilfe aus und" - @echo "'all' erzeugt ein JAR-File und ein Bash-Script welches das Java-Programm" - @echo "aufruft." - -jarclean: - @rm -Rf $(BUILD) - -test: $(OBJS) - java -Dfile.encoding=UTF-8 -cp ${CLASSPATH}:$(JUNITCLASSPATH) org.junit.runner.JUnitCore org.slub.rosetta.dps.repository.plugin.storage.nfs.TestSLUBStoragePlugin - -clean: jarclean - @rm -Rf doc/ - find ./java/org/ -name "*.class" -exec rm -f \{\} \; - @rm -Rf $(JAR) - -distclean: clean - find ./ -name "*~" -exec rm -f \{\} \; - @rm -Rf null - -$(BUILD): - @mkdir $@; - @mkdir $@/lib - -$(JAR): $(OBJS) - @cp -r PLUGIN-INF/ $(BUILD) - @cp -r META-INF/ $(BUILD) - @cd java; find ./ -name "*.class" -print -exec cp --parents -r \{\} $(PWD)/$(BUILD) \; ; cd .. - @cd $(BUILD); ${JAVAPATH}/jar cfvM ../$@ ./* ; cd .. - -%.class: %.java - ${JAVAPATH}/javac --release ${JAVARELEASE} -g -classpath ${CLASSPATH}:${JUNITCLASSPATH} -Xlint:all $< - -doc: $(SOURCES) - javadoc -d doc/ $^ - -check_prerequisites: - @echo -n "### Checking java path: $(JAVAPATH) ...." - @if [ -e $(JAVAPATH) ]; then echo "fine :)"; else echo " not found! :("; fi - @echo -n "### Checking Exlibris Rosetta SDK path: $(ROSETTASDK) ...." - @if [ -e $(ROSETTASDK) ]; then echo "fine :)"; else echo " not found! :("; fi - -.PHONY: help clean distclean jarclean test diff --git a/gitlab-ci/Dockerfile b/gitlab-ci/Dockerfile index f2f449488b7f5082de6fc8d48003e54c1c936065..15d616ea3dbf220b9325c0dc100ac420e79337a8 100644 --- a/gitlab-ci/Dockerfile +++ b/gitlab-ci/Dockerfile @@ -1,4 +1,4 @@ -FROM sdvharbor.slub-dresden.de/replication/debian:bookworm-slim +FROM git.slub-dresden.de/digital-preservation/dependency_proxy/containers/debian:bullseye-slim ARG GITDIR ENV DEBIAN_FRONTEND=noninteractive @@ -6,28 +6,21 @@ ENV EXLIBRIS_REPO=https://github.com/ExLibrisGroup/Rosetta.dps-sdk-projects.git ENV EXLIBRIS_REPODIR=Rosetta.dps-sdk-projects ENV EXLIBRIS_PATH=/exlibris +ARG CACHEBUST=1 RUN apt-get update; \ - apt-get install -y --no-install-recommends gnupg wget locales; \ + apt-get install -y --no-install-recommends gnupg wget; \ wget -O - http://sdvdebianrepo.slub-dresden.de/deb-repository/pub.gpg.key | apt-key add - ; \ - echo "deb http://sdvdebianrepo.slub-dresden.de/deb-repository bookworm main" > /etc/apt/sources.list.d/slub.list; - -RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ - locale-gen -ENV LANG=en_US.UTF-8 -ENV LANGUAGE=en_US:en -ENV LC_ALL=en_US.UTF-8 + echo "deb http://sdvdebianrepo.slub-dresden.de/deb-repository bullseye main" > /etc/apt/sources.list.d/slub.list; RUN apt-get update; \ apt-get -y upgrade; \ apt-get install -y \ apt-file \ apt-utils \ - make \ openjdk-17-jdk \ junit4 \ - libspring-beans-java \ - libspring-core-java \ git \ + maven \ ; RUN apt-file update; RUN git clone https://github.com/ExLibrisGroup/Rosetta.dps-sdk-projects.git diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..7582fbb2cca5196bd5f6c3215a61d390518c90a7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +<modelVersion>4.0.0</modelVersion> +<groupId>org.slub.rosetta.dps.repository.plugin</groupId> +<artifactId>SLUBStoragePlugin</artifactId> +<version>2.99</version> +<description>Plugin to organize permanent storage structure in a format like "/yyyy/mm/dd/IEPID/", + used for ExlibrisGroup`s Rosetta archival information system</description> +<build> + <testResources> + <testResource> + <directory>${project.basedir}/resources/</directory> + </testResource> + </testResources> + <sourceDirectory>src/main/java/</sourceDirectory> + <testSourceDirectory>src/test/java/</testSourceDirectory> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <configuration> + <outputDirectory>${project.build.outputDirectory}/PLUGIN-INF/</outputDirectory> + <resources> + <resource> + <directory>${project.basedir}/PLUGIN-INF/</directory> + </resource> + </resources> + </configuration> + </plugin> + + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <phase>prepare-package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> + <!-- <includeGroupIds>org.verapdf,org.mozilla</includeGroupIds> --> + <excludeGroupId>com.exlibris</excludeGroupId> + <excludeGroupId>org.apache.commons</excludeGroupId> + </configuration> + </execution> + </executions> + </plugin> + +<!-- + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>lib/</classpathPrefix> + <mainClass>org.slub.rosetta.dps.repository.plugin.SLUBPDFAFormatValdiationPlugin</mainClass> + </manifest> + </archive> + </configuration> + </plugin> + --> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>4.9.3.0</version> + <dependencies> + <!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs --> + <dependency> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs</artifactId> + <version>4.9.3</version> + </dependency> + </dependencies> + <configuration> + <includeFilterFile>spotbugs-include.xml</includeFilterFile> + <excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile> + </configuration> + </plugin> + + </plugins> +</build> +<properties> + <maven.compiler.source>17</maven.compiler.source> + <maven.compiler.target>17</maven.compiler.target> +</properties> + +<dependencies> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.24.3</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.exlibris</groupId> + <artifactId>core</artifactId> + <version>8.2.0</version> + <scope>system</scope> + <systemPath>${ROSETTASDK}/lib/dps-sdk-8.2.0.jar</systemPath> + </dependency> + <!-- test --> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + <scope>system</scope> + <systemPath>${ROSETTASDK}/dps-sdk-projects/dps-sdk-deposit/lib/commons-lang-2.6.jar</systemPath> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.9</version> + <scope>test</scope> + <type>jar</type> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>3.2.18.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>3.2.18.RELEASE</version> + </dependency> +</dependencies> +</project> diff --git a/spotbugs_exclude.xml b/spotbugs_exclude.xml new file mode 100644 index 0000000000000000000000000000000000000000..67289ab28a416473d59a8b4ae460fcfb3a4f1550 --- /dev/null +++ b/spotbugs_exclude.xml @@ -0,0 +1,7 @@ +<FindBugsFilter> + <Match> + <Bug category="EXPERIMENTAL"/> + <Bug category="BAD_PRACTICE"/> + <Bug category="STYLE"/> + </Match> +</FindBugsFilter> diff --git a/spotbugs_include.xml b/spotbugs_include.xml new file mode 100644 index 0000000000000000000000000000000000000000..0c7189cec562824217b65f8655e35ae7fd9d97d5 --- /dev/null +++ b/spotbugs_include.xml @@ -0,0 +1,7 @@ +<FindBugsFilter> + <Match> + <Bug category="SECURITY"/> + <Bug category="CORRECTNESS"/> + <Bug category="PERFORMANCE"/> + </Match> +</FindBugsFilter>