Merge branch 'build-template' into 'main'
Use build template See merge request tpeetz/generations!2
This commit is contained in:
+50
-15
@@ -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
|
||||
|
||||
+106
-22
@@ -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 {
|
||||
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,21 +90,75 @@ 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',
|
||||
'endpoint-url': 'https://www.thpeetz.de',
|
||||
'source-highlighter': 'rouge',
|
||||
'revdate': BUILD_DATE,
|
||||
'revnumber': '1.0.0',
|
||||
'revremark': 'Entwurf',
|
||||
'imagesdir': './images',
|
||||
'toc': 'left',
|
||||
'toc-title': 'Inhaltsverzeichnis',
|
||||
'revdate': BUILD_DATE,
|
||||
'revnumber': { project.version.toString() },
|
||||
'revremark': 'Entwurf',
|
||||
'chapter-label': '',
|
||||
'icons': 'font',
|
||||
'idprefix': 'id_',
|
||||
@@ -82,8 +167,7 @@ asciidoctorPdf {
|
||||
}
|
||||
}
|
||||
|
||||
task asciidoctor(dependsOn: asciidoctorPdf)
|
||||
build.dependsOn(['asciidoctor'])
|
||||
build.dependsOn(['asciidoctorPdf'])
|
||||
|
||||
wrapper {
|
||||
gradleVersion = "6.3"
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Checkstyle configuration that checks the sun coding conventions from:
|
||||
|
||||
- the Java Language Specification at
|
||||
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
|
||||
|
||||
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
|
||||
|
||||
- the Javadoc guidelines at
|
||||
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
|
||||
|
||||
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
|
||||
|
||||
- some best practices
|
||||
|
||||
Checkstyle is very configurable. Be sure to read the documentation at
|
||||
https://checkstyle.org (or in your downloaded distribution).
|
||||
|
||||
Most Checks are configurable, be sure to consult the documentation.
|
||||
|
||||
To completely disable a check, just comment it out or delete it from the file.
|
||||
To suppress certain violations please review suppression filters.
|
||||
|
||||
Finally, it is worth reading the documentation.
|
||||
|
||||
-->
|
||||
|
||||
<module name="Checker">
|
||||
<!--
|
||||
If you set the basedir property below, then all reported file
|
||||
names will be relative to the specified directory. See
|
||||
https://checkstyle.org/config.html#Checker
|
||||
|
||||
<property name="basedir" value="${basedir}"/>
|
||||
-->
|
||||
<property name="severity" value="error"/>
|
||||
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
|
||||
<!-- Excludes all 'module-info.java' files -->
|
||||
<!-- See https://checkstyle.org/config_filefilters.html -->
|
||||
<module name="BeforeExecutionExclusionFileFilter">
|
||||
<property name="fileNamePattern" value="module\-info\.java$"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}"
|
||||
default="checkstyle-suppressions.xml" />
|
||||
<property name="optional" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- Checks that a package-info.java file exists for each package. -->
|
||||
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
|
||||
<module name="JavadocPackage"/>
|
||||
|
||||
<!-- Checks whether files end with a new line. -->
|
||||
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
|
||||
<module name="NewlineAtEndOfFile"/>
|
||||
|
||||
<!-- Checks that property files contain the same keys. -->
|
||||
<!-- See https://checkstyle.org/config_misc.html#Translation -->
|
||||
<module name="Translation"/>
|
||||
|
||||
<!-- Checks for Size Violations. -->
|
||||
<!-- See https://checkstyle.org/config_sizes.html -->
|
||||
<module name="FileLength"/>
|
||||
<module name="LineLength">
|
||||
<property name="fileExtensions" value="java"/>
|
||||
</module>
|
||||
|
||||
<!-- Checks for whitespace -->
|
||||
<!-- See https://checkstyle.org/config_whitespace.html -->
|
||||
<module name="FileTabCharacter"/>
|
||||
|
||||
<!-- Miscellaneous other checks. -->
|
||||
<!-- See https://checkstyle.org/config_misc.html -->
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\s+$"/>
|
||||
<property name="minimum" value="0"/>
|
||||
<property name="maximum" value="0"/>
|
||||
<property name="message" value="Line has trailing spaces."/>
|
||||
</module>
|
||||
|
||||
<!-- Checks for Headers -->
|
||||
<!-- See https://checkstyle.org/config_header.html -->
|
||||
<!-- <module name="Header"> -->
|
||||
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
|
||||
<!-- <property name="fileExtensions" value="java"/> -->
|
||||
<!-- </module> -->
|
||||
|
||||
<module name="TreeWalker">
|
||||
|
||||
<!-- Checks for Javadoc comments. -->
|
||||
<!-- See https://checkstyle.org/config_javadoc.html -->
|
||||
<module name="InvalidJavadocPosition"/>
|
||||
<module name="JavadocMethod"/>
|
||||
<module name="JavadocType"/>
|
||||
<module name="JavadocVariable"/>
|
||||
<module name="JavadocStyle"/>
|
||||
<module name="MissingJavadocMethod"/>
|
||||
|
||||
<!-- Checks for Naming Conventions. -->
|
||||
<!-- See https://checkstyle.org/config_naming.html -->
|
||||
<module name="ConstantName"/>
|
||||
<module name="LocalFinalVariableName"/>
|
||||
<module name="LocalVariableName"/>
|
||||
<module name="MemberName"/>
|
||||
<module name="MethodName"/>
|
||||
<module name="PackageName"/>
|
||||
<module name="ParameterName"/>
|
||||
<module name="StaticVariableName"/>
|
||||
<module name="TypeName"/>
|
||||
|
||||
<!-- Checks for imports -->
|
||||
<!-- See https://checkstyle.org/config_imports.html -->
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="false"/>
|
||||
</module>
|
||||
|
||||
<!-- Checks for Size Violations. -->
|
||||
<!-- See https://checkstyle.org/config_sizes.html -->
|
||||
<module name="MethodLength"/>
|
||||
<module name="ParameterNumber"/>
|
||||
|
||||
<!-- Checks for whitespace -->
|
||||
<!-- See https://checkstyle.org/config_whitespace.html -->
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="GenericWhitespace"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="NoWhitespaceAfter"/>
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="OperatorWrap"/>
|
||||
<module name="ParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
<module name="WhitespaceAfter"/>
|
||||
<module name="WhitespaceAround"/>
|
||||
|
||||
<!-- Modifier Checks -->
|
||||
<!-- See https://checkstyle.org/config_modifiers.html -->
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="RedundantModifier"/>
|
||||
|
||||
<!-- Checks for blocks. You know, those {}'s -->
|
||||
<!-- See https://checkstyle.org/config_blocks.html -->
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="EmptyBlock"/>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="RightCurly"/>
|
||||
|
||||
<!-- Checks for common coding problems -->
|
||||
<!-- See https://checkstyle.org/config_coding.html -->
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
<module name="HiddenField"/>
|
||||
<module name="IllegalInstantiation"/>
|
||||
<module name="InnerAssignment"/>
|
||||
<module name="MagicNumber"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
|
||||
<!-- Checks for class design -->
|
||||
<!-- See https://checkstyle.org/config_design.html -->
|
||||
<module name="DesignForExtension"/>
|
||||
<module name="FinalClass"/>
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="InterfaceIsType"/>
|
||||
<module name="VisibilityModifier"/>
|
||||
|
||||
<!-- Miscellaneous other checks. -->
|
||||
<!-- See https://checkstyle.org/config_misc.html -->
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="FinalParameters"/>
|
||||
<module name="TodoComment"/>
|
||||
<module name="UpperEll"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
|
||||
<module name="SuppressionXpathFilter">
|
||||
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
|
||||
default="checkstyle-xpath-suppressions.xml" />
|
||||
<property name="optional" value="true"/>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
</module>
|
||||
@@ -1 +1,5 @@
|
||||
description = 'Anwendung Generations'
|
||||
group=de.thpeetz.generations
|
||||
version=1.0.0-SNAPSHOT
|
||||
gitLabPrivateToken=bFcsw1ebNhoFgKysksU1
|
||||
projectId=27
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -0,0 +1,11 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT"
|
||||
class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="debug">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Test classes for application Generations.
|
||||
*
|
||||
* @author Thomas Peetz
|
||||
* @since 1.0.0
|
||||
* @version 1.0.0
|
||||
*/
|
||||
package de.thpeetz.generations;
|
||||
Reference in New Issue
Block a user