split into dedicated gradle modules

This commit is contained in:
Tom Hombergs
2019-06-14 12:47:49 +02:00
parent d8592c65ec
commit d28fa49d90
40 changed files with 168 additions and 60 deletions

View File

@@ -0,0 +1,23 @@
dependencies {
implementation project(':common')
implementation project(':application')
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'junit' // excluding junit 4
}
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.1'
testImplementation 'org.mockito:mockito-junit-jupiter:2.23.0'
testImplementation 'com.tngtech.archunit:archunit:0.9.3'
testImplementation 'de.adesso:junit-insights:1.1.0'
testImplementation 'org.junit.platform:junit-platform-launcher:1.4.2'
}
test {
useJUnitPlatform()
systemProperty 'de.adesso.junitinsights.enabled', 'true'
}

View File

@@ -1,13 +1,23 @@
package io.reflectoring.reviewapp.adapter.persistence;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
import org.springframework.data.jdbc.repository.config.JdbcConfiguration;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@Configuration
@EnableJdbcRepositories
@ComponentScan
class PersistenceAdapterConfiguration extends JdbcConfiguration {
@Bean
NamedParameterJdbcOperations namedParameterJdbcOperations(DataSource dataSource) {
return new NamedParameterJdbcTemplate(dataSource);
}
}

View File

@@ -3,6 +3,7 @@ package io.reflectoring.reviewapp.adapter.persistence;
import io.reflectoring.reviewapp.domain.Author;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
@@ -10,7 +11,7 @@ import org.springframework.test.context.jdbc.SqlGroup;
import static org.assertj.core.api.Assertions.*;
@SpringBootTest
@DataJdbcTest
class AuthorPersistenceAdapterTest {
@Autowired

View File

@@ -3,6 +3,7 @@ package io.reflectoring.reviewapp.adapter.persistence;
import io.reflectoring.reviewapp.domain.Book;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
@@ -12,7 +13,7 @@ import java.util.Optional;
import static org.assertj.core.api.Assertions.*;
@SpringBootTest
@DataJdbcTest
class BookPersistenceAdapterTest {
@Autowired

View File

@@ -1,11 +1,9 @@
package io.reflectoring.reviewapp.adapter.persistence;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Import;
@SpringBootConfiguration
@EnableAutoConfiguration
@Import(PersistenceAdapterConfiguration.class)
public class PersistenceAdapterTestConfiguration {
class PersistenceAdapterTestConfiguration {
}

22
adapters/web/build.gradle Normal file
View File

@@ -0,0 +1,22 @@
dependencies {
implementation project(':common')
implementation project(':application')
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'junit' // excluding junit 4
}
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.1'
testImplementation 'org.mockito:mockito-junit-jupiter:2.23.0'
testImplementation 'com.tngtech.archunit:archunit:0.9.3'
testImplementation 'de.adesso:junit-insights:1.1.0'
testImplementation 'org.junit.platform:junit-platform-launcher:1.4.2'
}
test {
useJUnitPlatform()
systemProperty 'de.adesso.junitinsights.enabled', 'true'
}

View File

@@ -0,0 +1,23 @@
package io.reflectoring.reviewapp.adapter.web;
import io.reflectoring.reviewapp.application.port.in.RegisterBookUseCase;
import io.reflectoring.reviewapp.application.port.in.RegisterBookUseCase.RegisterBookCommand;
import io.reflectoring.reviewapp.domain.Book;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
class RegisterBookController {
private final RegisterBookUseCase registerBookUseCase;
@PostMapping(path = "/books/register")
void registerBook(@RequestBody Book book) {
RegisterBookCommand command = new RegisterBookCommand(book.getTitle(), book.getAuthorId());
registerBookUseCase.registerBook(command);
}
}

31
application/build.gradle Normal file
View File

@@ -0,0 +1,31 @@
dependencies {
implementation project(':common')
implementation 'org.springframework:spring-context'
implementation 'org.springframework:spring-core'
implementation 'javax.validation:validation-api'
// Needed for Spring Data annotations on domain entities.
// This is a shortcut to avoid a mapping step between domain and persistence!
implementation 'org.springframework.data:spring-data-commons'
implementation 'org.springframework.boot:spring-boot-starter-validation'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'junit' // excluding junit 4
}
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.1'
testImplementation 'org.mockito:mockito-junit-jupiter:2.23.0'
testImplementation 'com.tngtech.archunit:archunit:0.9.3'
testImplementation 'de.adesso:junit-insights:1.1.0'
testImplementation 'org.junit.platform:junit-platform-launcher:1.4.2'
}
test {
useJUnitPlatform()
systemProperty 'de.adesso.junitinsights.enabled', 'true'
}

View File

@@ -1,41 +1,29 @@
plugins {
id 'org.springframework.boot' version '2.1.4.RELEASE'
id 'java'
id "io.spring.dependency-management" version "1.0.6.RELEASE"
}
apply plugin: 'io.spring.dependency-management'
allprojects {
group = 'io.reflectoring'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
group = 'io.reflectoring.reviewapp'
version = '0.0.1-SNAPSHOT'
configurations {
compileOnly {
extendsFrom annotationProcessor
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
repositories {
jcenter()
}
}
repositories {
jcenter()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'junit' // excluding junit 4
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.1.5.RELEASE")
}
}
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.1'
testImplementation 'org.mockito:mockito-junit-jupiter:2.23.0'
testImplementation 'com.tngtech.archunit:archunit:0.9.3'
testImplementation 'de.adesso:junit-insights:1.1.0'
testImplementation 'org.junit.platform:junit-platform-launcher:1.4.2'
}
test {
useJUnitPlatform()
systemProperty 'de.adesso.junitinsights.enabled', 'true'
}

6
common/build.gradle Normal file
View File

@@ -0,0 +1,6 @@
dependencies {
implementation 'org.springframework:spring-context'
implementation 'org.springframework:spring-core'
implementation 'javax.validation:validation-api'
}

View File

@@ -0,0 +1,23 @@
plugins {
id "org.springframework.boot" version "2.1.5.RELEASE"
}
dependencies {
implementation project(':common')
implementation project(':application')
implementation project(':adapters:persistence')
implementation project(':adapters:web')
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'junit' // excluding junit 4
}
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.1'
testImplementation 'org.mockito:mockito-junit-jupiter:2.23.0'
testImplementation 'com.tngtech.archunit:archunit:0.9.3'
testImplementation 'de.adesso:junit-insights:1.1.0'
testImplementation 'org.junit.platform:junit-platform-launcher:1.4.2'
}

View File

@@ -2,7 +2,6 @@ package io.reflectoring.reviewapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
@SpringBootApplication
public class BookReviewerApplication {

1
gradle.properties Normal file
View File

@@ -0,0 +1 @@
springboot_version=2.1.5.RELEASE

View File

@@ -1,6 +1,5 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
}
rootProject.name = 'clean-architecture-example'
include 'common'
include 'application'
include 'adapters:persistence'
include 'adapters:web'
include 'configuration'

View File

@@ -1,4 +0,0 @@
package io.reflectoring.reviewapp.adapter.morepersistence;
class AnotherEntity {
}

View File

@@ -1,13 +0,0 @@
package io.reflectoring.reviewapp.adapter.morepersistence;
import lombok.RequiredArgsConstructor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
class AnotherPersistenceAdapter {
private final CrudRepository<AnotherEntity, Long> anotherRepository;
}