Skip to content

Commit a50bfb6

Browse files
patbaumgartnerdsyer
authored andcommitted
Update Spring Boot release, adding Gradle build and cleanup
- Update Spring Boot release, Checkstyle, Mysql. - Formatting pom.xml with sortpom-maven-plugin. - Rename README to standard file name. - Adding GitHub Action for Gradle.
1 parent dff45cf commit a50bfb6

File tree

10 files changed

+85
-66
lines changed

10 files changed

+85
-66
lines changed

.github/workflows/gradle-build.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-gradle
3+
4+
name: Java CI with Gradle
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
java: [ '17' ]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up JDK ${{matrix.java}}
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: ${{matrix.java}}
26+
distribution: 'adopt'
27+
cache: maven
28+
- name: Setup Gradle
29+
uses: gradle/actions/setup-gradle@v4
30+
- name: Build with Gradle
31+
run: ./gradlew build

.github/workflows/maven-build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
2+
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven
33

44
name: Java CI with Maven
55

@@ -26,4 +26,4 @@ jobs:
2626
distribution: 'adopt'
2727
cache: maven
2828
- name: Build with Maven Wrapper
29-
run: ./mvnw -B package
29+
run: ./mvnw -B verify

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
HELP.md
2+
pom.xml.bak
23
target/
34
!.mvn/wrapper/maven-wrapper.jar
45
!**/src/main/**/target/
@@ -41,6 +42,9 @@ out/
4142
### VS Code ###
4243
.vscode/
4344

45+
### SDK Man ###
46+
.sdkmanrc
47+
4448
### CSS ###
4549
_site/
4650
*.css

