Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ObjectMapper generation #143

Merged
merged 2 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To use the plugin you need Gradle version 5.6 or later, to start add the followi

```groovy
plugins {
id "co.com.bancolombia.cleanArchitecture" version "1.9.0"
id "co.com.bancolombia.cleanArchitecture" version "1.9.1"
}
```

Expand Down
2 changes: 1 addition & 1 deletion config/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set -e

REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"

files=$((git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.java$") || true)
files=$(git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.java$" || true)
if [ ! -z "${files}" ]; then
comma_files=$(echo "$files" | paste -s -d "," -)
"${REPO_ROOT_DIR}/gradlew" goJF -DgoogleJavaFormat.include="$comma_files" &>/dev/null
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
package=co.com.bancolombia
systemProp.version=1.9.0
systemProp.version=1.9.1
2 changes: 1 addition & 1 deletion src/main/java/co/com/bancolombia/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Constants {
public static final String COBERTURA_VERSION = "3.0.0";
public static final String RCOMMONS_ASYNC_COMMONS_STARTER_VERSION = "1.0.0-beta5";
public static final String RCOMMONS_OBJECT_MAPPER_VERSION = "0.1.0";
public static final String PLUGIN_VERSION = "1.9.0";
public static final String PLUGIN_VERSION = "1.9.1";
public static final String TOMCAT_EXCLUSION =
"compile.exclude group: \"org.springframework.boot\", module:\"spring-boot-starter-tomcat\"";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import co.com.bancolombia.exceptions.CleanException;
import co.com.bancolombia.factory.ModuleBuilder;
import co.com.bancolombia.factory.ModuleFactory;
import co.com.bancolombia.factory.commons.ObjectMapperFactory;
import java.io.IOException;

public class DrivenAdapterJPA implements ModuleFactory {
Expand All @@ -23,5 +24,6 @@ public void buildModule(ModuleBuilder builder) throws IOException, CleanExceptio
if (builder.getBooleanParam("include-secret")) {
new DrivenAdapterSecrets().buildModule(builder);
}
new ObjectMapperFactory().buildModule(builder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import co.com.bancolombia.exceptions.CleanException;
import co.com.bancolombia.factory.ModuleBuilder;
import co.com.bancolombia.factory.ModuleFactory;
import co.com.bancolombia.factory.commons.ObjectMapperFactory;
import java.io.IOException;
import org.gradle.api.logging.Logger;

Expand All @@ -23,5 +24,6 @@ public void buildModule(ModuleBuilder builder) throws IOException, CleanExceptio
if (builder.getBooleanParam("include-secret")) {
new DrivenAdapterSecrets().buildModule(builder);
}
new ObjectMapperFactory().buildModule(builder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import co.com.bancolombia.exceptions.CleanException;
import co.com.bancolombia.factory.ModuleBuilder;
import co.com.bancolombia.factory.ModuleFactory;
import co.com.bancolombia.factory.commons.ObjectMapperFactory;
import java.io.IOException;
import lombok.AllArgsConstructor;
import org.gradle.api.logging.Logger;
Expand All @@ -28,6 +29,7 @@ public void buildModule(ModuleBuilder builder) throws IOException, CleanExceptio
if (builder.getBooleanParam("include-secret")) {
new DrivenAdapterSecrets().buildModule(builder);
}
new ObjectMapperFactory().buildModule(builder);
}

protected String getPathMode(Mode mode) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package co.com.bancolombia.factory.commons;

import co.com.bancolombia.Constants;
import co.com.bancolombia.exceptions.CleanException;
import co.com.bancolombia.factory.ModuleBuilder;
import co.com.bancolombia.factory.ModuleFactory;
import java.io.IOException;

public class ObjectMapperFactory implements ModuleFactory {

@Override
public void buildModule(ModuleBuilder builder) throws IOException, CleanException {
builder.setupFromTemplate("commons/object-mapper");
builder.appendDependencyToModule(
"app-service",
"compile 'org.reactivecommons.utils:object-mapper:"
+ Constants.RCOMMONS_OBJECT_MAPPER_VERSION
+ "'");
}
}
6 changes: 6 additions & 0 deletions src/main/resources/commons/object-mapper/definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"folders": [],
"files": {
"commons/object-mapper/object-mapper-config.java.mustache": "applications/app-service/src/main/java/{{packagePath}}/config/ObjectMapperConfig.java"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package {{package}}.config;

import org.reactivecommons.utils.ObjectMapper;
import org.reactivecommons.utils.ObjectMapperImp;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ObjectMapperConfig {

@Bean
public ObjectMapper objectMapper() {
return new ObjectMapperImp();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dependencies {
compile project(':model')
compile 'org.springframework.boot:spring-boot-starter-data-redis-reactive'
compile 'org.reactivecommons.utils:object-mapper:0.1.0'
implementation 'org.reactivecommons.utils:object-mapper-api:{{objectMapperVersion}}'

testCompile 'org.reactivecommons.utils:object-mapper:{{objectMapperVersion}}'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ dependencies {
compile project(':model')
compile 'org.springframework.boot:spring-boot-starter-data-redis-reactive'
compile 'com.fasterxml.jackson.core:jackson-databind'
compile 'org.reactivecommons.utils:object-mapper:0.1.0'
implementation 'org.reactivecommons.utils:object-mapper-api:{{objectMapperVersion}}'

testCompile 'org.reactivecommons.utils:object-mapper:{{objectMapperVersion}}'
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dependencies {
compile project(':model')
compile 'org.springframework.boot:spring-boot-starter-data-redis'
compile 'org.reactivecommons.utils:object-mapper:0.1.0'
implementation 'org.reactivecommons.utils:object-mapper-api:{{objectMapperVersion}}'

testCompile 'org.reactivecommons.utils:object-mapper:{{objectMapperVersion}}'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ dependencies {
compile project(':model')
compile 'org.springframework.boot:spring-boot-starter-data-redis'
compile 'com.fasterxml.jackson.core:jackson-databind'
compile 'org.reactivecommons.utils:object-mapper:0.1.0'
implementation 'org.reactivecommons.utils:object-mapper-api:{{objectMapperVersion}}'

testCompile 'org.reactivecommons.utils:object-mapper:{{objectMapperVersion}}'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dependencies {
implementation project(':model')
implementation project(':usecase')
compile 'org.springframework.boot:spring-boot-starter'
{{#reactive}}compile 'org.reactivecommons.utils:object-mapper:{{objectMapperVersion}}'{{/reactive}}
runtime('org.springframework.boot:spring-boot-devtools')
}

Expand Down