-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maven plugin for Helidon Service Inject
- Loading branch information
1 parent
43301ef
commit c192431
Showing
25 changed files
with
3,140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Maven Plugin | ||
--- | ||
|
||
The Helidon Service Maven Plugin provides the following goals: | ||
|
||
1. Create application artifacts (`create-application`, `create-test-application`) | ||
|
||
# Create application artifacts Maven goals | ||
|
||
This goal creates artifacts that are only valid for the service (assembled from libraries and its own sources). | ||
This goal generates: | ||
|
||
1. Application Binding - a mapping of services to injection points (to bypass runtime lookups) - generates class `Injection__Binding` | ||
2. Application Main - a generated main class that registers all services (to bypass service discovery) - generates class `ApplicationMain` | ||
|
||
Usage of this plugin goal is not required, yet it is recommended for final application module, it will add | ||
- binding for injection points, to avoid runtime lookups | ||
- explicit registration of all services into `InjectConfig`, to avoid resource lookup and reflection at runtime | ||
- overall speedup of bootstrapping, as all the required tasks to start a service registry are code generated | ||
|
||
This goal should not be used for library modules (i.e. modules that do not have a Main class that bootstraps registry). | ||
|
||
## Usage | ||
|
||
Goal names: | ||
|
||
- `create-application` - for production sources | ||
- `create-test-application` - for test sources (only creates binding, main class not relevant) | ||
|
||
Configuration options: | ||
|
||
| Name | Property | Default | Description | | ||
|--------------------|-------------------------------------------------|------------------------|---------------------------------------------------------------------------------| | ||
| `packageName` | `helidon.codegen.package-name` | Inferred from module | Package to put the generated classes in | | ||
| `moduleName` | `helidon.codegen.module-name` | Inferred from module | Name of the JPMS module | | ||
| `validate` | `helidon.inject.application.validate` | `true` | Whether to validate application | | ||
| `createMain` | `helidon.inject.application.main.generate` | `true` | Whether to create application Main class | | ||
| `mainClassName` | `helidon.inject.application.main.class.name` | `ApplicationMain` | Name of the generated Main class | | ||
| `createBinding` | `helidon.inject.application.binding.generate` | `true` | Whether to create application binding | | ||
| `bindingClassName` | `helidon.inject.application.binding.class.name` | `Application__Binding` | Name of the generated binding class, for test, it is `TestApplication__Binding` | | ||
| `failOnError` | `helidon.inject.fail-on-error` | `true` | Whether to fail when the plugin encounters an error | | ||
| `failOnWarning` | `helidon.inject.fail-on-warning` | `false` | Whether to fail when the plugin encounters a warning | | ||
| `compilerArgs` | | | Arguments of the Java compiler (both classes are compiled by the plugin) | | ||
|
||
Configuration example in `pom.xml`: | ||
|
||
```xml | ||
|
||
<plugin> | ||
<groupId>io.helidon.service</groupId> | ||
<artifactId>helidon-service-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>create-application</id> | ||
<goals> | ||
<goal>create-application</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<packageName>com.example.mypackage</packageName> | ||
<bindingClassName>MyInjection__Binding</bindingClassName> | ||
<mainClassName>MyApplicationMain</mainClassName> | ||
<validate>false</validate> | ||
</configuration> | ||
</plugin> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2024 Oracle and/or its affiliates. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<FindBugsFilter | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://github.com/spotbugs/filter/3.0.0" | ||
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd"> | ||
|
||
<Match> | ||
<!-- Path comes from config or code --> | ||
<Class name="io.helidon.service.inject.maven.plugin.CreateApplicationAbstractMojo"/> | ||
<Bug pattern="PATH_TRAVERSAL_IN"/> | ||
</Match> | ||
<Match> | ||
<!-- Classpath is constructed from maven classpath --> | ||
<Class name="io.helidon.service.inject.maven.plugin.CreateApplicationAbstractMojo"/> | ||
<Bug pattern="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED"/> | ||
</Match> | ||
|
||
<Match> | ||
<!-- Path comes from config or code --> | ||
<Class name="io.helidon.service.inject.maven.plugin.CreateTestApplicationMojo"/> | ||
<Bug pattern="PATH_TRAVERSAL_IN"/> | ||
</Match> | ||
</FindBugsFilter> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2023, 2024 Oracle and/or its affiliates. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.helidon.service.inject</groupId> | ||
<artifactId>helidon-service-inject-project</artifactId> | ||
<version>4.2.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>helidon-service-inject-maven-plugin</artifactId> | ||
<name>Helidon Service Maven Plugin</name> | ||
<packaging>maven-plugin</packaging> | ||
|
||
<properties> | ||
<version.plexus.classworlds>2.7.0</version.plexus.classworlds> | ||
<version.plexus.utils>3.3.0</version.plexus.utils> | ||
<version.plugin.api>3.9.3</version.plugin.api> | ||
<version.plugin.annotations>3.9.0</version.plugin.annotations> | ||
<version.plugin.plugin>3.9.0</version.plugin.plugin> | ||
<version.plugin.project>2.2.1</version.plugin.project> | ||
|
||
<spotbugs.exclude>etc/spotbugs/exclude.xml</spotbugs.exclude> | ||
</properties> | ||
|
||
<reporting> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-plugin-plugin</artifactId> | ||
<reportSets> | ||
<reportSet> | ||
<reports> | ||
<report>report</report> | ||
</reports> | ||
</reportSet> | ||
</reportSets> | ||
</plugin> | ||
</plugins> | ||
</reporting> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-artifact</artifactId> | ||
<version>${version.plugin.api}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model</artifactId> | ||
<version>${version.plugin.api}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- normal dependencies --> | ||
<dependency> | ||
<groupId>io.helidon.common</groupId> | ||
<artifactId>helidon-common</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.common</groupId> | ||
<artifactId>helidon-common-types</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.codegen</groupId> | ||
<artifactId>helidon-codegen-class-model</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.service</groupId> | ||
<artifactId>helidon-service-registry</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.service</groupId> | ||
<artifactId>helidon-service-codegen</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.service.inject</groupId> | ||
<artifactId>helidon-service-inject-codegen</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.service</groupId> | ||
<artifactId>helidon-service-metadata</artifactId> | ||
</dependency> | ||
<dependency> | ||
<!-- | ||
we cannot use helidon-service-inject as the SPI is required on classpath of application, | ||
and this introduces conflicts; API is small and does not introduce SPI | ||
that is used from within it, so we can share it | ||
--> | ||
<groupId>io.helidon.service.inject</groupId> | ||
<artifactId>helidon-service-inject-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.codegen</groupId> | ||
<artifactId>helidon-codegen</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.codegen</groupId> | ||
<artifactId>helidon-codegen-scan</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.codegen</groupId> | ||
<artifactId>helidon-codegen-compiler</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.classgraph</groupId> | ||
<artifactId>classgraph</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
<version>${version.plugin.api}</version> | ||
<scope>provided</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-classworlds</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-utils</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.plugin-tools</groupId> | ||
<artifactId>maven-plugin-annotations</artifactId> | ||
<version>${version.plugin.annotations}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-project</artifactId> | ||
<version>${version.plugin.project}</version> | ||
<scope>provided</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-utils</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-artifact</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-plugin-plugin</artifactId> | ||
<version>${version.plugin.plugin}</version> | ||
<configuration> | ||
<mojoDependencies> | ||
<!-- we need this since 19ea is not really supported --> | ||
<!-- <mojoDependency></mojoDependency>--> | ||
</mojoDependencies> | ||
<requiredMavenVersion>[3.6.1,)</requiredMavenVersion> | ||
<requiredJavaVersion>[${version.java}.0,)</requiredJavaVersion> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<compilerArgument>-proc:none</compilerArgument> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Oops, something went wrong.