readme.md README.md

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Spring PetClinic Sample Application [![Build Status](https://github.com/spring-projects/spring-petclinic/actions/workflows/maven-build.yml/badge.svg)](https://github.com/spring-projects/spring-petclinic/actions/workflows/maven-build.yml)
1+
# Spring PetClinic Sample Application [![Build Status](https://github.com/spring-projects/spring-petclinic/actions/workflows/maven-build.yml/badge.svg)](https://github.com/spring-projects/spring-petclinic/actions/workflows/maven-build.yml)[![Build Status](https://github.com/spring-projects/spring-petclinic/actions/workflows/gradle-build.yml/badge.svg)](https://github.com/spring-projects/spring-petclinic/actions/workflows/gradle-build.yml)
22

33
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/spring-projects/spring-petclinic) [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=7517918)
44

@@ -29,14 +29,6 @@ Or you can run it from Maven directly using the Spring Boot Maven plugin. If you
2929

3030
> NOTE: If you prefer to use Gradle, you can build the app using `./gradlew build` and look for the jar file in `build/libs`.
3131
32-
At development time it is recommended to use the integration tests (whch have their own `main` method) to run the application. This will allow you to make changes to the content and see the changes immediately. You can run the integration tests from your IDE or using the command line. Because there are multiple main classes for different database configurations, you have to choose one, e.g:
33-
34-
```bash
35-
./mvnw spring-boot:test-run -Dspring-boot.run.main-class=org.springframework.samples.petclinic.PetClinicIntegrationTests
36-
```
37-
38-
Or you can run it in your IDE directly from the test class of your choice.
39-
4032
## Building a Container
4133

4234
There is no `Dockerfile` in this project. You can build a container image (if you have a docker daemon) using the Spring Boot build plugin:
@@ -52,16 +44,15 @@ Our issue tracker is available [here](https://github.com/spring-projects/spring-
5244
## Database configuration
5345

5446
In its default configuration, Petclinic uses an in-memory database (H2) which
55-
gets populated at startup with data. If you launch the app from the integration tests, the h2 console is automatically
56-
exposed at `http://localhost:8080/h2-console`,
47+
gets populated at startup with data. The h2 console is exposed at `http://localhost:8080/h2-console`,
5748
and it is possible to inspect the content of the database using the `jdbc:h2:mem:<uuid>` URL. The UUID is printed at startup to the console.
5849

5950
A similar setup is provided for MySQL and PostgreSQL if a persistent database configuration is needed. Note that whenever the database type changes, the app needs to run with a different profile: `spring.profiles.active=mysql` for MySQL or `spring.profiles.active=postgres` for PostgreSQL. See the [Spring Boot documentation](https://docs.spring.io/spring-boot/how-to/properties-and-configuration.html#howto.properties-and-configuration.set-active-spring-profiles) for more detail on how to set the active profile.
6051

6152
You can start MySQL or PostgreSQL locally with whatever installer works for your OS or use docker:
6253

6354
```bash
64-
docker run -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:9.0
55+
docker run -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:9.1
6556
```
6657

6758
or

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id 'java'
3-
id 'org.springframework.boot' version '3.3.4'
3+
id 'org.springframework.boot' version '3.3.5'
44
id 'io.spring.dependency-management' version '1.1.6'
55
id 'org.graalvm.buildtools.native' version '0.10.3'
66
id 'org.cyclonedx.bom' version '1.10.0'
@@ -25,7 +25,7 @@ repositories {
2525
mavenCentral()
2626
}
2727

28-
ext.checkstyleVersion = "10.18.1"
28+
ext.checkstyleVersion = "10.20.0"
2929
ext.springJavaformatCheckstyleVersion = "0.0.43"
3030
ext.webjarsFontawesomeVersion = "4.7.0"
3131
ext.webjarsBootstrapVersion = "5.3.3"

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
mysql:
3-
image: mysql:9.0
3+
image: mysql:9.1
44
ports:
55
- "3306:3306"
66
environment:

pom.xml

+40-46
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xmlns="http://maven.apache.org/POM/4.0.0"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
53
<modelVersion>4.0.0</modelVersion>
6-
<groupId>org.springframework.samples</groupId>
7-
<artifactId>spring-petclinic</artifactId>
8-
<version>3.3.0-SNAPSHOT</version>
94

105
<parent>
116
<groupId>org.springframework.boot</groupId>
127
<artifactId>spring-boot-starter-parent</artifactId>
13-
<version>3.3.4</version>
14-
<relativePath/>
8+
<version>3.3.5</version>
9+
<relativePath></relativePath>
1510
</parent>
11+
12+
<groupId>org.springframework.samples</groupId>
13+
<artifactId>spring-petclinic</artifactId>
14+
<version>3.3.0-SNAPSHOT</version>
15+
1616
<name>petclinic</name>
1717

1818
<properties>
@@ -28,11 +28,11 @@
2828
<webjars-bootstrap.version>5.3.3</webjars-bootstrap.version>
2929
<webjars-font-awesome.version>4.7.0</webjars-font-awesome.version>
3030

31-
<checkstyle.version>10.18.1</checkstyle.version>
31+
<checkstyle.version>10.20.0</checkstyle.version>
3232
<jacoco.version>0.8.12</jacoco.version>
3333
<libsass.version>0.2.29</libsass.version>
3434
<lifecycle-mapping>1.0.0</lifecycle-mapping>
35-
<maven-checkstyle.version>3.5.0</maven-checkstyle.version>
35+
<maven-checkstyle.version>3.6.0</maven-checkstyle.version>
3636
<nohttp-checkstyle.version>0.0.11</nohttp-checkstyle.version>
3737
<spring-format.version>0.0.43</spring-format.version>
3838

@@ -171,10 +171,10 @@
171171
<version>${spring-format.version}</version>
172172
<executions>
173173
<execution>
174-
<phase>validate</phase>
175174
<goals>
176175
<goal>validate</goal>
177176
</goals>
177+
<phase>validate</phase>
178178
</execution>
179179
</executions>
180180
</plugin>
@@ -197,19 +197,17 @@
197197
<executions>
198198
<execution>
199199
<id>nohttp-checkstyle-validation</id>
200+
<goals>
201+
<goal>check</goal>
202+
</goals>
200203
<phase>validate</phase>
201204
<configuration>
202205
<configLocation>src/checkstyle/nohttp-checkstyle.xml</configLocation>
203206
<sourceDirectories>${basedir}</sourceDirectories>
204207
<includes>**/*</includes>
205208
<excludes>**/.git/**/*,**/.idea/**/*,**/target/**/,**/.flattened-pom.xml,**/*.class</excludes>
206-
<propertyExpansion>
207-
config_loc=${basedir}/src/checkstyle/
208-
</propertyExpansion>
209+
<propertyExpansion>config_loc=${basedir}/src/checkstyle/</propertyExpansion>
209210
</configuration>
210-
<goals>
211-
<goal>check</goal>
212-
</goals>
213211
</execution>
214212
</executions>
215213
</plugin>
@@ -250,10 +248,10 @@
250248
</execution>
251249
<execution>
252250
<id>report</id>
253-
<phase>prepare-package</phase>
254251
<goals>
255252
<goal>report</goal>
256253
</goals>
254+
<phase>prepare-package</phase>
257255
</execution>
258256
</executions>
259257
</plugin>
@@ -271,14 +269,13 @@
271269
<!-- Spring Boot Actuator displays sbom-related information if a CycloneDX SBOM file is
272270
present at the classpath -->
273271
<plugin>
274-
<?m2e ignore?>
272+
<?m2e ignore?>
275273
<groupId>org.cyclonedx</groupId>
276274
<artifactId>cyclonedx-maven-plugin</artifactId>
277275
</plugin>
278276

279277
</plugins>
280278
</build>
281-
282279
<licenses>
283280
<license>
284281
<name>Apache License, Version 2.0</name>
@@ -288,39 +285,38 @@
288285

289286
<repositories>
290287
<repository>
291-
<id>spring-snapshots</id>
292-
<name>Spring Snapshots</name>
293-
<url>https://repo.spring.io/snapshot</url>
294288
<snapshots>
295289
<enabled>true</enabled>
296290
</snapshots>
291+
<id>spring-snapshots</id>
292+
<name>Spring Snapshots</name>
293+
<url>https://repo.spring.io/snapshot</url>
297294
</repository>
298295
<repository>
299-
<id>spring-milestones</id>
300-
<name>Spring Milestones</name>
301-
<url>https://repo.spring.io/milestone</url>
302296
<snapshots>
303297
<enabled>false</enabled>
304298
</snapshots>
299+
<id>spring-milestones</id>
300+
<name>Spring Milestones</name>
301+
<url>https://repo.spring.io/milestone</url>
305302
</repository>
306303
</repositories>
307-
308304
<pluginRepositories>
309305
<pluginRepository>
310-
<id>spring-snapshots</id>
311-
<name>Spring Snapshots</name>
312-
<url>https://repo.spring.io/snapshot</url>
313306
<snapshots>
314307
<enabled>true</enabled>
315308
</snapshots>
309+
<id>spring-snapshots</id>
310+
<name>Spring Snapshots</name>
311+
<url>https://repo.spring.io/snapshot</url>
316312
</pluginRepository>
317313
<pluginRepository>
318-
<id>spring-milestones</id>
319-
<name>Spring Milestones</name>
320-
<url>https://repo.spring.io/milestone</url>
321314
<snapshots>
322315
<enabled>false</enabled>
323316
</snapshots>
317+
<id>spring-milestones</id>
318+
<name>Spring Milestones</name>
319+
<url>https://repo.spring.io/milestone</url>
324320
</pluginRepository>
325321
</pluginRepositories>
326322

@@ -335,11 +331,11 @@
335331
<executions>
336332
<execution>
337333
<id>unpack</id>
338-
<?m2e execute onConfiguration,onIncremental?>
339-
<phase>generate-resources</phase>
340334
<goals>
341335
<goal>unpack</goal>
342336
</goals>
337+
<?m2e execute onConfiguration,onIncremental?>
338+
<phase>generate-resources</phase>
343339
<configuration>
344340
<artifactItems>
345341
<artifactItem>
@@ -358,21 +354,20 @@
358354
<groupId>com.gitlab.haynes</groupId>
359355
<artifactId>libsass-maven-plugin</artifactId>
360356
<version>${libsass.version}</version>
357+
<configuration>
358+
<inputPath>${basedir}/src/main/scss/</inputPath>
359+
<outputPath>${basedir}/src/main/resources/static/resources/css/</outputPath>
360+
<includePath>${project.build.directory}/webjars/META-INF/resources/webjars/bootstrap/${webjars-bootstrap.version}/scss/</includePath>
361+
</configuration>
361362
<executions>
362363
<execution>
363-
<phase>generate-resources</phase>
364364
<?m2e execute onConfiguration,onIncremental?>
365365
<goals>
366366
<goal>compile</goal>
367367
</goals>
368+
<phase>generate-resources</phase>
368369
</execution>
369370
</executions>
370-
<configuration>
371-
<inputPath>${basedir}/src/main/scss/</inputPath>
372-
<outputPath>${basedir}/src/main/resources/static/resources/css/</outputPath>
373-
<includePath>
374-
${project.build.directory}/webjars/META-INF/resources/webjars/bootstrap/${webjars-bootstrap.version}/scss/</includePath>
375-
</configuration>
376371
</plugin>
377372
</plugins>
378373
</build>
@@ -406,7 +401,7 @@
406401
</goals>
407402
</pluginExecutionFilter>
408403
<action>
409-
<ignore />
404+
<ignore></ignore>
410405
</action>
411406
</pluginExecution>
412407
<pluginExecution>
@@ -419,7 +414,7 @@
419414
</goals>
420415
</pluginExecutionFilter>
421416
<action>
422-
<ignore />
417+
<ignore></ignore>
423418
</action>
424419
</pluginExecution>
425420
<pluginExecution>
@@ -432,7 +427,7 @@
432427
</goals>
433428
</pluginExecutionFilter>
434429
<action>
435-
<ignore />
430+
<ignore></ignore>
436431
</action>
437432
</pluginExecution>
438433
</pluginExecutions>
@@ -444,5 +439,4 @@
444439
</build>
445440
</profile>
446441
</profiles>
447-
448442
</project>

src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class MySqlIntegrationTests {
4646

4747
@ServiceConnection
4848
@Container
49-
static MySQLContainer<?> container = new MySQLContainer<>("mysql:9.0");
49+
static MySQLContainer<?> container = new MySQLContainer<>("mysql:9.1");
5050

5151
@LocalServerPort
5252
int port;

src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class MysqlTestApplication {
3636
@Profile("mysql")
3737
@Bean
3838
static MySQLContainer<?> container() {
39-
return new MySQLContainer<>("mysql:9.0");
39+
return new MySQLContainer<>("mysql:9.1");
4040
}
4141

4242
public static void main(String[] args) {

src/test/java/org/springframework/samples/petclinic/vet/VetTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.junit.jupiter.api.Test;
1919
import org.springframework.util.SerializationUtils;
2020

21-
import static org.junit.jupiter.api.Assertions.assertNotNull;
2221
import static org.assertj.core.api.Assertions.assertThat;
2322

2423
/**

0 commit comments

Comments
 (0)