Skip to content

Commit

Permalink
Merge branch 'release/v2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarman committed Dec 16, 2018
2 parents af939a1 + b2ad9d8 commit 0e76bb5
Show file tree
Hide file tree
Showing 44 changed files with 1,576 additions and 615 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The project contains unit and integration test examples for standard components
The project illustrates the use of Spring Boot Actuator for application monitoring and management. The application demonstrates the recording of custom metrics and the creation of custom health checks. Also, custom Maven and Gradle project attributes are incorporated into the Actuator info endpoint.

#### API Documentation Generator
The project includes [Springfox](http://springfox.github.io/springfox/) Swagger integration to automatically generate API docs for the RESTful web service endpoints. This feature may be activated using the *"docs"* Spring profile.
The project includes [Spring REST Docs](https://spring.io/projects/spring-restdocs) integration to automatically generate API docs for the RESTful web service endpoints. This feature may be activated using the *"asciidoctor"* Gradle task.

#### Executable Jar
The Maven and Gradle builds produce a fully executable Spring Boot Jar file. The Jar file may be executed directly from the command line without the *"java -jar"* command and may be installed on servers as a Linux service.
Expand Down Expand Up @@ -279,6 +279,26 @@ java -jar build/libs/example-1.0.0.jar --spring.profiles.active=mysql,batch
./example-1.0.0.jar --spring.profiles.active=mysql,batch
```

#### asciidoctor

The `asciidoctor` Gradle task performs the following workflow steps:

* compiles Java classes to the /build directory
* copies all resources to the /build directory
* executes the unit test suites
* generates [Asciidoctor](https://asciidoctor.org/) snippets in the /build/generated-snippets directory
* generates HTML API Docs in the /build/asciidoc/html5 directory

The `asciidoctor` Gradle task generates API documentation using [Spring REST Docs](https://spring.io/projects/spring-restdocs).

To execute the `asciidoctor` Gradle task, type the following command at a terminal prompt in the project base directory.

```
./gradlew clean asciidoctor
```

The API documentation is placed in the /build/asciidoc/html5 directory and the root document is named `index.html`.

#### encodePassword

The `encodePassword` Gradle task executes the `BCryptPasswordEncoderUtil` utility class to encode password values which may be included in the sample database scripts. The clear text password values are passed as a Gradle `-P` property arguments on the command line.
Expand Down
25 changes: 19 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'org.springframework.boot' version '2.1.1.RELEASE'
id 'org.asciidoctor.convert' version '1.5.3'
}

apply plugin: 'io.spring.dependency-management'
Expand All @@ -12,14 +13,15 @@ apply plugin: 'project-report'
apply plugin: 'build-dashboard'

ext {
snippetsDir = file('build/generated-snippets')

jacocoVersion = '0.8.2'
checkstyleVersion = '8.14'
pmdVersion = '6.9.0'
swaggerVersion = '2.7.0'
}

group = 'com.leanstacks'
version = '2.2.0'
version = '2.3.0'
sourceCompatibility = 11
targetCompatibility = 11

Expand All @@ -37,14 +39,16 @@ dependencies {

compile group: 'com.github.ben-manes.caffeine', name: 'caffeine'
compile group: 'org.liquibase', name: 'liquibase-core'
compile group: 'io.springfox', name: 'springfox-swagger2', version: swaggerVersion
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: swaggerVersion

runtime group: 'org.hsqldb', name: 'hsqldb'
runtime group: 'mysql', name: 'mysql-connector-java'

testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testCompile group: 'org.springframework.security', name: 'spring-security-test'
testCompile group: 'org.springframework.restdocs', name: 'spring-restdocs-mockmvc'
testCompile group: 'com.google.guava', name: 'guava', version: '27.0.1-jre'

asciidoctor group: 'org.springframework.restdocs', name: 'spring-restdocs-asciidoctor'
}

defaultTasks 'clean', 'build'
Expand Down Expand Up @@ -81,7 +85,15 @@ jacocoTestReport {
}
}

test.finalizedBy jacocoTestReport
test {
outputs.dir snippetsDir
finalizedBy jacocoTestReport
}

asciidoctor {
inputs.dir snippetsDir
dependsOn test
}

checkstyle {
toolVersion = checkstyleVersion
Expand All @@ -90,7 +102,8 @@ checkstyle {

pmd {
toolVersion = pmdVersion
ruleSetConfig = rootProject.resources.text.fromFile('etc/pmd/ruleset.xml')
ruleSets = []
ruleSetFiles = files('etc/pmd/ruleset.xml')
ignoreFailures = true
}

Expand Down
125 changes: 68 additions & 57 deletions etc/pmd/ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,78 +1,89 @@
<?xml version="1.0"?>
<ruleset name="LeanStacks PMD Ruleset" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
<ruleset name="LeanStacks PMD Ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.io/ruleset_2_0_0.xsd">

<description>
This is the LeanStacks Official PMD ruleset.
</description>
This is the LeanStacks Official PMD ruleset.
</description>

<!-- Use the entire 'basic' ruleset -->
<rule ref="rulesets/java/basic.xml" />
<rule ref="category/java/bestpractices.xml" />

<!-- Use the entire 'clone' ruleset -->
<rule ref="rulesets/java/clone.xml" />

<!-- Use the entire 'code size' ruleset -->
<rule ref="rulesets/java/codesize.xml" />

<!-- Use the entire 'controversial' ruleset -->
<rule ref="rulesets/java/controversial.xml">
<exclude name="AtLeastOneConstructor" />
<rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor" />
<exclude name="OnlyOneReturn" />
</rule>
<rule ref="rulesets/java/controversial.xml/DataflowAnomalyAnalysis">

<rule ref="category/java/codestyle.xml/LongVariable">
<properties>
<property name="violationSuppressRegex" value="^Found 'UR'-anomaly.*" />
<property name="minimum" value="35" />
</properties>
</rule>

<!-- Use the entire 'coupling' ruleset -->
<rule ref="rulesets/java/coupling.xml">
<exclude name="LawOfDemeter" />
<exclude name="LoosePackageCoupling" />
<rule ref="category/java/codestyle.xml/ShortVariable">
<properties>
<property name="minimum" value="2" />
</properties>
</rule>

<!-- Use the entire 'design' ruleset -->
<rule ref="rulesets/java/design.xml" />

<!-- Use the entire 'empty' ruleset -->
<rule ref="rulesets/java/empty.xml" />

<!-- Use the entire 'finalizers' ruleset -->
<rule ref="rulesets/java/finalizers.xml" />

<!-- Use the entire 'javabeans' ruleset -->
<rule ref="rulesets/java/javabeans.xml" />

<!-- Use the entire 'java logging' ruleset -->
<rule ref="rulesets/java/logging-java.xml">
<!-- InvalidSlf4jMessageFormat has bug in PMD 5.5.1 -->
<exclude name="InvalidSlf4jMessageFormat" />
<rule ref="category/java/codestyle.xml/ShortClassName">
<properties>
<property name="minimum" value="2" />
</properties>
</rule>

<!-- Use the entire 'junit' ruleset -->
<rule ref="rulesets/java/junit.xml" />

<!-- Use the entire 'optimizations' ruleset -->
<rule ref="rulesets/java/optimizations.xml" />

<!-- Use the entire 'sun security' ruleset -->
<rule ref="rulesets/java/sunsecure.xml" />

<!-- Use the entire 'strict exceptions' ruleset -->
<rule ref="rulesets/java/strictexception.xml" />

<!-- Use the entire 'type resolution' ruleset -->
<rule ref="rulesets/java/typeresolution.xml" />
<rule ref="category/java/codestyle.xml/ClassNamingConventions">
<properties>
<property name="utilityClassPattern" value="[A-Z][a-zA-Z0-9]*" />
</properties>
</rule>

<!-- Use the entire 'unnecessary' ruleset -->
<rule ref="rulesets/java/unnecessary.xml" />
<rule ref="category/java/codestyle.xml/FieldNamingConventions">
<properties>
<property name="exclusions" value="serialVersionUID|logger" />
</properties>
</rule>

<!-- Use the entire 'unused code' ruleset -->
<rule ref="rulesets/java/unusedcode.xml" />
<rule ref="category/java/design.xml">
<exclude name="DataClass" />
<exclude name="LawOfDemeter" />
<exclude name="LoosePackageCoupling" />
</rule>

<rule ref="category/java/design.xml/SignatureDeclareThrowsException">
<properties>
<property name="IgnoreJUnitCompletely" value="true" />
</properties>
</rule>

<rule ref="category/java/documentation.xml" />

<!-- Use the entire 'strings' ruleset -->
<rule ref="rulesets/java/strings.xml" />
<rule ref="category/java/documentation.xml/CommentSize">
<properties>
<property name="maxLineLength" value="120" />
<property name="maxLines" value="20" />
</properties>
</rule>

<rule ref="category/java/errorprone.xml" />

<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals">
<properties>
<property name="skipAnnotations" value="true" />
</properties>
</rule>

<rule ref="category/java/errorprone.xml/DataflowAnomalyAnalysis">
<properties>
<property name="violationSuppressRegex" value="^Found 'UR'-anomaly.*" />
</properties>
</rule>

<rule ref="category/java/multithreading.xml" />

<rule ref="category/java/performance.xml" />

<rule ref="category/java/security.xml" />

</ruleset>
27 changes: 13 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.leanstacks</groupId>
<artifactId>skeleton-ws-spring-boot</artifactId>
<version>2.2.0</version>
<version>2.3.0</version>
<name>Spring Boot Starter Project</name>
<description>Starter application stack for RESTful web services using Spring Boot.</description>

Expand All @@ -18,7 +18,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<swagger.version>2.7.0</swagger.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -66,18 +65,6 @@

<!-- Dependencies for Miscellaneous Functionality -->

<!-- Dependencies for Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>

<!-- Dependencies for Unit Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -89,6 +76,18 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.0.1-jre</version>
<scope>test</scope>
</dependency>

<!-- Dependencies for API Docs -->
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
16 changes: 16 additions & 0 deletions src/docs/asciidoc/_includes/http-response-error.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[source,http,options="nowrap"]
----
HTTP/1.1 404
Content-Length: 213
Content-Type: application/json;charset=UTF-8
{
"timestamp": "2018-12-12T13:16:11.771539Z",
"method": "GET",
"path": "/api/...",
"status": 404,
"statusText": "Not Found",
"exceptionClass": "java.util.NoSuchElementException",
"exceptionMessage": "No value present"
}
----
32 changes: 32 additions & 0 deletions src/docs/asciidoc/_includes/response-fields-error.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
|===
|Path|Type|Description

|`+timestamp+`
|`+String+`
|The time the error occurred.

|`+method+`
|`+String+`
|The HTTP method.

|`+path+`
|`+String+`
|The request context path.

|`+status+`
|`+Number+`
|The response HTTP status code.

|`+statusText+`
|`+String+`
|The response HTTP status text.

|`+exceptionClass+`
|`+String+`
|The exception class.

|`+exceptionMessage+`
|`+String+`
|The exception message.

|===
Loading

0 comments on commit 0e76bb5

Please sign in to comment.