Skip to content

Commit 2d37610

Browse files
authored
mapstruct#2011 Introduce gem as replacement of hickory:prism (mapstruct#2007)
1 parent 6b49c83 commit 2d37610

52 files changed

Lines changed: 836 additions & 772 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build-config/src/main/resources/build-config/import-control.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<!-- the annotation processor may not use the annotations or enums specified in org.mapstruct directly... -->
1111
<disallow pkg="org.mapstruct" exact-match="true" />
1212

13-
<subpackage name="internal.prism">
14-
<!-- ... with exception to the package org.mapstruct.ap.internal.prism -->
13+
<subpackage name="internal.gem">
14+
<!-- ... with exception to the package org.mapstruct.ap.internal.gem -->
1515
<allow pkg=".*" regex="true" />
1616
</subpackage>
1717
<subpackage name="test">

parent/pom.xml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<properties>
2323
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24-
<com.jolira.hickory.version>1.0.0</com.jolira.hickory.version>
24+
<org.mapstruct.gem.version>1.0.0.Alpha1</org.mapstruct.gem.version>
2525
<!-- We can't go to 3.0.0-M2 as it has a regression. See https://issues.apache.org/jira/browse/MENFORCER-306 -->
2626
<org.apache.maven.plugins.enforcer.version>3.0.0-M1</org.apache.maven.plugins.enforcer.version>
2727
<org.apache.maven.plugins.surefire.version>3.0.0-M3</org.apache.maven.plugins.surefire.version>
@@ -109,9 +109,14 @@
109109
<version>19.0</version>
110110
</dependency>
111111
<dependency>
112-
<groupId>com.jolira</groupId>
113-
<artifactId>hickory</artifactId>
114-
<version>${com.jolira.hickory.version}</version>
112+
<groupId>org.mapstruct.tools.gem</groupId>
113+
<artifactId>gem-api</artifactId>
114+
<version>${org.mapstruct.gem.version}</version>
115+
</dependency>
116+
<dependency>
117+
<groupId>org.mapstruct.tools.gem</groupId>
118+
<artifactId>gem-processor</artifactId>
119+
<version>${org.mapstruct.gem.version}</version>
115120
</dependency>
116121
<dependency>
117122
<groupId>junit</groupId>
@@ -287,7 +292,7 @@
287292
specified as patterns within a source folder, so we can't exclude generated-sources
288293
altogether
289294
-->
290-
<excludes>**/*Prism.java,*/itest/jaxb/xsd/*</excludes>
295+
<excludes>**/*Gem.java,*/itest/jaxb/xsd/*</excludes>
291296
</configuration>
292297
<dependencies>
293298
<dependency>
@@ -376,7 +381,7 @@
376381
<version>${org.apache.maven.plugins.javadoc.version}</version>
377382
<configuration>
378383
<quiet>true</quiet>
379-
<excludePackageNames>org.mapstruct.ap.internal.prism;org.mapstruct.itest.jaxb.xsd.*</excludePackageNames>
384+
<excludePackageNames>org.mapstruct.ap.internal.gem;org.mapstruct.itest.jaxb.xsd.*</excludePackageNames>
380385
<source>8</source>
381386
</configuration>
382387
</plugin>

processor/pom.xml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,9 @@
3232
<groupId>org.freemarker</groupId>
3333
<artifactId>freemarker</artifactId>
3434
</dependency>
35-
36-
<!-- Compile-only; Using "provided" scope as there is no such scope in Maven;
37-
these dependencies are not required at runtime, only for prism generation
38-
and tests -->
39-
<!-- Using optional as well due to IntelliJ picking up the dependency
40-
and running the hickory processor in projects using the mapstruct-processor.
41-
This happens only when the processor is defined in the maven-compiler annotationProcessorPaths -->
4235
<dependency>
43-
<groupId>com.jolira</groupId>
44-
<artifactId>hickory</artifactId>
45-
<scope>provided</scope>
46-
<optional>true</optional>
36+
<groupId>org.mapstruct.tools.gem</groupId>
37+
<artifactId>gem-api</artifactId>
4738
</dependency>
4839
<dependency>
4940
<groupId>${project.groupId}</groupId>
@@ -182,19 +173,37 @@
182173
</goals>
183174
<configuration>
184175
<minimizeJar>true</minimizeJar>
176+
<artifactSet>
177+
<includes>
178+
<include>org.freemarker:*</include>
179+
<include>org.mapstruct.tools.gem:gem-api</include>
180+
</includes>
181+
</artifactSet>
185182
<filters>
186183
<filter>
187184
<artifact>org.freemarker:freemarker</artifact>
188185
<excludes>
189186
<exclude>META-INF/*.*</exclude>
190187
</excludes>
191188
</filter>
189+
<filter>
190+
<artifact>org.mapstruct.tools.gem:gem-api</artifact>
191+
<excludes>
192+
<exclude>META-INF/*.*</exclude>
193+
<exclude>**/GemDefinition.class</exclude>
194+
<exclude>**/GemDefinitions.class</exclude>
195+
</excludes>
196+
</filter>
192197
</filters>
193198
<relocations>
194199
<relocation>
195200
<pattern>freemarker</pattern>
196201
<shadedPattern>org.mapstruct.ap.shaded.freemarker</shadedPattern>
197202
</relocation>
203+
<relocation>
204+
<pattern>org.mapstruct.tools.gem</pattern>
205+
<shadedPattern>org.mapstruct.ap.shaded.org.mapstruct.tools.gem</shadedPattern>
206+
</relocation>
198207
</relocations>
199208
</configuration>
200209
</execution>
@@ -227,9 +236,14 @@
227236
<groupId>org.apache.maven.plugins</groupId>
228237
<artifactId>maven-compiler-plugin</artifactId>
229238
<configuration>
230-
<annotationProcessors>
231-
<annotationProcessor>net.java.dev.hickory.prism.internal.PrismGenerator</annotationProcessor>
232-
</annotationProcessors>
239+
<annotationProcessorPaths>
240+
<path>
241+
<groupId>org.mapstruct.tools.gem</groupId>
242+
<artifactId>gem-processor</artifactId>
243+
<version>${org.mapstruct.gem.version}</version>
244+
</path>
245+
<!-- other annotation processors -->
246+
</annotationProcessorPaths>
233247
</configuration>
234248
</plugin>
235249
<plugin>

