diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 67eb4f0..811ae91 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,20 +1,55 @@
-Create Application:
+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 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 asciidoctor
- artifacts:
- paths:
- - build/docs/asciidocPdf/generations.pdf
+ script: ./gradlew asciidoctorPdf
-Build Library:
- stage: build
- script:
- - chmod +x gradlew
- - ./gradlew publish
+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 ebfa85b..ebe3725 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,40 +1,75 @@
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'
- id 'java'
id 'maven-publish'
}
-description = 'Anwendung Generations'
-group = 'de.thpeetz.generations'
-
-repositories {
+repositories {
jcenter()
ruby.gems()
+ mavenLocal()
+ mavenCentral()
maven {
url "https://gitlab.thpeetz.de/api/v4/packages/maven"
name "GitLab"
}
}
-build.dependsOn(['asciidoctor'])
-
dependencies {
asciidoctorGems 'rubygems:rouge:3.15.0'
- implementation 'org.slf4j:slf4j-api:1.7.22'
- testImplementation 'junit:junit:4.12'
+ implementation 'org.slf4j:slf4j-api:1.7.30'
testImplementation 'org.mockito:mockito-all:1.9.5'
+ testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
+ implementation 'ch.qos.logback:logback-core:1.2.6'
+ implementation 'ch.qos.logback:logback-classic:1.2.6'
}
+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'
+
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
@@ -46,12 +81,8 @@ publishing {
}
}
-final BUILD_DATE = new Date().format('dd.MM.yyyy').toString()
-
-jar {
- manifest {
- attributes 'Implementation-Title': 'Generations', 'Implementation-Version': version
- }
+application {
+ mainClassName = MAIN_CLASS_NAME
}
java {
@@ -59,31 +90,84 @@ java {
targetCompatibility = JavaVersion.VERSION_1_8
}
+jar {
+ manifest {
+ attributes('Implementation-Title': 'Versabundus Application', 'Implementation-Version': version, 'Main-Class': MAIN_CLASS_NAME)
+ }
+}
+
+tasks.named('test') {
+ useJUnitPlatform()
+}
+
+jacocoTestReport {
+ reports {
+ xml.enabled true
+ }
+}
+
+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", "tpeetz_generations_AYB--ei2Uw4Nr911AV3u"
+ property "sonar.host.url", "https://sonar.thpeetz.de"
+ property "sonar.login", "92ff8e7c02747a905df2c49de874ce3db001bd37"
+ property "sonar.qualitygate.wait", true
+ property "sonar.sourceEncoding", "UTF-8"
+ }
+}
+
+tasks.named('sonarqube').configure {
+ dependsOn test
+}
+
asciidoctorPdf {
dependsOn asciidoctorGemsPrepare
+
baseDirFollowsSourceFile()
asciidoctorj {
requires 'rouge'
- attributes 'build-gradle': file('build.gradle'),
- 'endpoint-url': 'http://www.thpeetz.de',
- 'source-highlighter': 'rouge',
- 'revdate': BUILD_DATE,
- 'revnumber': '1.0.0',
- 'revremark': 'Entwurf',
- 'imagesdir': './images',
- 'toc': 'left',
- 'toc-title': 'Inhaltsverzeichnis',
- 'chapter-label': '',
- 'icons': 'font',
- 'idprefix': 'id_',
- 'idseparator': '-',
- 'docinfo1': ''
+ attributes 'build-gradle': file('build.gradle'),
+ 'endpoint-url': 'https://www.thpeetz.de',
+ 'source-highlighter': 'rouge',
+ 'imagesdir': './images',
+ 'toc': 'left',
+ 'toc-title': 'Inhaltsverzeichnis',
+ 'revdate': BUILD_DATE,
+ '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 8d0c7be..318da58 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1 +1,5 @@
+description = 'Anwendung Generations'
+group=de.thpeetz.generations
version=1.0.0-SNAPSHOT
+gitLabPrivateToken=bFcsw1ebNhoFgKysksU1
+projectId=27
diff --git a/src/docs/asciidoc/generations.adoc b/src/docs/asciidoc/Pflichtenheft.adoc
similarity index 100%
rename from src/docs/asciidoc/generations.adoc
rename to src/docs/asciidoc/Pflichtenheft.adoc
diff --git a/src/main/java/de/thpeetz/generations/App.java b/src/main/java/de/thpeetz/generations/App.java
new file mode 100644
index 0000000..cadef61
--- /dev/null
+++ b/src/main/java/de/thpeetz/generations/App.java
@@ -0,0 +1,33 @@
+package de.thpeetz.generations;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Example App class.
+ * @author tpeetz
+ *
+ */
+public class App {
+
+ /**
+ * Standard logger.
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(App.class);
+
+ /**
+ * Returns greeting.
+ * @return greeting
+ */
+ public String getGreeting() {
+ return "Hello world.";
+ }
+
+ /**
+ * Main entry point for application Generations.
+ * @param args Arguments
+ */
+ public static void main(final String[] args) {
+ LOG.info("Greeting {}", new App().getGreeting());
+ }
+}
diff --git a/src/main/java/de/thpeetz/generations/package-info.java b/src/main/java/de/thpeetz/generations/package-info.java
new file mode 100644
index 0000000..da20ed5
--- /dev/null
+++ b/src/main/java/de/thpeetz/generations/package-info.java
@@ -0,0 +1,8 @@
+/**
+ * Domain classes used to implement application Generations.
+ *
+ * @author Thomas Peetz
+ * @since 1.0.0
+ * @version 1.0.0
+ */
+package de.thpeetz.generations;
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
new file mode 100644
index 0000000..14d6b6a
--- /dev/null
+++ b/src/main/resources/logback.xml
@@ -0,0 +1,11 @@
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
diff --git a/src/test/java/de/thpeetz/generations/AppTest.java b/src/test/java/de/thpeetz/generations/AppTest.java
new file mode 100644
index 0000000..b4c9388
--- /dev/null
+++ b/src/test/java/de/thpeetz/generations/AppTest.java
@@ -0,0 +1,36 @@
+/*
+ * This Java source file was generated by the Gradle 'init' task.
+ */
+package de.thpeetz.generations;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import org.junit.jupiter.api.Test;
+
+class AppTest {
+
+ @Test
+ void appHasAGreeting() {
+ App classUnderTest = new App();
+ assertNotNull(classUnderTest.getGreeting(),
+ "app should have a greeting");
+ }
+
+ @Test
+ void checkGreeting() {
+ App classUnderTest = new App();
+ assertEquals("Hello world.", classUnderTest.getGreeting());
+ }
+
+ @Test
+ void checkMainWithoutArguments() {
+ try {
+ String[] args = {};
+ App.main(args);
+ } catch (Exception e) {
+ fail("Exception thrown");
+ }
+ }
+}
diff --git a/src/test/java/de/thpeetz/generations/package-info.java b/src/test/java/de/thpeetz/generations/package-info.java
new file mode 100644
index 0000000..954fc70
--- /dev/null
+++ b/src/test/java/de/thpeetz/generations/package-info.java
@@ -0,0 +1,8 @@
+/**
+ * Test classes for application Generations.
+ *
+ * @author Thomas Peetz
+ * @since 1.0.0
+ * @version 1.0.0
+ */
+package de.thpeetz.generations;