diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..07764a7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=lf \ No newline at end of file diff --git a/.gitignore b/.gitignore index b0d4fc1..23b183e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ # Log file *.log -.idea #*.iml # Package Files # @@ -35,9 +34,22 @@ src/generated .project .classpath .factorypath -.settings +.idea/ +.settings/ +.externalToolBuilders/ .vscode *.code-workspace - +*.xpr # Testing stuff xrechnung + +# Mac stuff +.DS_Store +andre*-simple.xml +somePrefix*.xml +zz + +# 2.0 stuff +api/ +cli/ +core/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 039bbdd..75032c2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,48 +1,31 @@ image: maven:latest - + variables: - BUILD_PROPS: "-Dbuild.revision=$CI_COMMIT_SHA -Dbuild.branch=$CI_COMMIT_REF_NAME -Dbuild.number=$CI_PIPELINE_IID " - MAVEN_CLI_OPTS: " --batch-mode -Dmaven.repo.local=/cache/repository -Dfile.encoding=UTF-8" + BUILD_PROPS: "-Dbuild.revision=$CI_COMMIT_SHA -Dbuild.branch=$CI_COMMIT_REF_NAME -Dbuild.number=$CI_PIPELINE_IID -Dfile.encoding=UTF-8 -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false" + MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true -Xmx6g" + MAVEN_CLI_OPTS: " --batch-mode --update-snapshots --errors --fail-at-end --show-version -s .mvn/settings.xml" + MAVEN_CLI_OPTS_CENTRAL: " --batch-mode --show-version -s .mvn/settings-maven-central.xml" before_script: - export CI_JOB_TIMESTAMP="-Dbuild.timestamp=$(date --utc --iso-8601=seconds)" -build-amazoncorretto: - stage: build - image: maven:amazoncorretto - script: - - mvn $MAVEN_CLI_OPTS $BUILD_PROPS $CI_JOB_TIMESTAMP verify - artifacts: - name: amazoncorretto - paths: - - target/*.jar - reports: - junit: - - target/surefire-reports/*.xml - - target/failsafe-reports/*.xml +cache: +# Change the cache key if major dependencies change + key: constant160 + paths: + - .m2/repository -build-java-14: +# Basic Java build steps +.java: stage: build - image: maven:3-jdk-14 + needs: + - job: java-11 + artifacts: false script: - mvn $MAVEN_CLI_OPTS $BUILD_PROPS $CI_JOB_TIMESTAMP verify artifacts: + name: artifacts when: on_failure - name: java-14 - paths: - - target/* - reports: - junit: - - target/surefire-reports/*.xml - - target/failsafe-reports/*.xml - -build-java-11-openj9: - stage: build - image: maven:3-jdk-11-openj9 - script: - - mvn $MAVEN_CLI_OPTS $BUILD_PROPS $CI_JOB_TIMESTAMP verify - artifacts: - name: java-11-openj9 paths: - target/*.jar reports: @@ -50,13 +33,15 @@ build-java-11-openj9: - target/surefire-reports/*.xml - target/failsafe-reports/*.xml -build-java-11: - stage: build - image: maven:3-jdk-11 +java-11: + extends: .java + image: maven:3-eclipse-temurin-11-alpine + needs: [ ] script: - - mvn $MAVEN_CLI_OPTS $BUILD_PROPS $CI_JOB_TIMESTAMP verify + - mvn $MAVEN_CLI_OPTS $BUILD_PROPS $CI_JOB_TIMESTAMP install artifacts: name: java-11 + when: always paths: - target/*.jar - target/*.zip @@ -65,30 +50,86 @@ build-java-11: - target/surefire-reports/*.xml - target/failsafe-reports/*.xml -build-java-8-openj9: - stage: build - image: maven:3-jdk-8-openj9 - script: - - mvn $MAVEN_CLI_OPTS $BUILD_PROPS $CI_JOB_TIMESTAMP verify - artifacts: - name: java-8-open-j9 - paths: - - target/*.jar - reports: - junit: - - target/surefire-reports/*.xml - - target/failsafe-reports/*.xml +java-17: + extends: .java + image: maven:3-eclipse-temurin-17-alpine -build-java8: - stage: build - image: maven:3-jdk-8-alpine +java-21: + extends: .java + image: maven:3-eclipse-temurin-21-alpine + +java-25: + extends: .java + image: maven:3-eclipse-temurin-25-alpine + +# Rare Java stuff +.java_extended: + extends: .java + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" + +# Note: the openj9 images don't exist for Java 17, 21 or 25 +# Removed because the latest public image is 11.0.11 which is not comaptible to the Lombok requirement of 11.0.23 +#java-11-openj9: +# extends: .java_extended +# image: maven:3-jdk-11-openj9 + +# Deploy Java 11 build on Maven Central +deploy-java-11-snapshot: + extends: java-11 script: - - mvn $MAVEN_CLI_OPTS $BUILD_PROPS $CI_JOB_TIMESTAMP verify + - mvn $MAVEN_CLI_OPTS_CENTRAL -P release-snapshot deploy + +# Deploy Java 11 build to KoSIT repository (manually) +deploy: + stage: deploy + image: maven:3-eclipse-temurin-11-alpine + needs: + - job: java-11 + script: + - export PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + - mvn $MAVEN_CLI_OPTS deploy:deploy-file -Dfile=target/validator-${PROJECT_VERSION}.zip -DgroupId=kosit -DartifactId=validator -Dversion=${PROJECT_VERSION} -Dclassifier="distribution" -Dpackaging=zip -DrepositoryId="gitlab-maven" -Durl=https://projekte.kosit.org/api/v4/projects/7/packages/maven + - mvn $MAVEN_CLI_OPTS deploy:deploy-file -Dfile=target/validator-${PROJECT_VERSION}.jar -DgroupId=kosit -DartifactId=validator -Dversion=${PROJECT_VERSION} -Dpackaging=jar -DrepositoryId="gitlab-maven" -Durl=https://projekte.kosit.org/api/v4/projects/7/packages/maven + - mvn $MAVEN_CLI_OPTS deploy:deploy-file -Dfile=target/validator-${PROJECT_VERSION}-javadoc.jar -DgroupId=kosit -DartifactId=validator -Dversion=${PROJECT_VERSION} -Dclassifier="javadoc" -Dpackaging=zip -DrepositoryId="gitlab-maven" -Durl=https://projekte.kosit.org/api/v4/projects/7/packages/maven + - mvn $MAVEN_CLI_OPTS deploy:deploy-file -Dfile=target/validator-${PROJECT_VERSION}-standalone.jar -DgroupId=kosit -DartifactId=validator -Dversion=${PROJECT_VERSION} -Dclassifier="standalone" -Dpackaging=jar -DrepositoryId="gitlab-maven" -Durl=https://projekte.kosit.org/api/v4/projects/7/packages/maven + - mvn $MAVEN_CLI_OPTS deploy:deploy-file -Dfile=target/validator-${PROJECT_VERSION}-sources.jar -DgroupId=kosit -DartifactId=validator -Dversion=${PROJECT_VERSION} -Dclassifier="sources" -Dpackaging=jar -DrepositoryId="gitlab-maven" -Durl=https://projekte.kosit.org/api/v4/projects/7/packages/maven + when: manual + +# Build Docker images and upload to KoSIT registry +create-build-image: + stage: deploy + image: docker:latest + needs: [ ] + services: + - docker:dind + script: + - apk add bash + - bash .mvn/createBuildImages.sh + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" + - if: $CI_COMMIT_REF_NAME == "main" + changes: + - .mvn/createBuildImages.sh + +# Run OWASP checks - expensive so only on main branch +owasp-check: + stage: test + image: maven:3-eclipse-temurin-21-alpine + needs: [ ] + # set job timeout to 1 hour - it's required when new rules are downloaded + timeout: 1h + variables: + RUNNER_SCRIPT_TIMEOUT: 1h + script: + - mvn $MAVEN_CLI_OPTS $BUILD_PROPS $CI_JOB_TIMESTAMP validate -Powasp-check artifacts: - name: java-8-alpine - paths: - - target/*.jar + name: artifacts reports: - junit: - - target/surefire-reports/*.xml - - target/failsafe-reports/*.xml + codequality: + - target/dependency-check-report.html + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" + - if: $CI_COMMIT_REF_NAME == "main" + changes: + - pom.xml + - owasp-suppressions.xml diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml deleted file mode 100644 index ef7efd6..0000000 --- a/.idea/checkstyle-idea.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index bea581f..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/KoSIT_Validator.xml b/.idea/copyright/KoSIT_Validator.xml deleted file mode 100644 index 114e72d..0000000 --- a/.idea/copyright/KoSIT_Validator.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index bc6a0ba..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/eclipseCodeFormatter.xml b/.idea/eclipseCodeFormatter.xml deleted file mode 100644 index a63598c..0000000 --- a/.idea/eclipseCodeFormatter.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 893896a..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 241632b..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/saveactions_settings.xml b/.idea/saveactions_settings.xml deleted file mode 100644 index 3b2acd8..0000000 --- a/.idea/saveactions_settings.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.mvn/createBuildImages.sh b/.mvn/createBuildImages.sh new file mode 100644 index 0000000..e29998b --- /dev/null +++ b/.mvn/createBuildImages.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# +# Copyright 2017-2022 Koordinierungsstelle für IT-Standards (KoSIT) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +TAGS=("3-jdk-8" "3-jdk-8-openj9" "3-eclipse-temurin-11-alpine" "3-jdk-11-openj9" "3-eclipse-temurin-17-alpine" "3-eclipse-temurin-21-alpine" "3-eclipse-temurin-24-alpine") + +docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY" +for i in "${TAGS[@]}" +do + echo Creating build image for "$i" + { + echo "FROM maven:${i}" + } >>Dockerfile + docker build -t "$CI_REGISTRY_IMAGE/maven:$i" . + docker push "$CI_REGISTRY_IMAGE/maven:${i}" + rm Dockerfile +done \ No newline at end of file diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 0000000..883d916 --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1 @@ +-Xms128m -Xmx256m \ No newline at end of file diff --git a/.mvn/settings-maven-central.xml b/.mvn/settings-maven-central.xml new file mode 100644 index 0000000..30b15c3 --- /dev/null +++ b/.mvn/settings-maven-central.xml @@ -0,0 +1,11 @@ + + + + central + ${MVN_CENTRAL_USER} + ${MAVEN_CENTRAL_TOKEN} + + + diff --git a/.mvn/settings.xml b/.mvn/settings.xml new file mode 100644 index 0000000..0b53a90 --- /dev/null +++ b/.mvn/settings.xml @@ -0,0 +1,17 @@ + + + + gitlab-maven + + + + Job-Token + ${env.CI_JOB_TOKEN} + + + + + + \ No newline at end of file diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 16bf637..0000000 --- a/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,127 +0,0 @@ -cleanup.add_default_serial_version_id=false -cleanup.add_generated_serial_version_id=true -cleanup.add_missing_annotations=true -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=false -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_missing_override_annotations_interface_methods=true -cleanup.add_serial_version_id=false -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=true -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_functional_interfaces=false -cleanup.convert_to_enhanced_for_loop=true -cleanup.correct_indentation=false -cleanup.format_source_code=true -cleanup.format_source_code_changes_only=false -cleanup.insert_inferred_type_arguments=false -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=true -cleanup.make_private_fields_final=true -cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=true -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=true -cleanup.organize_imports=true -cleanup.qualify_static_field_accesses_with_declaring_class=false -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=true -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_redundant_type_arguments=true -cleanup.remove_trailing_whitespaces=true -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_trailing_whitespaces_ignore_empty=false -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=true -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=false -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=false -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=false -cleanup.sort_members_all=false -cleanup.use_anonymous_class_creation=false -cleanup.use_blocks=true -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_lambda=true -cleanup.use_parentheses_in_expressions=true -cleanup.use_this_for_non_static_field_access=true -cleanup.use_this_for_non_static_field_access_only_if_necessary=false -cleanup.use_this_for_non_static_method_access=true -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup.use_type_arguments=false -cleanup_profile=_initCleanUpProfile -cleanup_settings_version=2 -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_initFormatterProfile -formatter_settings_version=12 -org.eclipse.jdt.ui.ignorelowercasenames=true -org.eclipse.jdt.ui.importorder=java;javax;org;com;lombok;de; -org.eclipse.jdt.ui.javadoc=true -org.eclipse.jdt.ui.ondemandthreshold=99 -org.eclipse.jdt.ui.staticondemandthreshold=99 -org.eclipse.jdt.ui.text.custom_code_templates=