processor/src/main/java/org/mapstruct/ap/MappingProcessor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434

3535
import org.mapstruct.ap.internal.model.Mapper;
3636
import org.mapstruct.ap.internal.option.Options;
37-
import org.mapstruct.ap.internal.prism.MapperPrism;
38-
import org.mapstruct.ap.internal.prism.ReportingPolicyPrism;
37+
import org.mapstruct.ap.internal.gem.MapperGem;
38+
import org.mapstruct.ap.internal.gem.ReportingPolicyGem;
3939
import org.mapstruct.ap.internal.processor.DefaultModelElementProcessorContext;
4040
import org.mapstruct.ap.internal.processor.ModelElementProcessor;
4141
import org.mapstruct.ap.internal.processor.ModelElementProcessor.ProcessorContext;
@@ -66,8 +66,8 @@
6666
* <li>if no error occurred, write out the model into Java source files</li>
6767
* </ul>
6868
* <p>
69-
* For reading annotation attributes, prisms as generated with help of the <a
70-
* href="https://java.net/projects/hickory">Hickory</a> tool are used. These prisms allow a comfortable access to
69+
* For reading annotation attributes, gems as generated with help of the <a
70+
* href="https://java.net/projects/hickory">Hickory</a> tool are used. These gems allow a comfortable access to
7171
* annotations and their attributes without depending on their class objects.
7272
* <p>
7373
* The creation of Java source files is done using the <a href="http://freemarker.org/"> FreeMarker</a> template engine.
@@ -137,7 +137,7 @@ private Options createOptions() {
137137
return new Options(
138138
Boolean.valueOf( processingEnv.getOptions().get( SUPPRESS_GENERATOR_TIMESTAMP ) ),
139139
Boolean.valueOf( processingEnv.getOptions().get( SUPPRESS_GENERATOR_VERSION_INFO_COMMENT ) ),
140-
unmappedTargetPolicy != null ? ReportingPolicyPrism.valueOf( unmappedTargetPolicy.toUpperCase() ) : null,
140+
unmappedTargetPolicy != null ? ReportingPolicyGem.valueOf( unmappedTargetPolicy.toUpperCase() ) : null,
141141
processingEnv.getOptions().get( DEFAULT_COMPONENT_MODEL ),
142142
processingEnv.getOptions().get( DEFAULT_INJECTION_STRATEGY ),
143143
Boolean.valueOf( processingEnv.getOptions().get( ALWAYS_GENERATE_SERVICE_FILE ) ),
@@ -236,7 +236,7 @@ private Set<TypeElement> getMappers(final Set<? extends TypeElement> annotations
236236

237237
// on some JDKs, RoundEnvironment.getElementsAnnotatedWith( ... ) returns types with
238238
// annotations unknown to the compiler, even though they are not declared Mappers
239-
if ( mapperTypeElement != null && MapperPrism.getInstanceOn( mapperTypeElement ) != null ) {
239+
if ( mapperTypeElement != null && MapperGem.instanceOn( mapperTypeElement ) != null ) {
240240
mapperTypes.add( mapperTypeElement );
241241
}
242242
}

processor/src/main/java/org/mapstruct/ap/internal/prism/CollectionMappingStrategyPrism.java renamed to processor/src/main/java/org/mapstruct/ap/internal/gem/CollectionMappingStrategyGem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
*
44
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
55
*/
6-
package org.mapstruct.ap.internal.prism;
6+
package org.mapstruct.ap.internal.gem;
77

88
/**
9-
* Prism for the enum {@link org.mapstruct.CollectionMappingStrategy}
9+
* Gem for the enum {@link org.mapstruct.CollectionMappingStrategy}
1010
*
1111
* @author Andreas Gudian
1212
*/
13-
public enum CollectionMappingStrategyPrism {
13+
public enum CollectionMappingStrategyGem {
1414

1515
ACCESSOR_ONLY,
1616
SETTER_PREFERRED,
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright MapStruct Authors.
3+
*
4+
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
package org.mapstruct.ap.internal.gem;
7+
8+
import javax.xml.bind.annotation.XmlElementDecl;
9+
import javax.xml.bind.annotation.XmlElementRef;
10+
11+
import org.mapstruct.AfterMapping;
12+
import org.mapstruct.BeanMapping;
13+
import org.mapstruct.BeforeMapping;
14+
import org.mapstruct.Builder;
15+
import org.mapstruct.Context;
16+
import org.mapstruct.DecoratedWith;
17+
import org.mapstruct.InheritConfiguration;
18+
import org.mapstruct.InheritInverseConfiguration;
19+
import org.mapstruct.IterableMapping;
20+
import org.mapstruct.MapMapping;
21+
import org.mapstruct.Mapper;
22+
import org.mapstruct.MapperConfig;
23+
import org.mapstruct.Mapping;
24+
import org.mapstruct.MappingTarget;
25+
import org.mapstruct.Mappings;
26+
import org.mapstruct.Named;
27+
import org.mapstruct.ObjectFactory;
28+
import org.mapstruct.Qualifier;
29+
import org.mapstruct.TargetType;
30+
import org.mapstruct.ValueMapping;
31+
import org.mapstruct.ValueMappings;
32+
import org.mapstruct.tools.gem.GemDefinition;
33+
34+
/**
35+
* Triggers the generation of ge types using <a href="https://java.net/projects/hickory">Hickory</a>.
36+
*
37+
* @author Gunnar Morling
38+
*/
39+
@GemDefinition(Mapper.class)
40+
@GemDefinition(Mapping.class)
41+
@GemDefinition(Mappings.class)
42+
@GemDefinition(IterableMapping.class)
43+
@GemDefinition(BeanMapping.class)
44+
@GemDefinition(MapMapping.class)
45+
@GemDefinition(TargetType.class)
46+
@GemDefinition(MappingTarget.class)
47+
@GemDefinition(DecoratedWith.class)
48+
@GemDefinition(MapperConfig.class)
49+
@GemDefinition(InheritConfiguration.class)
50+
@GemDefinition(InheritInverseConfiguration.class)
51+
@GemDefinition(Qualifier.class)
52+
@GemDefinition(Named.class)
53+
@GemDefinition(ObjectFactory.class)
54+
@GemDefinition(AfterMapping.class)
55+
@GemDefinition(BeforeMapping.class)
56+
@GemDefinition(ValueMapping.class)
57+
@GemDefinition(ValueMappings.class)
58+
@GemDefinition(Context.class)
59+
@GemDefinition(Builder.class)
60+
61+
// external types
62+
@GemDefinition(XmlElementDecl.class)
63+
@GemDefinition(XmlElementRef.class)
64+
public class GemGenerator {
65+
}

processor/src/main/java/org/mapstruct/ap/internal/prism/InjectionStrategyPrism.java renamed to processor/src/main/java/org/mapstruct/ap/internal/gem/InjectionStrategyGem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
*
44
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
55
*/
6-
package org.mapstruct.ap.internal.prism;
6+
package org.mapstruct.ap.internal.gem;
77

88
/**
9-
* Prism for the enum {@link org.mapstruct.InjectionStrategy}.
9+
* Gem for the enum {@link org.mapstruct.InjectionStrategy}.
1010
*
1111
* @author Kevin Grüneberg
1212
*/
13-
public enum InjectionStrategyPrism {
13+
public enum InjectionStrategyGem {
1414

1515
FIELD,
1616
CONSTRUCTOR;

processor/src/main/java/org/mapstruct/ap/internal/prism/MappingConstantsPrism.java renamed to processor/src/main/java/org/mapstruct/ap/internal/gem/MappingConstantsGem.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
*
44
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
55
*/
6-
package org.mapstruct.ap.internal.prism;
6+
package org.mapstruct.ap.internal.gem;
77

88
/**
9-
* Prism for the enum {@link org.mapstruct.MappingConstants}
9+
* Gem for the enum {@link org.mapstruct.MappingConstants}
1010
*
1111
* @author Sjaak Derksen
1212
*/
13-
public final class MappingConstantsPrism {
13+
public final class MappingConstantsGem {
1414

15-
private MappingConstantsPrism() {
15+
private MappingConstantsGem() {
1616
}
1717

1818
public static final String NULL = "<NULL>";

processor/src/main/java/org/mapstruct/ap/internal/prism/MappingInheritanceStrategyPrism.java renamed to processor/src/main/java/org/mapstruct/ap/internal/gem/MappingInheritanceStrategyGem.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
*
44
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
55
*/
6-
package org.mapstruct.ap.internal.prism;
6+
package org.mapstruct.ap.internal.gem;
77

88

99
/**
10-
* Prism for the enum {@link org.mapstruct.MappingInheritanceStrategy}
10+
* Gem for the enum {@link org.mapstruct.MappingInheritanceStrategy}
1111
*
1212
* @author Andreas Gudian
1313
*/
14-
public enum MappingInheritanceStrategyPrism {
14+
public enum MappingInheritanceStrategyGem {
1515

1616
EXPLICIT( false, false, false ),
1717
AUTO_INHERIT_FROM_CONFIG( true, true, false ),
@@ -22,7 +22,7 @@ public enum MappingInheritanceStrategyPrism {
2222
private final boolean applyForward;
2323
private final boolean applyReverse;
2424

25-
MappingInheritanceStrategyPrism(boolean isAutoInherit, boolean applyForward, boolean applyReverse) {
25+
MappingInheritanceStrategyGem(boolean isAutoInherit, boolean applyForward, boolean applyReverse) {
2626
this.autoInherit = isAutoInherit;
2727
this.applyForward = applyForward;
2828
this.applyReverse = applyReverse;

processor/src/main/java/org/mapstruct/ap/internal/prism/NullValueCheckStrategyPrism.java renamed to processor/src/main/java/org/mapstruct/ap/internal/gem/NullValueCheckStrategyGem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
*
44
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
55
*/
6-
package org.mapstruct.ap.internal.prism;
6+
package org.mapstruct.ap.internal.gem;
77

88

99
/**
10-
* Prism for the enum {@link org.mapstruct.NullValueCheckStrategy}
10+
* Gem for the enum {@link org.mapstruct.NullValueCheckStrategy}
1111
*
1212
* @author Sean Huang
1313
*/
14-
public enum NullValueCheckStrategyPrism {
14+
public enum NullValueCheckStrategyGem {
1515

1616
ON_IMPLICIT_CONVERSION,
1717
ALWAYS;

0 commit comments

Comments
 (0)