|
16 | 16 | import java.util.Set;
|
17 | 17 |
|
18 | 18 | import org.eclipse.esmf.aspectmodel.generator.json.AspectModelJsonPayloadGenerator;
|
| 19 | +import org.eclipse.esmf.aspectmodel.generator.json.JsonPayloadGenerationConfig; |
| 20 | +import org.eclipse.esmf.aspectmodel.generator.json.JsonPayloadGenerationConfigBuilder; |
19 | 21 | import org.eclipse.esmf.metamodel.Aspect;
|
20 | 22 |
|
21 | 23 | import org.apache.maven.plugin.MojoExecutionException;
|
22 | 24 | import org.apache.maven.plugin.MojoFailureException;
|
23 | 25 | import org.apache.maven.plugins.annotations.LifecyclePhase;
|
24 | 26 | import org.apache.maven.plugins.annotations.Mojo;
|
| 27 | +import org.apache.maven.plugins.annotations.Parameter; |
25 | 28 | import org.slf4j.Logger;
|
26 | 29 | import org.slf4j.LoggerFactory;
|
27 | 30 |
|
28 | 31 | @Mojo( name = "generateJsonPayload", defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
|
29 | 32 | public class GenerateJsonPayload extends AspectModelMojo {
|
30 | 33 | private static final Logger LOG = LoggerFactory.getLogger( GenerateJsonPayload.class );
|
31 | 34 |
|
| 35 | + @Parameter( defaultValue = "false" ) |
| 36 | + private boolean addTypeAttribute; |
| 37 | + |
32 | 38 | @Override
|
33 | 39 | public void executeGeneration() throws MojoExecutionException, MojoFailureException {
|
34 | 40 | validateParameters();
|
35 | 41 |
|
36 | 42 | final Set<Aspect> aspects = loadAspects();
|
37 | 43 | for ( final Aspect context : aspects ) {
|
38 |
| - final AspectModelJsonPayloadGenerator generator = new AspectModelJsonPayloadGenerator( context ); |
| 44 | + final JsonPayloadGenerationConfig config = JsonPayloadGenerationConfigBuilder.builder() |
| 45 | + .addTypeAttributeForEntityInheritance( addTypeAttribute ) |
| 46 | + .build(); |
| 47 | + final AspectModelJsonPayloadGenerator generator = new AspectModelJsonPayloadGenerator( context, config ); |
39 | 48 | generator.generate( name -> getOutputStreamForFile( name + ".json", outputDirectory ) );
|
40 | 49 | }
|
41 | 50 | LOG.info( "Successfully generated example JSON payloads for Aspect Models." );
|
|
0 commit comments