Prerequisites
Relevant source files
The following files were used as context for generating this wiki page:This document outlines the necessary software and environmental configurations required to build, test, and run the gs-rest-service project. The project is a RESTful web service built using the Spring Framework. Adhering to these prerequisites ensures a smooth development and deployment process.
The core requirements include a specific version of the Java Development Kit (JDK) and a compatible build tool, either Maven or Gradle. The project is self-contained and includes wrapper scripts for both build tools, which simplifies the setup process by not requiring a system-wide installation of Maven or Gradle.
Java Development Kit (JDK)
The project requires Java version 17. This is explicitly defined in the project's Maven configuration. The build wrapper scripts also rely on the JAVA_HOME environment variable being correctly set to the location of your JDK installation.
Sources: complete/pom.xml:18, initial/pom.xml:18
Environment Variable
The Maven and Gradle wrapper scripts (mvnw.cmd, gradlew.bat) check for the JAVA_HOME environment variable to locate the Java executable. If this variable is not set or points to an invalid directory, the build will fail.
The following diagram illustrates the logic used by the wrapper scripts to find the Java executable.
This diagram shows the validation flow for the JAVA_HOME environment variable in the build scripts.
Build Tools
The project can be built using either Apache Maven or Gradle. The repository includes wrapper scripts for both, which is the recommended way to build the project. This ensures that a consistent version of the build tool is used without requiring a manual installation.
Sources: README.adoc:35, test/run.sh
Maven
The project is configured as a standard Maven project. The pom.xml file defines the project structure, dependencies, and build process.
Project Object Model (POM)
The pom.xml file specifies the core configuration for the Maven build.
| Element | Description |
|---|---|
spring-boot-starter-parent | Inherits default configurations and dependency management from Spring Boot. |
java.version | Specifies the required Java version, which is 17. |
spring-boot-starter-web | Provides dependencies for building web applications, including RESTful applications, using Spring MVC. It includes an embedded Tomcat server by default. |
spring-boot-starter-test | Provides dependencies for testing Spring Boot applications with libraries like JUnit Jupiter, Mockito, and Spring Test. |
spring-boot-maven-plugin | A plugin to package the application as an executable JAR file. |
Sources: complete/pom.xml:7-36, initial/pom.xml:7-36
The following diagram shows the dependency structure defined in the pom.xml.
This diagram illustrates the parent POM and key dependencies for the project.
Build Lifecycle
The run.sh script demonstrates the use of standard Maven goals to build the project.
clean: Removes thetargetdirectory.compile: Compiles the source code.package: Packages the compiled code into an executable JAR.
Sources: test/run.sh:4-16
Gradle
The project also supports Gradle as a build tool, indicated by the presence of Gradle wrapper files (gradlew, gradlew.bat) and its use in the test execution script.
The run.sh script uses the following Gradle tasks:
compileJava: Compiles the Java source files.build: Assembles and tests the project, creating a distributable archive.
Sources: test/run.sh:10-26, initial/gradlew.bat
Summary
To work with the gs-rest-service project, a developer must have JDK 17 installed and the JAVA_HOME environment variable configured. The project can then be built and run using the included Maven or Gradle wrapper scripts, which handle the download and execution of the appropriate build tool. No manual installation of Maven or Gradle is required.