diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml new file mode 100644 index 0000000..c24c121 --- /dev/null +++ b/.github/workflows/gradle-build.yml @@ -0,0 +1,31 @@ +# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + java: [ '17' ] + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{matrix.java}} + uses: actions/setup-java@v4 + with: + java-version: ${{matrix.java}} + distribution: 'adopt' + cache: maven + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Build with Gradle + run: ./gradlew build diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 4718a6c..a1ec4da 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -1,5 +1,5 @@ # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven name: Java CI with Maven @@ -26,4 +26,4 @@ jobs: distribution: 'adopt' cache: maven - name: Build with Maven Wrapper - run: ./mvnw -B package + run: ./mvnw -B verify diff --git a/.gitignore b/.gitignore index c92e0b4..d2767ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ HELP.md +pom.xml.bak target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/**/target/ @@ -41,6 +42,9 @@ out/ ### VS Code ### .vscode/ +### SDK Man ### +.sdkmanrc + ### CSS ### _site/ *.css diff --git a/readme.md b/README.md similarity index 92% rename from readme.md rename to README.md index dea0758..bb3fe97 100644 --- a/readme.md +++ b/README.md @@ -1,4 +1,4 @@ -# 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) +# 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) [![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) @@ -29,14 +29,6 @@ Or you can run it from Maven directly using the Spring Boot Maven plugin. If you > NOTE: If you prefer to use Gradle, you can build the app using `./gradlew build` and look for the jar file in `build/libs`. -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: - -```bash -./mvnw spring-boot:test-run -Dspring-boot.run.main-class=org.springframework.samples.petclinic.PetClinicIntegrationTests -``` - -Or you can run it in your IDE directly from the test class of your choice. - ## Building a Container 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,8 +44,7 @@ Our issue tracker is available [here](https://github.com/spring-projects/spring- ## Database configuration In its default configuration, Petclinic uses an in-memory database (H2) which -gets populated at startup with data. If you launch the app from the integration tests, the h2 console is automatically -exposed at `http://localhost:8080/h2-console`, +gets populated at startup with data. The h2 console is exposed at `http://localhost:8080/h2-console`, and it is possible to inspect the content of the database using the `jdbc:h2:mem:` URL. The UUID is printed at startup to the console. 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. @@ -61,7 +52,7 @@ A similar setup is provided for MySQL and PostgreSQL if a persistent database co You can start MySQL or PostgreSQL locally with whatever installer works for your OS or use docker: ```bash -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 +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 ``` or diff --git a/build.gradle b/build.gradle index 21baa9a..a5175df 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.3.4' + id 'org.springframework.boot' version '3.3.5' id 'io.spring.dependency-management' version '1.1.6' id 'org.graalvm.buildtools.native' version '0.10.3' id 'org.cyclonedx.bom' version '1.10.0' @@ -25,7 +25,7 @@ repositories { mavenCentral() } -ext.checkstyleVersion = "10.18.1" +ext.checkstyleVersion = "10.20.0" ext.springJavaformatCheckstyleVersion = "0.0.43" ext.webjarsFontawesomeVersion = "4.7.0" ext.webjarsBootstrapVersion = "5.3.3" diff --git a/docker-compose.yml b/docker-compose.yml index 7d41b57..8fdaacb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: mysql: - image: mysql:9.0 + image: mysql:9.1 ports: - "3306:3306" environment: diff --git a/pom.xml b/pom.xml index e327681..3d7f28f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,18 +1,18 @@ - + 4.0.0 - org.springframework.samples - spring-petclinic - 3.3.0-SNAPSHOT org.springframework.boot spring-boot-starter-parent - 3.3.4 - + 3.3.5 + + + org.springframework.samples + spring-petclinic + 3.3.0-SNAPSHOT + petclinic @@ -28,11 +28,11 @@ 5.3.3 4.7.0 - 10.18.1 + 10.20.0 0.8.12 0.2.29 1.0.0 - 3.5.0 + 3.6.0 0.0.11 0.0.43 @@ -171,10 +171,10 @@ ${spring-format.version} - validate validate + validate @@ -197,19 +197,17 @@ nohttp-checkstyle-validation + + check + validate src/checkstyle/nohttp-checkstyle.xml ${basedir} **/* **/.git/**/*,**/.idea/**/*,**/target/**/,**/.flattened-pom.xml,**/*.class - - config_loc=${basedir}/src/checkstyle/ - + config_loc=${basedir}/src/checkstyle/ - - check - @@ -250,10 +248,10 @@ report - prepare-package report + prepare-package @@ -271,14 +269,13 @@ - + org.cyclonedx cyclonedx-maven-plugin - Apache License, Version 2.0 @@ -288,39 +285,38 @@ - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot true + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot - spring-milestones - Spring Milestones - https://repo.spring.io/milestone false + spring-milestones + Spring Milestones + https://repo.spring.io/milestone - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot true + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot - spring-milestones - Spring Milestones - https://repo.spring.io/milestone false + spring-milestones + Spring Milestones + https://repo.spring.io/milestone @@ -335,11 +331,11 @@ unpack - - generate-resources unpack + + generate-resources @@ -358,21 +354,20 @@ com.gitlab.haynes libsass-maven-plugin ${libsass.version} + + ${basedir}/src/main/scss/ + ${basedir}/src/main/resources/static/resources/css/ + ${project.build.directory}/webjars/META-INF/resources/webjars/bootstrap/${webjars-bootstrap.version}/scss/ + - generate-resources compile + generate-resources - - ${basedir}/src/main/scss/ - ${basedir}/src/main/resources/static/resources/css/ - - ${project.build.directory}/webjars/META-INF/resources/webjars/bootstrap/${webjars-bootstrap.version}/scss/ - @@ -406,7 +401,7 @@ - + @@ -419,7 +414,7 @@ - + @@ -432,7 +427,7 @@ - + @@ -444,5 +439,4 @@ - diff --git a/src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java b/src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java index 31231d7..d67e449 100644 --- a/src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java +++ b/src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java @@ -46,7 +46,7 @@ class MySqlIntegrationTests { @ServiceConnection @Container - static MySQLContainer container = new MySQLContainer<>("mysql:9.0"); + static MySQLContainer container = new MySQLContainer<>("mysql:9.1"); @LocalServerPort int port; diff --git a/src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java b/src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java index 96b71ec..8c7560a 100644 --- a/src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java +++ b/src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java @@ -36,7 +36,7 @@ public class MysqlTestApplication { @Profile("mysql") @Bean static MySQLContainer container() { - return new MySQLContainer<>("mysql:9.0"); + return new MySQLContainer<>("mysql:9.1"); } public static void main(String[] args) { diff --git a/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java b/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java index ec1aacf..b29c6d1 100644 --- a/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java +++ b/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java @@ -18,7 +18,6 @@ package org.springframework.samples.petclinic.vet; import org.junit.jupiter.api.Test; import org.springframework.util.SerializationUtils; -import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.assertj.core.api.Assertions.assertThat; /**