diff --git a/.gitignore b/.gitignore index 67bcc2f..0183484 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ .gradle/ build/ +.settings/ +.project +.classpath +bin/ +.asciidoctorconfig.adoc diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8650b4e..68c4226 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,58 @@ -Create Application: +variables: + GRADLE_OPTS: "-Dorg.gradle.daemon=false" + +before_script: + - source "/home/gitlab-runner/.sdkman/bin/sdkman-init.sh" + - sdk u java 11.0.12-open + +stages: + - build + - test + - analysis + - publish + +Build Application: stage: build - script: - - chmod +x gradlew - - ./gradlew --no-daemon build + script: ./gradlew --build-cache build + cache: + key: "$CI_COMMIT_REF_NAME" + policy: push + paths: + - build + - .gradle Create Documentation: stage: build - script: - - chmod +x gradlew - - ./gradlew --no-daemon asciidoctor - artifacts: - paths: - - build/docs/asciidocPdf/*.pdf + script: ./gradlew asciidoctorPdf +Test Application: + stage: test + script: ./gradlew check + cache: + key: "$CI_COMMIT_REF_NAME" + policy: pull + paths: + - build + - .gradle + +sonarqube-check: + stage: analysis + variables: + SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache + GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task + cache: + key: "${CI_JOB_NAME}" + paths: + - .sonar/cache + script: ./gradlew sonarqube + allow_failure: true + +Publish Artifacts: + stage: publish + script: ./gradlew publish + cache: + key: "$CI_COMMIT_REF_NAME" + policy: pull + paths: + - build + - .gradle diff --git a/build.gradle b/build.gradle index 10b2fee..f1189cd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,9 @@ plugins { id 'application' id 'jacoco' + id 'checkstyle' + id 'pmd' + id "com.github.spotbugs" version "4.8.0" id "org.sonarqube" version "3.3" id 'org.asciidoctor.jvm.pdf' version '3.3.0' id 'org.asciidoctor.jvm.gems' version '3.3.0' @@ -27,15 +30,47 @@ dependencies { implementation 'ch.qos.logback:logback-classic:1.1.2' } +final BUILD_DATE = new Date().format('dd.MM.yyyy').toString() +def pdfFileEntwicklung = layout.buildDirectory.file("docs/asciidocPdf/Entwicklungshandbuch.pdf") +def pdfArtifactEntwicklung = artifacts.add('archives', pdfFileEntwicklung.get().asFile) { + type 'pdf' + builtBy asciidoctorPdf +} +def pdfFileProjekt = layout.buildDirectory.file("docs/asciidocPdf/Projekthandbuch.pdf") +def pdfArtifactProjekt = artifacts.add('archives', pdfFileProjekt.get().asFile) { + type 'pdf' + builtBy asciidoctorPdf +} +def pdfFilePflichtenheft = layout.buildDirectory.file("docs/asciidocPdf/Pflichtenheft.pdf") +def pdfArtifactPflichtenheft = artifacts.add('archives', pdfFilePflichtenheft.get().asFile) { + type 'pdf' + builtBy asciidoctorPdf +} + +final MAIN_CLASS_NAME = 'com.thpeetz.versabundus.VersabundusApp' +sourceCompatibility = 1.8 + publishing { publications { - library(MavenPublication) { + mavenEntwicklung(MavenPublication) { + artifactId = "Entwicklungshandbuch" + artifact pdfArtifactEntwicklung + } + mavenProjekt(MavenPublication) { + artifactId = "Projekthandbuch" + artifact pdfArtifactProjekt + } + mavenPflichtenheft(MavenPublication) { + artifactId = "Pflichtenheft" + artifact pdfArtifactPflichtenheft + } + application(MavenPublication) { from components.java } } repositories { maven { - url "https://gitlab.thpeetz.de/api/v4/projects/27/packages/maven" + url "https://gitlab.thpeetz.de/api/v4/projects/${projectId}/packages/maven" credentials(HttpHeaderCredentials) { name = "Private-Token" value = gitLabPrivateToken @@ -47,11 +82,6 @@ publishing { } } -final BUILD_DATE = new Date().format('dd.MM.yyyy').toString() -final MAIN_CLASS_NAME = 'com.thpeetz.versabundus.VersabundusApp' -group = 'de.thpeetz.versabundus' -sourceCompatibility = 1.8 - application { mainClassName = MAIN_CLASS_NAME } @@ -63,7 +93,7 @@ jar { } tasks.named('test') { - useJUnitPlatform() + useJUnitPlatform() } jacocoTestReport { @@ -72,13 +102,34 @@ jacocoTestReport { } } +spotbugs { + ignoreFailures = false + showStackTraces = true + showProgress = true + effort = 'default' + reportLevel = 'default' +} + +tasks.withType(Checkstyle) { + ignoreFailures = true + showViolations = false + reports { + xml.enabled true + } +} + +pmd { + ignoreFailures = true +} + + test.finalizedBy jacocoTestReport sonarqube { properties { -// property "sonar.projectKey", "kontor_kontor-java_AX-dd-w3rXuu6JVRvr_g" + property "sonar.projectKey", "tpeetz_versabundus_AYB03YW5uGIZKMqU5_es" property "sonar.host.url", "https://sonar.thpeetz.de" -// property "sonar.login", "d39622f640a91f501b1e8a73d7d78c4fc412fc98" + property "sonar.login", "2703febc0e07fc850e5494125c8774a1fe65a90a" property "sonar.qualitygate.wait", true property "sonar.sourceEncoding", "UTF-8" } @@ -88,26 +139,6 @@ tasks.named('sonarqube').configure { dependsOn test } -//tasks.withType(Checkstyle) { -// ignoreFailures = true -// showViolations = false -// configFile = rootProject.file("config/checkstyle/checkstyle.xml") -// reports { -// xml.enabled true -// } -//} - -//tasks.withType(FindBugs) { -// ignoreFailures = true -// reports { -// xml.enabled true -// } -//} - -//pmd { -// ignoreFailures = true -//} - asciidoctorPdf { dependsOn asciidoctorGemsPrepare @@ -122,18 +153,17 @@ asciidoctorPdf { 'toc': 'left', 'toc-title': 'Inhaltsverzeichnis', 'revdate': BUILD_DATE, - 'revnumber': '1.0.0', + 'revnumber': { project.version.toString() }, 'revremark': 'Entwurf', 'chapter-label': '', 'icons': 'font', 'idprefix': 'id_', 'idseparator': '-', 'docinfo1': '' - } + } } -task asciidoctor(dependsOn: asciidoctorPdf) -build.dependsOn(['asciidoctor']) +build.dependsOn(['asciidoctorPdf']) wrapper { gradleVersion = "6.3" diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000..b88ef28 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle.properties b/gradle.properties index cc27fbe..3faad39 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,5 @@ description = 'Application Versabundus' version=1.0.0-SNAPSHOT +group=de.htpeetz.versabundus +gitLabPrivateToken=bFcsw1ebNhoFgKysksU1 +projectId=28 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 87b738c..490fda8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradlew b/gradlew index af6708f..2fe81a7 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# 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 +# +# https://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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 0f8d593..9109989 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/src/docs/asciidoc/versabundus.adoc b/src/docs/asciidoc/Pflichtenheft.adoc similarity index 100% rename from src/docs/asciidoc/versabundus.adoc rename to src/docs/asciidoc/Pflichtenheft.adoc diff --git a/src/main/java/de/thpeetz/versabundus/VersabundusApp.java b/src/main/java/de/thpeetz/versabundus/VersabundusApp.java new file mode 100644 index 0000000..6eeeef1 --- /dev/null +++ b/src/main/java/de/thpeetz/versabundus/VersabundusApp.java @@ -0,0 +1,10 @@ +package de.thpeetz.versabundus; + +public class VersabundusApp { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +}