Skip to content

Commit fa74125

Browse files
committed
feat: update dependencies; update doc; add github action
1 parent 6a710a9 commit fa74125

File tree

5 files changed

+85
-18
lines changed

5 files changed

+85
-18
lines changed

.github/workflows/maven.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Java CI with Maven
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
java-version: [ '21' ]
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
22+
- name: Set up JDK ${{ matrix.java-version }}
23+
uses: actions/setup-java@v2
24+
with:
25+
java-version: ${{ matrix.java-version }}
26+
distribution: 'temurin'
27+
28+
- name: Build with Maven
29+
run: ./mvnw -B package --file pom.xml
30+
31+
- name: Run tests
32+
run: ./mvnw test

README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# your-own-dependency-injection-framework
22

3-
It is very small project, that shows, how you can build your own dependency injection framework.
3+
![Build Status](https://github.com/your-username/your-own-dependency-injection-framework/actions/workflows/maven.yml/badge.svg)
44

5-
It suitable for **constructor** and **field** injection.
5+
This is a small project that demonstrates how to build your own dependency injection framework.
66

7-
- You can find the framework itself under "com.di.framework" package.
8-
- You can find sample application under tests.
7+
It supports **constructor** and **field** injection.
98

10-
### How you can use
9+
- The framework itself can be found under the "com.di.framework" package.
10+
- Sample applications are available under the tests.
1111

12-
##### 1. You have to define how you want to map interfaces to their implementations.
12+
### How to use
13+
14+
##### 1. Define how you want to map interfaces to their implementations.
1315

1416
```java
1517
public class DependencyInjectionConfig extends AbstractModule {
@@ -22,7 +24,7 @@ public class DependencyInjectionConfig extends AbstractModule {
2224
}
2325
```
2426

25-
##### 2. Add **@OwnInject** annotation to constructor or field.
27+
##### 2. Add **@OwnInject** annotation to the constructor or fields.
2628

2729
```java
2830
public class ConstructorInjectionClient {
@@ -65,10 +67,22 @@ public class SampleAppToTryDependencyInjection {
6567
}
6668
```
6769

68-
### How it works
70+
### How It Works
6971

7072
The two main classes are **AbstractModule** and **OwnDiFramework**.
7173

72-
* The **AbstractModule** contains interfaces with their implementations (subclasses).
73-
* The **OwnDiFramework** performs the injection via java reflection. It checks that the constructor or fields are annotated with **@OwnInject** annotation.
74+
* **AbstractModule** contains interfaces with their implementations (subclasses).
75+
* **OwnDiFramework** performs the injection via Java reflection. It checks that the constructor or fields are annotated with the **@OwnInject** annotation.
7476

77+
78+
### Running Tests
79+
80+
To execute tests, use the Maven Wrapper included in the project. Run the following command from the root directory of the project:
81+
82+
```sh
83+
./mvnw test
84+
```
85+
86+
This command will compile the project with Java 21 and run all the tests using JUnit.
87+
88+
If you encounter any issues or have any questions, please refer to the documentation or reach out for support.

mvnw

100644100755
File mode changed.

pom.xml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,37 @@
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<maven.compiler.source>1.8</maven.compiler.source>
16-
<maven.compiler.target>1.8</maven.compiler.target>
15+
<maven.compiler.source>21</maven.compiler.source>
16+
<maven.compiler.target>21</maven.compiler.target>
1717
</properties>
1818

1919
<dependencies>
2020
<dependency>
21-
<groupId>junit</groupId>
22-
<artifactId>junit</artifactId>
23-
<version>4.12</version>
21+
<groupId>org.junit.jupiter</groupId>
22+
<artifactId>junit-jupiter-api</artifactId>
23+
<version>5.10.2</version>
24+
<scope>test</scope>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.junit.jupiter</groupId>
28+
<artifactId>junit-jupiter-engine</artifactId>
29+
<version>5.10.2</version>
2430
<scope>test</scope>
2531
</dependency>
26-
2732
</dependencies>
2833

34+
<build>
35+
<plugins>
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-compiler-plugin</artifactId>
39+
<version>3.8.1</version>
40+
<configuration>
41+
<source>21</source>
42+
<target>21</target>
43+
</configuration>
44+
</plugin>
45+
</plugins>
46+
</build>
47+
2948
</project>

src/test/java/com/di/framework/OwnDiFrameworkTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.di.framework;
22

3-
import static org.junit.Assert.assertEquals;
3+
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
6+
import org.junit.jupiter.api.Test;
47

58
import com.di.framework.example.ConstructorInjectionExample;
6-
import org.junit.Test;
79

810
import com.di.framework.example.FieldInjectionExample;
911
import com.di.framework.example.service.CalculatorService;

0 commit comments

Comments
 (0)