Skip to content

Commit 1a54666

Browse files
committed
Minor code fixes; Implemented swagger and added license and readme files; Updated pom versions to latest using "versions-maven-plugin"; Dockerized application; Switched maven compiler version to 21 due to alpine 3.20 available openjdk version
1 parent 803b654 commit 1a54666

File tree

13 files changed

+338
-22
lines changed

13 files changed

+338
-22
lines changed

Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Stage 1: Build the Spring Boot application
2+
FROM amazoncorretto:21-alpine AS build
3+
4+
# Install necessary build tools
5+
RUN apk add --no-cache maven
6+
7+
# Set the working directory
8+
WORKDIR /app
9+
10+
# Copy the Maven project files
11+
COPY pom.xml /app/
12+
COPY src /app/src/
13+
14+
# Build the application
15+
RUN mvn clean package -DskipTests
16+
17+
# Stage 2: Create an image with RabbitMQ and your Spring Boot application
18+
FROM rabbitmq:3.13.7-management-alpine AS final
19+
20+
# Install necessary runtime packages
21+
RUN apk add --no-cache openjdk21-jdk \
22+
&& rabbitmq-plugins enable --offline rabbitmq_mqtt \
23+
&& rabbitmq-plugins enable --offline rabbitmq_web_mqtt
24+
25+
# Copy the Spring Boot application from the build stage
26+
COPY --from=build /app/target/softwaredevelopmentsimulation-1.3.0.jar /app/software-development-simulation.jar
27+
28+
# Add a health check for RabbitMQ
29+
HEALTHCHECK --interval=10s --timeout=3s --retries=3 \
30+
CMD nc -z localhost 5672 || exit 1
31+
32+
# Expose ports for RabbitMQ and Spring Boot application
33+
EXPOSE 5672 15672 15675 21682
34+
35+
# Start RabbitMQ and wait for it to be ready before starting the Spring Boot application
36+
CMD sh -c "rabbitmq-server & \
37+
until nc -z localhost 5672; do \
38+
echo 'Waiting for RabbitMQ...'; \
39+
sleep 1; \
40+
done; \
41+
java -jar /app/software-development-simulation.jar"
42+
43+
LABEL maintainer="Marko Dojkic <[email protected]>" \
44+
version="1.3.0" \
45+
description="Docker image for the Software Development Simulation Spring Boot application" \
46+
org.opencontainers.image.source="https://github.com/MarkoDojkic/Software-Development-Simulation" \
47+
org.opencontainers.image.documentation="https://github.com/MarkoDojkic/Software-Development-Simulation#readme" \
48+
org.opencontainers.image.licenses="MIT"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Marko Dojkić
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Software Development Simulation
2+
3+
[![Software-Development-Simulation-Main-Build](https://github.com/MarkoDojkic/Software-Development-Simulation/actions/workflows/build.yml/badge.svg)](https://github.com/MarkoDojkic/Software-Development-Simulation/actions/workflows/build.yml)
4+
![SonarQube Security Rating](https://img.shields.io/badge/SonarQube%20Security%20Rating-A-brightgreen)
5+
![SonarQube Quality Gate](https://img.shields.io/badge/SonarQube%20Quality%20Gate-Passed-brightgreen)
6+
![SonarQube Duplicated Lines](https://img.shields.io/badge/SonarQube%20Duplicated%20Lines-0%25-brightgreen)
7+
![SonarQube LOC](https://img.shields.io/badge/SonarQube%20LOC-2000-blue)
8+
![JaCoCo Coverage](https://img.shields.io/badge/JaCoCo%20Coverage-93.5%25-brightgreen)
9+
10+
**Note:** SonarQube information is based on the last GitHub Action run and is generated locally. As such, there is no direct link available to the SonarQube dashboard.
11+
12+
## Overview
13+
14+
The Software Development Simulation project is a web-based application designed to simulate and manage software development tasks. It utilizes Spring Boot for backend services, Spring Integration for messaging, and integrates with Swagger for API documentation.
15+
16+
## Features
17+
18+
- **Spring Boot Application**: Built with Spring Boot 3.3.3.
19+
- **Spring Integration**: Configured with multiple channels for task management.
20+
- **Swagger Documentation**: Integrated for API documentation and testing.
21+
- **SonarQube Integration**: Quality and security analysis with all issues resolved.
22+
- **JaCoCo Test Coverage**: 100% class and method test coverage.
23+
24+
## Setup
25+
26+
1. **Clone the Repository**
27+
28+
```bash
29+
git clone https://github.com/MarkoDojkic/Software-Development-Simulation.git
30+
31+
2. **Build the Project**
32+
33+
```bash
34+
mvn clean install
35+
36+
3. **Run the Application**
37+
38+
```bash
39+
mvn spring-boot:run
40+
41+
The application will run on port `21682`. RabbitMQ is required with rabbitmq_mqtt and rabbitmq_web_mqtt plugins enabled and active on port `15675`.
42+
43+
## Docker Setup
44+
45+
To build and run the application using Docker, follow these steps:
46+
47+
### Dockerfile
48+
49+
The `Dockerfile` is set up to build and package the application into a Docker image. It uses Maven to build the JAR file and then packages it into a minimal Java runtime image.
50+
51+
### Build and Run the Docker Image
52+
53+
1. **Build the Docker image:**
54+
55+
```bash
56+
docker build -t software-development-simulation .
57+
```
58+
59+
2. **Run the Docker container:**
60+
61+
```bash
62+
docker run -p 5672:5672 -p 15672:15672 -p 15675:15675 -p 21682:21682 software-development-simulation
63+
```
64+
65+
This will build the Docker image and run the application.
66+
NOTE: Before running docker container make sure that no instances of `RabbitMQ` are already active because it will interfere with `docker image RabbitMQ` and messages won`t get through.
67+
68+
**Access Swagger UI**
69+
70+
Navigate to `http://localhost:21682/swagger-ui.html` to access the Swagger UI.
71+
72+
## Spring Integration Channels
73+
74+
The application utilizes various Spring Integration channels for processing different types of messages. Below is a summary of the key channels and their purposes:
75+
76+
1. **Error Channels**
77+
78+
- `errorChannel`: Handles general errors.
79+
- `errorChannel.mqtt.input`: Sends error messages to MQTT for frontend integration.
80+
- `errorChannel.logFile.input`: Saves error messages to log file for persistent storage.
81+
82+
2. **Information Channels**
83+
84+
- `information.input`: Receives general information.
85+
- `information.mqtt.input`: Sends information to MQTT for frontend integration.
86+
- `information.logFile.input`: Saves information to log file for persistent storage.
87+
88+
3. **Jira Activity Stream Channels**
89+
90+
- `jiraActivityStream.input`: Receives Jira activity stream messages.
91+
- `jiraActivityStream.mqtt.input`: Sends Jira activity stream messages to MQTT for frontend integration.
92+
- `jiraActivityStream.logFile.input`: Saves Jira activity stream messages to log file for persistent storage.
93+
94+
4. **Epic Channels**
95+
96+
- `epicMessage.input`: Receives messages related to epics with priority handling.
97+
98+
5. **Control Bus Channel**
99+
100+
- `controlBus.input`: Handles control bus messages for managing flows.
101+
102+
6. **Current Sprint Channels**
103+
104+
- `currentSprintEpic.input`: Receives epics for the current sprint.
105+
- `currentSprintUserStories`: Receives user stories for the current sprint using splitter from `currentSprintEpic.input`.
106+
107+
7. **In Progress Channels**
108+
109+
- `inProgressEpic`: Receives epics that are currently in progress.
110+
- `inProgressUserStory`: Receives user stories that are currently in progress.
111+
112+
8. **Done Channels**
113+
114+
- `doneEpics.output`: Receives completed epics.
115+
- `doneSprintUserStories.output`: Receives completed user stories.
116+
- `doneTechnicalTasks`: Receives completed technical tasks.
117+
118+
9. **Technical Task Channels**
119+
120+
- `toDoTechnicalTasks`: Receives technical tasks that are to be done.
121+
- `trivialTechnicalTaskQueue.input` A`normalTechnicalTaskQueue.input`, `minorTechnicalTaskQueue.input`, `majorTechnicalTaskQueue.input`, `criticalTechnicalTaskQueue.input`, `blockerTechnicalTaskQueue.input`: Receive technical tasks of various priorities.
122+
- `trivialTechnicalTask`, `normalTechnicalTask`, `minorTechnicalTask`, `majorTechnicalTask`, `criticalTechnicalTask`, `blockerTechnicalTask`: Handle technical tasks based on priority.
123+
124+
Each channel is configured to handle specific message types and priorities, ensuring efficient processing and management of tasks and messages within the application. Channels that send messages to MQTT or save to log files are specifically set up to facilitate frontend integration and persistent logging.
125+
126+

pom.xml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<url>https://github.com/MarkoDojkic/Software-Development-Simulation</url>
1212
<licenses>
1313
<license>
14-
<name>Apache License, Version 2.0</name>
15-
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
14+
<name>MIT License</name>
15+
<url>https://github.com/MarkoDojkic/Software-Development-Simulation/blob/main/LICENSE</url>
1616
<distribution>repo</distribution>
1717
</license>
1818
</licenses>
@@ -138,15 +138,22 @@
138138
<dependency>
139139
<groupId>com.google.guava</groupId>
140140
<artifactId>guava</artifactId>
141-
<version>33.2.1-jre</version>
141+
<version>33.3.0-jre</version>
142+
<scope>compile</scope>
143+
</dependency>
144+
<dependency>
145+
<groupId>org.springdoc</groupId>
146+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
147+
<version>2.6.0</version>
142148
<scope>compile</scope>
143149
</dependency>
144150

151+
145152
<!-- Tests -->
146153
<dependency>
147154
<groupId>org.hamcrest</groupId>
148155
<artifactId>hamcrest</artifactId>
149-
<version>3.0-rc1</version>
156+
<version>3.0</version>
150157
<scope>test</scope>
151158
</dependency>
152159
<dependency>
@@ -182,13 +189,13 @@
182189
<dependency>
183190
<groupId>org.mockito</groupId>
184191
<artifactId>mockito-junit-jupiter</artifactId>
185-
<version>5.12.0</version>
192+
<version>5.13.0</version>
186193
<scope>test</scope>
187194
</dependency>
188195
<dependency>
189196
<groupId>io.moquette</groupId>
190197
<artifactId>moquette-broker</artifactId>
191-
<version>0.15</version>
198+
<version>0.17</version>
192199
<scope>test</scope>
193200
<exclusions>
194201
<exclusion>
@@ -241,8 +248,8 @@
241248
<artifactId>maven-compiler-plugin</artifactId>
242249
<version>3.13.0</version>
243250
<configuration>
244-
<source>22</source>
245-
<target>22</target>
251+
<source>21</source>
252+
<target>21</target>
246253
</configuration>
247254
</plugin>
248255
<plugin>
@@ -283,6 +290,11 @@
283290
</argLine>
284291
</configuration>
285292
</plugin>
293+
<plugin>
294+
<groupId>org.codehaus.mojo</groupId>
295+
<artifactId>versions-maven-plugin</artifactId>
296+
<version>2.17.1</version>
297+
</plugin>
286298
</plugins>
287299
</build>
288300
<repositories>

src/main/java/dev/markodojkic/softwaredevelopmentsimulation/SoftwareDevelopmentSimulationApp.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ public static void main(String[] args) {
2828
updateDevelopmentTeamsSetup(new DevelopmentTeamCreationParameters());
2929

3030
try {
31-
getIGateways().sendToInfo(String.format("Welcome to Software development simulator™ Developed by Ⓒ Marko Dojkić 2024%nSize occupied by predefined data is: %.2f KB%nI hope you will enjoy using my spring integration web-based application", (double) Files.size(getCurrentApplicationDataPath()) / 1024));
31+
getIGateways().sendToInfo(String.format("Welcome to Software development simulator™ Developed by Ⓒ Marko Dojkić 2024%nSize occupied by appliaction user data is: %.2f KB%nI hope you will enjoy using my spring integration web-based application", (double) Files.size(getCurrentApplicationDataPath()) / 1024));
3232
} catch (IOException e) {
33-
getIGateways().sendToInfo(String.format("Welcome to Software development simulator™ Developed by Ⓒ Marko Dojkić 2024%nSize occupied by predefined data is: %.2f KB%nI hope you will enjoy using my spring integration web-based application", 0.00));
33+
getIGateways().sendToInfo(String.format("Welcome to Software development simulator™ Developed by Ⓒ Marko Dojkić 2024%nSize occupied by appliaction user data is: %.2f KB%nI hope you will enjoy using my spring integration web-based application", 0.00));
3434
}
35-
36-
//TODO: Implement swagger, explain controllers and write readme
3735
}
3836
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package dev.markodojkic.softwaredevelopmentsimulation.config;
2+
3+
import io.swagger.v3.oas.models.ExternalDocumentation;
4+
import io.swagger.v3.oas.models.OpenAPI;
5+
import io.swagger.v3.oas.models.info.Info;
6+
import io.swagger.v3.oas.models.info.License;
7+
import org.springdoc.core.models.GroupedOpenApi;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.Configuration;
10+
11+
@Configuration
12+
public class SwaggerConfig {
13+
14+
@Bean
15+
public OpenAPI customOpenAPI() {
16+
return new OpenAPI()
17+
.info(new Info().title("Software development simulator™ API")
18+
.description("This is the API documentation for the Software development simulator™ Developed by Ⓒ Marko Dojkić")
19+
.version("v1.3.0")
20+
.license(new License().name("Apache 2.0").url("https://springdoc.org")))
21+
.externalDocs(new ExternalDocumentation()
22+
.description("GitHub Repository")
23+
.url("https://github.com/MarkoDojkic/Software-Development-Simulation"));
24+
}
25+
26+
@Bean
27+
public GroupedOpenApi apiGroup() {
28+
return GroupedOpenApi.builder()
29+
.group("api")
30+
.pathsToMatch("/api/**")
31+
.build();
32+
}
33+
}

0 commit comments

Comments
 (0)