Skip to content

Commit 9591440

Browse files
authored
Merge branch 'main' into 379-specify-model-namespace-packages
2 parents fb3bd67 + 730a00c commit 9591440

File tree

18 files changed

+93
-25
lines changed

18 files changed

+93
-25
lines changed

documentation/developer-guide/modules/tooling-guide/pages/java-aspect-tooling.adoc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,23 +152,24 @@ include::esmf-developer-guide:ROOT:partial$esmf-aspect-meta-model-java-artifact.
152152
[[understanding-model-resolution]]
153153
=== Understanding Model Resolution
154154

155-
The example in the last section showed how a self-contained Aspect Model file can be loaded (i.e., a file that
156-
does not refer to model element definitions in other files or namespaces). Whenever models are loaded that
157-
could contain such references, or you want to load a model element by URN, the AspectModelLoader relies on
158-
so-called _resolution strategies_. A resolution strategy is a function that takes a model element identifier
159-
(a model element URN) as an input and returns the content of the file that contains the corresponding model
160-
element definition. Note that this is not necessarily a file in the local filesystem, but it could also be a
161-
remote file or even exist only virtually as a collection of statements in an RDF triple store. Several
162-
`ResolutionStrategy`s are provided that can be instantiated and passed to the `AspectModelLoader` constructor
163-
to enable it to find model element definitions:
155+
The example in the last section showed how a self-contained Aspect Model file can be loaded (i.e., a
156+
file that does not refer to model element definitions in other files or namespaces). Whenever models
157+
are loaded that could contain such references, or you want to load a model element by URN, the
158+
AspectModelLoader relies on so-called _resolution strategies_. A resolution strategy is a function
159+
that takes a model element identifier (a model element URN) as an input and returns the content of
160+
the file that contains the corresponding model element definition. Note that this is not necessarily
161+
a file in the local filesystem, but it could also be a remote file or even exist only virtually as a
162+
collection of statements in an RDF triple store. Several `ResolutionStrategy`​s are provided
163+
that can be instantiated and passed to the `AspectModelLoader` constructor to enable it to find
164+
model element definitions:
164165

165166
* The `FileSystemStrategy` resolves elements from files in the file system which are either structured in the
166167
xref:tooling-guide:samm-cli.adoc#models-directory-structure[models directory structure] or exist as flat
167168
list of files in one directory (by using `FileSystemStrategy` with a `FlatModelsRoot`).
168169
* The `ClassPathStrategy` resolves model elements from resources in the Java class path.
169170
* The `FromLoadedFileStrategy` resolves model elements from an `AspectModelFile` that already resides in
170171
memory.
171-
* The `EitherStrategy` can be used to chain two or more different `ResolutionStrategy`s.
172+
* The `EitherStrategy` can be used to chain two or more different `ResolutionStrategy`​s.
172173
* The `ExternalResolverStrategy` delegates resolution to an external command such as a script; it is used in
173174
the implementation of the `--custom-resolver` option of the xref:tooling-guide:samm-cli.adoc[samm-cli].
174175

documentation/developer-guide/modules/tooling-guide/pages/maven-plugin.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ are replaced using `packageName` | `String` | none | {nok}
118118
| `templateFile` | The path and name of the velocity template file containing the macro library. See xref:java-aspect-tooling.adoc#providing-custom-macros-for-code-generation[Providing Custom Macros for Code Generation]. | `String` | none | {nok}
119119
| `executeLibraryMacros` | Execute the macros provided in the velocity macro library. | `Boolean` | `false` | {nok}
120120
| `disableJacksonAnnotations` | Leads to generated Java code that does not contain https://github.com/FasterXML/jackson[Jackson] annotations. | `Boolean` | `false` | {nok}
121+
| `skip` | Skip execution of plugin and generation | `Boolean` | `false` | {nok}
121122
|===
122123

