Skip to content

Commit e688814

Browse files
committed
Document custom model resolution in Maven plugin
1 parent 0b17772 commit e688814

File tree

1 file changed

+71
-3
lines changed

1 file changed

+71
-3
lines changed

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

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ To include the plugin, use the following dependency:
1818
</dependency>
1919
----
2020

21-
[NOTE]
22-
====
21+
[[model-resolution]]
22+
== Model Resolution in the Maven Plugin
23+
2324
The current implementation of the `esmf-aspect-model-maven-plugin` uses the
2425
`FileSystemStrategy` or the `GitHubStrategy`, or combination of both, to resolve Aspect Models. See
2526
xref:java-aspect-tooling.adoc#understanding-model-resolution[Understanding Model Resolution] for
@@ -55,7 +56,9 @@ Settings] should contain a corresonding `<server>` entry:
5556
</servers>
5657
</settings>
5758
----
58-
====
59+
60+
It is possible to provide a custom model resolution strategy to the
61+
`esmf-aspect-model-maven-plugin`. See section <<custom-model-resolution>> for more information.
5962

6063
== Validating an Aspect Model
6164

@@ -880,3 +883,68 @@ Configuration Properties:
880883
| `includes` | A list of AAS files to convert. | `String` | none | {ok}
881884
| `outputDirectory` | The path to the directory where the generated Aspect Models will be written to. | `String` | none | {ok}
882885
|===
886+
887+
[[custom-model-resolution]]
888+
== Custom Model Resolution
889+
890+
It is possible to provide a custom model resolution strategy implementation to the
891+
`esmf-aspect-model-maven-plugin` that is used instead of the
892+
xref:maven-plugin.adoc#model-resolution[built-in resolution strategies]. This is done using the Java
893+
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/ServiceLoader.html[ServiceLoader].
894+
To provide your own resolution strategy, you need to:
895+
896+
. Create a class that implements `org.eclipse.esmf.aspectmodel.resolver.ResolutionStrategy`.
897+
. Register the class as a service: create a file
898+
`META-INF/services/org.eclipse.esmf.aspectmodel.resolver.ResolutionStrategy` that contains one line
899+
with the fully qualified name of your resolver class.
900+
. Bundle your class as a Maven artifact. In order to use your custom resolver with the
901+
`esmf-aspect-model-maven-plugin`, declare your artifact as a plugin dependency:
902+
+
903+
[source,xml,subs=attributes+]
904+
----
905+
<build>
906+
<plugins>
907+
<plugin>
908+
<artifactId>esmf-aspect-model-maven-plugin</artifactId>
909+
<dependencies>
910+
<dependency>
911+
<groupId>your.resolver.group.id</groupId>
912+
<artifactId>your.resolver.artifact.id</artifactId>
913+
<version>1.0.0</version>
914+
</dependency>
915+
</dependencies>
916+
<configuration>
917+
<!-- ... -->
918+
</configuration>
919+
</plugin>
920+
</plugins>
921+
</build>
922+
----
923+
924+
In order to enable users of your custom resolver to pass arguments to your resolver implementation,
925+
they can use a block called `<resolutionConfiguration>` in the plugin `<configuration>`:
926+
927+
[source,xml,subs=attributes+]
928+
----
929+
<build>
930+
<plugins>
931+
<plugin>
932+
<artifactId>esmf-aspect-model-maven-plugin</artifactId>
933+
<!-- ... -->
934+
<configuration>
935+
<resolutionConfiguration>
936+
<my.custom.property>...</my.custom.property>
937+
</resolutionConfiguration>
938+
</configuration>
939+
</plugin>
940+
</plugins>
941+
</build>
942+
----
943+
944+
The ResolutionStrategy implementation can access these properties using `System.getProperty()`,
945+
e.g.:
946+
947+
[source,java,subs=attributes+]
948+
----
949+
String myCustomProperty = System.getProperty("my.custom.property");
950+
----

0 commit comments

Comments
 (0)