Skip to content

Commit 4e6722c

Browse files
authored
Add sample for mapstruct on testclasspath with lombok (#118)
1 parent b8937d2 commit 4e6722c

16 files changed

Lines changed: 427 additions & 0 deletions

File tree

mapstruct-lombok/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@ sourceCompatibility = JavaVersion.VERSION_1_8
1818
dependencies {
1919
implementation "org.mapstruct:mapstruct:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}"
2020
testImplementation 'junit:junit:4.13.1'
21+
22+
/*
23+
this example uses lombok directly over the annotationProcessor,
24+
the io.freefair.lombok plugin works as well.
25+
The freefair-lombok plugin is used in the example mapstruct-on-gradle-testcp-with-lombok
26+
*/
2127
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}", "org.projectlombok:lombok-mapstruct-binding:${lombokMapstructBindingVersion}"
2228
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
id 'java'
3+
id "io.freefair.lombok" version "6.0.0-m2"
4+
}
5+
6+
repositories {
7+
mavenCentral()
8+
}
9+
10+
dependencies {
11+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
12+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
13+
14+
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
15+
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
16+
17+
testAnnotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
18+
}
19+
20+
test {
21+
useJUnitPlatform()
22+
}
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

mapstruct-on-gradle-testcp-with-lombok/gradlew

Lines changed: 185 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mapstruct-on-gradle-testcp-with-lombok/gradlew.bat

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootProject.name = 'mapstruct-gradle-in-testclasses'
2+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package de.beanfactory.samples.mapstruct.mapper;
2+
3+
import de.beanfactory.samples.mapstruct.model.SourceBean;
4+
import de.beanfactory.samples.mapstruct.model.TargetBean;
5+
import org.mapstruct.Mapper;
6+
7+
@Mapper
8+
public interface SourceTargetMapper {
9+
10+
public TargetBean map(SourceBean source);
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package de.beanfactory.samples.mapstruct.model;
2+
3+
import lombok.Data;
4+
5+
@Data
6+
public class SourceBean {
7+
int id;
8+
String data;
9+
10+
public SourceBean(int id, String data) {
11+
this.id = id;
12+
this.data = data;
13+
}
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package de.beanfactory.samples.mapstruct.model;
2+
3+
import lombok.Data;
4+
5+
@Data
6+
public class TargetBean {
7+
int id;
8+
String data;
9+
}

0 commit comments

Comments
 (0)