Skip to content

feat: basic java project #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/scaffold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ jobs:
- name: Install cookiecutter
run: |
pip install cookiecutter
# - name: Test cookiecutter
# run: |
# cookiecutter . --no-input
# - name: Set up JDK 21
# uses: actions/setup-java@v1
# with:
# java-version: 21
# - name: Cache Maven packages
# uses: actions/cache@v2
# with:
# path: ~/.m2
# key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
# restore-keys: ${{ runner.os }}-m2
# - name: Build with Maven
# run: cd sample && mvn clean install -ntp
- name: Test cookiecutter
run: |
cookiecutter --config-file=test-config.yml --no-input .
- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: 21
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: cd sample && mvn clean install -ntp
6 changes: 4 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"app_name": "sample",
"app_name": "{{cookiecutter.app_name}}",
"app_name_lower": "{{cookiecutter.app_name.lower()}}",
"app_title": "{{cookiecutter.app_name.capitalize()}}"
"app_title": "{{cookiecutter.app_name.capitalize()}}",
"group_id": "org.dfm.{{cookiecutter.app_name_lower}}",
"artifact_id": "{{cookiecutter.app_name_lower}}"
}
4 changes: 4 additions & 0 deletions test-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
default_context:
app_name: "sample"
group_id: "org.example.sample"
artifact_id: "sample"
260 changes: 260 additions & 0 deletions {{cookiecutter.app_name_lower}}/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>{{cookiecutter.group_id}}</groupId>
<artifactId>{{cookiecutter.artifact_id}}</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>21</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<junit-jupiter.version>5.11.3</junit-jupiter.version>
<spring-boot.version>3.3.5</spring-boot.version>
<cucumber.version>7.20.1</cucumber.version>
<springdoc-openapi-starter.version>2.6.0</springdoc-openapi-starter.version>
<pre-liquibase.version>1.5.1</pre-liquibase.version>
<otj-pg-embedded.version>1.1.0</otj-pg-embedded.version>
<snakeyaml.version>2.3</snakeyaml.version>
<h2.version>2.3.232</h2.version>
<!-- plugins -->
<cukedoctor-maven-plugin.version>3.9.0</cukedoctor-maven-plugin.version>
<maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
<maven-enforcer-plugin>3.5.0</maven-enforcer-plugin>
<arch-unit-maven-plugin.version>4.0.2</arch-unit-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<jib-maven.plugin.version>3.4.4</jib-maven.plugin.version>
<git-code-format-maven-plugin.version>5.3</git-code-format-maven-plugin.version>
<githook-maven-plugin.version>1.0.5</githook-maven-plugin.version>
<pitest-maven-plugin.version>1.17.1</pitest-maven-plugin.version>
<pitest-junit5-plugin.version>1.2.1</pitest-junit5-plugin.version>
</properties>
<!--<modules>
<module>domain</module>
<module>domain-api</module>
<module>rest-adapter</module>
<module>jpa-adapter</module>
<module>bootstrap</module>
<module>acceptance-test</module>
</modules>-->
<dependencyManagement>
<dependencies>
<!-- Frameworks & Libraries -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- JUnit 5 dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<!-- mockito dependencies -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source> <!-- 1.8,1.9,1.10,11,12,13 -->
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin}</version>
<configuration>
<rules>
<dependencyConvergence/>
<requireReleaseDeps>
<failWhenParentIsSnapshot>false</failWhenParentIsSnapshot>
<excludes>
<exclude>${project.groupId}:*</exclude>
</excludes>
</requireReleaseDeps>
</rules>
<fail>true</fail>
</configuration>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.cosium.code</groupId>
<artifactId>git-code-format-maven-plugin</artifactId>
<version>${git-code-format-maven-plugin.version}</version>
<executions>
<!-- On commit, format the modified java files -->
<execution>
<id>install-formatter-hook</id>
<goals>
<goal>install-hooks</goal>
</goals>
</execution>
<!-- On Maven verify phase, fail if any file
(including unmodified) is badly formatted -->
<execution>
<id>validate-code-format</id>
<goals>
<goal>validate-code-format</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- Enable https://github.com/google/google-java-format -->
<dependency>
<groupId>com.cosium.code</groupId>
<artifactId>google-java-format</artifactId>
<version>${git-code-format-maven-plugin.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>io.github.phillipuniverse</groupId>
<artifactId>githook-maven-plugin</artifactId>
<version>${githook-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
<configuration>
<hooks>
<pre-commit>
echo "Validating..."
exec mvn test
echo "Formatting code..."
exec mvn git-code-format:format-code
echo "Validating format..."
exec mvn git-code-format:validate-code-format
</pre-commit>
</hooks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</plugin>
<plugin>
<groupId>com.societegenerale.commons</groupId>
<artifactId>arch-unit-maven-plugin</artifactId>
<version>${arch-unit-maven-plugin.version}</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>arch-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib-maven.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Loading