From 0b7103fcfcf79d976ce68ccc48a49c9adb6a824a Mon Sep 17 00:00:00 2001 From: Bernardo Date: Tue, 3 Nov 2020 23:14:36 +0100 Subject: [PATCH 01/13] Corrected docs --- src/main/resources/archetype-resources/readme.md | 4 ++-- .../archetype-resources/src/site/markdown/index.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/archetype-resources/readme.md b/src/main/resources/archetype-resources/readme.md index 81e54e5..b9cd63c 100644 --- a/src/main/resources/archetype-resources/readme.md +++ b/src/main/resources/archetype-resources/readme.md @@ -1,7 +1,7 @@ #set( $symbol_pound = '#' ) ${symbol_pound} ${projectName} -This is a [Spring MVC](https://spring.io) project using [React](https://reactjs.org/) templates for the frontend, created with the use of the [Spring MVC with React Maven Archetype](https://github.com/Bernardo-MG/spring-mvc-react-maven-archetype). It will ease the development of new Spring MVC projects, setting it up for CI through the use of three free services: [Github](https://github.com/), [Github Workflow](https://docs.github.com/en/actions/configuring-and-managing-workflows) and [Bintray](https://bintray.com/). +This is a [Spring MVC](https://spring.io) project using [Angular](https://angular.io/) templates for the frontend, created with the use of the [Spring MVC with Angular Maven Archetype](https://github.com/Bernardo-MG/spring-mvc-angular-maven-archetype). It will ease the development of new Spring MVC projects, setting it up for CI through the use of three free services: [Github](https://github.com/), [Github Workflow](https://docs.github.com/en/actions/configuring-and-managing-workflows) and [Bintray](https://bintray.com/). Before beginning with the new project there are a few things which should be edited: @@ -29,7 +29,7 @@ The project by default comes with a useful series of features: - Preconfigured POM to begin developing a new [Spring MVC](https://spring.io) project with [Spring Boot}(https://spring.io/projects/spring-boot). - Initial sample project including working persistence and exception handling - Integration with [Thymeleaf](http://www.thymeleaf.org/) for the view templates. -- Using [React](https://reactjs.org/) for the UI. +- Using [Angular](https://angular.io/) for the UI. - Using [Liquibase](http://www.liquibase.org/) for database versioning. - Integration with [iText](https://itextpdf.com/) for generating PDFs. - Prepared for [Github Workflow](https://docs.github.com/en/actions/configuring-and-managing-workflows), including configuration files and deployment scripts. Check the [Archetype documentation](http://docs.bernardomg.com/maven/library-maven-archetype) to find out more. diff --git a/src/main/resources/archetype-resources/src/site/markdown/index.md b/src/main/resources/archetype-resources/src/site/markdown/index.md index 96fb1fe..f4f7d9d 100644 --- a/src/main/resources/archetype-resources/src/site/markdown/index.md +++ b/src/main/resources/archetype-resources/src/site/markdown/index.md @@ -1,12 +1,12 @@ # ${projectName} -This is a base project created with the [Spring MVC with Thymeleaf Maven Archetype][archetype], prepared to ease the development of new libraries. +This is a base project created with the [Spring MVC with Angular Maven Archetype][archetype], prepared to ease the development of new libraries. Note that while it is meant to be a working project from the beginning, meaning that it compiles, runs the tests and creates the docs. It is mostly composed of placeholder classes which should be swapped with actual content. ## Where should I start customizing the project? -First of all, check the [Spring MVC with Thymeleaf Maven Archetype][archetype] documentation, and then edit the readme file and the Maven site descriptions about the project. +First of all, check the [Spring MVC with Angular Maven Archetype][archetype] documentation, and then edit the readme file and the Maven site descriptions about the project. After that, of course, the classes and tests included should be replaced with actual code, which also means adding dependencies and changing profiles and plugins as needed on the POM. @@ -20,4 +20,4 @@ While the project can be used just by itself, it won't take full advantage of mo - Test artifacts repository, Sonatype OSS by default. - Documentation repository, through SSH by default. -[archetype]: https://www.github.com/bernardo-mg/spring-mvc-react-maven-archetype \ No newline at end of file +[archetype]: https://www.github.com/bernardo-mg/spring-mvc-angular-maven-archetype \ No newline at end of file From ab8c21e15c9331487b0748a173932d6d5baa14cb Mon Sep 17 00:00:00 2001 From: Bernardo Date: Wed, 6 Jan 2021 19:33:28 +0100 Subject: [PATCH 02/13] Added comments --- .../src/main/java/Application.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/main/resources/archetype-resources/src/main/java/Application.java b/src/main/resources/archetype-resources/src/main/java/Application.java index 81a5946..d930528 100644 --- a/src/main/resources/archetype-resources/src/main/java/Application.java +++ b/src/main/resources/archetype-resources/src/main/java/Application.java @@ -1,16 +1,53 @@ +/** + * The MIT License (MIT) + *