123124
=== Generate Static Meta Classes
@@ -265,7 +266,7 @@ Configuration Properties:
265266
| `aspectApiBaseUrl` | The base URL for the Aspect API OpenAPI specification. | `String` | none | {ok}
266267
| `aspectParameterFile` | The path to a file including the schema description for the resource. For JSON the description has to be in json, for YAML it has to be in YAML. | `String` | none | {nok}
267268
| `useSemanticApiVersion` | Use the complete semantic version of the Aspect Model as the version of the Aspect API. | `Boolean` | `false` | {nok}
268-
| `aspectResourcePath` | The resource-path` for the Aspect API endpoints. | `String` | none | {nok}
269+
| `aspectResourcePath` | The `resource-path` for the Aspect API endpoints. | `String` | none | {nok}
269270
| `includeQueryApi` | Include the path for the Query Aspect API Endpoint in the OpenAPI specification. | `Boolean` | `false` | {nok}
270271
| `includeFullCrud` | Include the POST/PUT/PATCH methods in the OpenAPI specification. | `Boolean` | `false` | {nok}
271272
| `includePost` | Include the POST method in the OpenAPI specification. | `Boolean` | `false` | {nok}

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/AspectModelMojo.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import io.vavr.control.Either;
3838
import org.apache.maven.plugin.AbstractMojo;
3939
import org.apache.maven.plugin.MojoExecutionException;
40+
import org.apache.maven.plugin.MojoFailureException;
4041
import org.apache.maven.plugins.annotations.Parameter;
4142

4243
public abstract class AspectModelMojo extends AbstractMojo {
@@ -52,6 +53,12 @@ public abstract class AspectModelMojo extends AbstractMojo {
5253
@Parameter( defaultValue = "false" )
5354
protected boolean detailedValidationMessages;
5455

56+
/**
57+
* Skip the execution.
58+
*/
59+
@Parameter( name = "skip", property = "gen.skip", defaultValue = "false" )
60+
private Boolean skip;
61+
5562
protected void validateParameters() throws MojoExecutionException {
5663
if ( includes == null || includes.isEmpty() ) {
5764
throw new MojoExecutionException( "Missing configuration. Please provide Aspect Models to be included." );
@@ -101,4 +108,15 @@ protected FileOutputStream getOutputStreamForFile( final String artifactName, fi
101108
throw new RuntimeException( "Could not write to output " + outputDirectory );
102109
}
103110
}
111+
112+
@Override
113+
public void execute() throws MojoExecutionException, MojoFailureException {
114+
if ( Boolean.TRUE.equals( skip ) ) {
115+
getLog().info( "Generation is skipped." );
116+
return;
117+
}
118+
executeGeneration();
119+
}
120+
121+
abstract void executeGeneration() throws MojoExecutionException, MojoFailureException;
104122
}

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateAas.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class GenerateAas extends AspectModelMojo {
3232
private String targetFormat;
3333

3434
@Override
35-
public void execute() throws MojoExecutionException, MojoFailureException {
35+
public void executeGeneration() throws MojoExecutionException, MojoFailureException {
3636
validateParameters();
3737
final Set<Aspect> aspects = loadAspects();
3838
final AspectModelAasGenerator generator = new AspectModelAasGenerator();

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateAspectFromAas.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@Mojo( name = "generateAspectFromAas", defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
3333
public class GenerateAspectFromAas extends AspectModelMojo {
3434
@Override
35-
public void execute() throws MojoExecutionException, MojoFailureException {
35+
public void executeGeneration() throws MojoExecutionException, MojoFailureException {
3636
validateParameters();
3737
for ( final String include : includes ) {
3838
final AasToAspectModelGenerator generator = AasToAspectModelGenerator.fromFile( new File( include ) );

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateAsyncApiSpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class GenerateAsyncApiSpec extends AspectModelMojo {
5757
private String language;
5858

5959
@Override
60-
public void execute() throws MojoExecutionException, MojoFailureException {
60+
public void executeGeneration() throws MojoExecutionException, MojoFailureException {
6161
final Set<Aspect> aspects = loadAspects();
6262
final Locale locale = Optional.ofNullable( language ).map( Locale::forLanguageTag ).orElse( Locale.ENGLISH );
6363
final ApiFormat format = Try.of( () -> ApiFormat.valueOf( outputFormat.toUpperCase() ) )

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateDiagram.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class GenerateDiagram extends AspectModelMojo {
3636
private Set<String> targetFormats;
3737

3838
@Override
39-
public void execute() throws MojoExecutionException {
39+
public void executeGeneration() throws MojoExecutionException {
4040
validateParameters();
4141

4242
final Set<Aspect> aspects = loadAspects();

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateDocumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class GenerateDocumentation extends AspectModelMojo {
3838
private final String htmlCustomCssFilePath = "";
3939

4040
@Override
41-
public void execute() throws MojoExecutionException {
41+
public void executeGeneration() throws MojoExecutionException {
4242
validateParameters();
4343

4444
try {

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateJavaClasses.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class GenerateJavaClasses extends CodeGenerationMojo {
3737
private boolean disableJacksonAnnotations;
3838

3939
@Override
40-
public void execute() throws MojoExecutionException {
40+
public void executeGeneration() throws MojoExecutionException {
4141
final Set<Aspect> aspects = loadAspects();
4242
for ( final Aspect aspect : aspects ) {
4343
final File templateLibFile = Path.of( templateFile ).toFile();

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateJsonPayload.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class GenerateJsonPayload extends AspectModelMojo {
3131
private static final Logger LOG = LoggerFactory.getLogger( GenerateJsonPayload.class );
3232

3333
@Override
34-
public void execute() throws MojoExecutionException, MojoFailureException {
34+
public void executeGeneration() throws MojoExecutionException, MojoFailureException {
3535
validateParameters();
3636

3737
final Set<Aspect> aspects = loadAspects();

0 commit comments

Comments
 (0)