Skip to content

Commit

Permalink
Add mapstruct integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawi01 committed Nov 14, 2024
1 parent 9a26dd0 commit 133fd89
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/manual/mapstructIntegration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/out
*.jar
27 changes: 27 additions & 0 deletions test/manual/mapstructIntegration/runTests
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -euo pipefail
echo 'This will build a project with mapstruct. If the compilation works without error or warning, lombok is working as designed.'

wget --no-clobber https://repo1.maven.org/maven2/org/mapstruct/mapstruct/1.6.2/mapstruct-1.6.2.jar
wget --no-clobber https://repo1.maven.org/maven2/org/mapstruct/mapstruct-processor/1.6.2/mapstruct-processor-1.6.2.jar

LOMBOK=../../../dist/lombok.jar
BINDING=../../../dist/lombok-mapstruct-binding-0.3.0.jar

# wget --no-clobber https://repo1.maven.org/maven2/org/projectlombok/lombok/1.18.34/lombok-1.18.34.jar
# wget --no-clobber https://repo1.maven.org/maven2/org/projectlombok/lombok-mapstruct-binding/0.2.0/lombok-mapstruct-binding-0.2.0.jar
# LOMBOK=lombok-1.18.34.jar
# BINDING=lombok-mapstruct-binding-0.2.0.jar

mkdir -p out

javac \
-proc:full \
--class-path mapstruct-1.6.2.jar:mapstruct-processor-1.6.2.jar:$LOMBOK:$BINDING \
-d out \
src/*

if ! grep -q 'to.setTest( from.getTest() );' 'out/MapperImpl.java'; then
echo 'Mapstruct does not detect lombok getters!' >&2
exit 1
fi
27 changes: 27 additions & 0 deletions test/manual/mapstructIntegration/src/From.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2024 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import lombok.Data;

@Data
public class From {
private String test;
}
25 changes: 25 additions & 0 deletions test/manual/mapstructIntegration/src/Mapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2024 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.mapstruct.Mapper
public interface Mapper {
To map(From from);
}
27 changes: 27 additions & 0 deletions test/manual/mapstructIntegration/src/To.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2024 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import lombok.Data;

@Data
public class To {
private String test;
}

0 comments on commit 133fd89

Please sign in to comment.