+ * Copyright (c) ${currentYear} the original author or authors. + *

+ * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + *

+ * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + *

+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package ${package}; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** + * Application runnable class. This allows Spring Boot to run the application. + * + * @author Bernardo Martínez Garrido + * + */ @SpringBootApplication public class Application { + /** + * Runnable main method. + * + * @param args execution parameters + */ public static void main(final String[] args) { SpringApplication.run(Application.class, args); } + /** + * Default constructor. + */ public Application() { super(); } From d7bcce83543e50f48cc906797f460c5758f50e7d Mon Sep 17 00:00:00 2001 From: Bernardo Date: Wed, 6 Jan 2021 21:06:47 +0100 Subject: [PATCH 03/13] Corrected type --- .../archetype-resources/src/main/js/app/api-response.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/archetype-resources/src/main/js/app/api-response.ts b/src/main/resources/archetype-resources/src/main/js/app/api-response.ts index b1740b1..418d609 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/api-response.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/api-response.ts @@ -2,5 +2,5 @@ import { ApiPage } from './api-page'; export interface ApiResponse { content: ApiPage; - status: T; + status: String; } \ No newline at end of file From 87c31d35fdb339f48e081a7544cf766b9eb5bbb2 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Wed, 6 Jan 2021 21:18:48 +0100 Subject: [PATCH 04/13] Reduced npm installation --- src/main/resources/archetype-resources/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml index c981c1a..2019fb5 100644 --- a/src/main/resources/archetype-resources/pom.xml +++ b/src/main/resources/archetype-resources/pom.xml @@ -903,7 +903,7 @@ npm - install + ci From be922aa8ed9a8d0a9961e98d24dae3b3ed36cbde Mon Sep 17 00:00:00 2001 From: Bernardo Date: Wed, 6 Jan 2021 21:32:01 +0100 Subject: [PATCH 05/13] Reverted change --- src/main/resources/archetype-resources/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml index 2019fb5..c981c1a 100644 --- a/src/main/resources/archetype-resources/pom.xml +++ b/src/main/resources/archetype-resources/pom.xml @@ -903,7 +903,7 @@ npm - ci + install From e61c1f5b18ca3f8b3f79a8ca05813983320f1b56 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 10 Jan 2021 19:28:21 +0100 Subject: [PATCH 06/13] Added string conversion method to response --- .../src/main/java/response/DefaultResponse.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/resources/archetype-resources/src/main/java/response/DefaultResponse.java b/src/main/resources/archetype-resources/src/main/java/response/DefaultResponse.java index abc3ce7..07e4196 100644 --- a/src/main/resources/archetype-resources/src/main/java/response/DefaultResponse.java +++ b/src/main/resources/archetype-resources/src/main/java/response/DefaultResponse.java @@ -26,6 +26,8 @@ import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.MoreObjects; + public class DefaultResponse implements Response { private T content; @@ -67,4 +69,10 @@ public void setStatus(final ResponseStatus value) { status = value; } + @Override + public final String toString() { + return MoreObjects.toStringHelper(this).add("status", status) + .add("content", content).toString(); + } + } From cddcf2415e6fb94612a477595a2a9e886998492e Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 17 Jan 2021 20:18:07 +0100 Subject: [PATCH 07/13] Cleaned up docs --- readme.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/readme.md b/readme.md index 5510c6a..76a4464 100644 --- a/readme.md +++ b/readme.md @@ -48,13 +48,6 @@ The application is coded in Java, using Maven to manage the project. It is a Maven Archetype, and can be used through command line or an IDE as long as it is included in the local repository. -### Prerequisites - -The project has been tested on the following Java versions: -* JDK 8 - -All other dependencies are handled through Maven, and noted in the included POM file. - ### Installing The best way to install the Archetype is by downloading it from the [Bintray repository][bintray-repo]. It can be acquired from the [Maven Central Repository][maven-repo] too, but it is not recommended. From 280303d80be059a18d25e8e953cb1b3a3e90f4d7 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 17 Jan 2021 20:21:08 +0100 Subject: [PATCH 08/13] Cleaned up docs --- src/main/resources/archetype-resources/readme.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/resources/archetype-resources/readme.md b/src/main/resources/archetype-resources/readme.md index b9cd63c..cf1d8e6 100644 --- a/src/main/resources/archetype-resources/readme.md +++ b/src/main/resources/archetype-resources/readme.md @@ -61,13 +61,6 @@ ${symbol_pound}${symbol_pound} Usage The application is coded in Java, using Maven to manage the project. -${symbol_pound}${symbol_pound}${symbol_pound} Prerequisites - -The project has been tested on the following Java versions: -* JDK 8 - -All other dependencies are handled through Maven, and noted in the included POM file. - ${symbol_pound}${symbol_pound}${symbol_pound} Profiles Maven profiles are included for setting up the database. From 9fcad7b86c51aceede6a45960c1a62c0bbcd2a8f Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 18 Jan 2021 20:36:36 +0100 Subject: [PATCH 09/13] Added environment for testing --- .../archetype-resources/.github/workflows/testing.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/archetype-resources/.github/workflows/testing.yml b/src/main/resources/archetype-resources/.github/workflows/testing.yml index b037746..6259979 100644 --- a/src/main/resources/archetype-resources/.github/workflows/testing.yml +++ b/src/main/resources/archetype-resources/.github/workflows/testing.yml @@ -10,6 +10,7 @@ jobs: matrix: jdk: [ 8, 11, 14 ] db: [ h2, mysql, postgres ] + env: [ development, production ] services: mysql: @@ -41,4 +42,4 @@ jobs: with: java-version: ${{ matrix.jdk }} - name: Run all tests - run: mvn clean verify -P${{ matrix.db }},development -Dspring.profiles.active=test,${{ matrix.db }} + run: mvn clean verify -P${{ matrix.db }},${{ matrix.env }} -Dspring.profiles.active=test,${{ matrix.db }} From 4ca6e6af8fd2c0491e5677af4f85be25db1aeaed Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 18 Jan 2021 20:55:41 +0100 Subject: [PATCH 10/13] Added missing profiles info --- .../archetype-resources/.github/workflows/deploy_docs.yml | 4 ++-- src/main/resources/archetype-resources/readme.md | 8 +++++--- .../archetype-resources/src/site/markdown/usage.md.vm | 2 +- src/site/markdown/index.md | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/resources/archetype-resources/.github/workflows/deploy_docs.yml b/src/main/resources/archetype-resources/.github/workflows/deploy_docs.yml index f3617d8..cb462cf 100644 --- a/src/main/resources/archetype-resources/.github/workflows/deploy_docs.yml +++ b/src/main/resources/archetype-resources/.github/workflows/deploy_docs.yml @@ -40,7 +40,7 @@ jobs: DEPLOY_DOCS_DEVELOP_SITE: ${{ secrets.DEPLOY_DOCS_DEVELOP_SITE }} - name: Deploy development docs if: steps.extract_branch.outputs.branch == 'develop' - run: mvn verify site site:deploy -B -P deployment,deployment-development --settings settings.xml -Dspring.profiles.active=test,h2 + run: mvn verify site site:deploy -B -P h2,development,deployment,deployment-development --settings settings.xml -Dspring.profiles.active=test,h2 - name: Deploy release docs if: steps.extract_branch.outputs.branch == 'master' - run: mvn verify site site:deploy -B -P deployment,deployment-release --settings settings.xml -Dspring.profiles.active=test,h2 + run: mvn verify site site:deploy -B -P h2,development,deployment,deployment-release --settings settings.xml -Dspring.profiles.active=test,h2 diff --git a/src/main/resources/archetype-resources/readme.md b/src/main/resources/archetype-resources/readme.md index cf1d8e6..f97c9e2 100644 --- a/src/main/resources/archetype-resources/readme.md +++ b/src/main/resources/archetype-resources/readme.md @@ -52,7 +52,7 @@ Documentation is also generated from the latest snapshot, taken from the 'develo The documentation site is actually a Maven site, and its sources are included in the project. If required it can be generated by using the following Maven command: ``` -mvn verify site -P h2,development +mvn verify site -P h2,development -Dspring.profiles.active=test,h2 ``` The verify phase is required, otherwise some of the reports won't be generated. @@ -65,6 +65,8 @@ ${symbol_pound}${symbol_pound}${symbol_pound} Profiles Maven profiles are included for setting up the database. +Spring profiles are also included for the databases. Matching the same name. + | Profile | Database | |----------|-----------------------| | h2 | H2 in-memory database | @@ -85,7 +87,7 @@ ${symbol_pound}${symbol_pound}${symbol_pound} Running To run the project locally use the following Maven command: ``` -mvn spring-boot:run -P h2,development +mvn spring-boot:run -P h2,development -Dspring.profiles.active=h2 ``` It will be accessible at [http://localhost:8080/](http://localhost:8080/). @@ -97,7 +99,7 @@ The project requires a database and a server for being able to run the integrati Just like running the project, an embedded server with an in-memory database can be used: ``` -mvn verify -P h2,development +mvn verify -P h2,development -Dspring.profiles.active=test,h2 ``` ${symbol_pound}${symbol_pound}${symbol_pound} Packaging the WAR diff --git a/src/main/resources/archetype-resources/src/site/markdown/usage.md.vm b/src/main/resources/archetype-resources/src/site/markdown/usage.md.vm index 48c81a4..6911101 100644 --- a/src/main/resources/archetype-resources/src/site/markdown/usage.md.vm +++ b/src/main/resources/archetype-resources/src/site/markdown/usage.md.vm @@ -7,7 +7,7 @@ The project requires a database and a server. But the included Maven profiles al To run the project locally with an H2 in-memory database: ``` -mvn spring-boot:run -P h2,development +mvn spring-boot:run -P h2,development -Dspring.profiles.active=h2 ``` This makes the project be accessible at [http://localhost:8080/](http://localhost:8080/). diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 99d31d8..7eab819 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -36,7 +36,7 @@ This configuration is for the database, and the easiest way to handle it is by u The verify phase is required for generating all the reports, and this means that the integration tests will be run, which require all the dependencies. ``` -$ mvn verify site -P h2,development +mvn verify site -P h2,development -Dspring.profiles.active=test,h2 ``` ### Running the project locally @@ -44,7 +44,7 @@ $ mvn verify site -P h2,development To run the project locally use the following Maven command: ``` -mvn spring-boot:run -P h2,development +mvn spring-boot:run -P h2,development -Dspring.profiles.active=h2 ``` From de7dbec98850222446b85e8f18b0cb5e8796c4da Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 18 Jan 2021 21:21:53 +0100 Subject: [PATCH 11/13] Updated super POM --- pom.xml | 2 +- src/main/resources/archetype-resources/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5625006..a727fb7 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ com.bernardomg.maven archetype-pom - 1.2.1 + 1.2.2 diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml index c981c1a..2a0e04c 100644 --- a/src/main/resources/archetype-resources/pom.xml +++ b/src/main/resources/archetype-resources/pom.xml @@ -11,7 +11,7 @@ com.bernardomg.maven base-pom - 1.3.4 + 1.3.5 From 10c1cc88fb357d3884720e0a9afdfc851165beed Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 18 Jan 2021 21:23:31 +0100 Subject: [PATCH 12/13] Updated skin --- pom.xml | 2 +- src/main/resources/archetype-resources/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a727fb7..4a56aa0 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ - 2.0.8 + 2.0.10 https://dl.bintray.com/bernardo-mg/maven/ https://bintray.com/bernardo-mg/maven/spring-mvc-angular-maven-archetype/view http://mvnrepository.com/artifact/com.bernardomg.maven.archetypes/spring-mvc-angular-archetype diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml index 2a0e04c..0f1733f 100644 --- a/src/main/resources/archetype-resources/pom.xml +++ b/src/main/resources/archetype-resources/pom.xml @@ -390,7 +390,7 @@ - 2.0.8 + 2.0.10 From b1e09bd34cee0817ccd7c3dd25cb2c4876d301e6 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 18 Jan 2021 21:28:47 +0100 Subject: [PATCH 13/13] Snapshot --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0411b93..16b3183 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ com.bernardomg.maven.archetypes spring-mvc-angular-archetype - 1.0.0 + 1.1.0-SNAPSHOT maven-archetype Spring MVC with Angular Maven Archetype