Skip to content

Commit

Permalink
Maven plugin integration tests.
Browse files Browse the repository at this point in the history
Moved version management for maven plugin to project root pom, moved plugin configuration there as well
A fix in `AptTypeInfoFactory` where a NPE was possible.
  • Loading branch information
tomas-langer committed Nov 27, 2024
1 parent 3d83e49 commit 11bb3ca
Show file tree
Hide file tree
Showing 16 changed files with 812 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,8 @@ private static boolean isTypeInThisModule(AptContext ctx,
moduleName.set(null);

ModuleElement module = ctx.aptEnv().getElementUtils().getModuleOf(type);
if (!module.isUnnamed()) {

if (module != null && !module.isUnnamed()) {
String name = module.getQualifiedName().toString();
if (hasValue(name)) {
moduleName.set(name);
Expand Down
42 changes: 42 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
<version.lib.maven.plugin.annotations>3.9.0</version.lib.maven.plugin.annotations>
<version.lib.maven.plugin.api>3.9.3</version.lib.maven.plugin.api>
<version.lib.maven.plugin.project>2.2.1</version.lib.maven.plugin.project>
<version.lib.apiguardian.api>1.1.2</version.lib.apiguardian.api>
<version.lib.groovy>2.4.16</version.lib.groovy>
<!--
!Version statement! - end
-->
Expand All @@ -125,6 +127,7 @@
<version.plugin.helidon-build-tools>4.0.14</version.plugin.helidon-build-tools>
<version.plugin.hibernate-enhance>${version.lib.hibernate}</version.plugin.hibernate-enhance>
<version.plugin.install>3.1.2</version.plugin.install>
<version.plugin.invoker>3.2.2</version.plugin.invoker>
<version.plugin.jacoco>0.8.5</version.plugin.jacoco>
<version.plugin.jandex>3.1.2</version.plugin.jandex>
<version.plugin.jar>3.3.0</version.plugin.jar>
Expand Down Expand Up @@ -859,6 +862,39 @@
<artifactId>maven-antrun-plugin</artifactId>
<version>${version.plugin.ant}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>${version.plugin.invoker}</version>
<configuration>
<addTestClassPath>true</addTestClassPath>
<settingsFile>src/it/settings.xml</settingsFile>
<mergeUserSettings>true</mergeUserSettings>
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
<!--suppress MavenModelInspection -->
<ignoreFailures>${maven.test.failure.ignore}</ignoreFailures>
<showErrors>true</showErrors>
<!--suppress UnresolvedMavenProperty, MavenModelInspection -->
<skipInvocation>${skipTests}</skipInvocation>
<!--suppress UnresolvedMavenProperty, MavenModelInspection -->
<skipInstallation>${skipTests}</skipInstallation>
<pomIncludes>
<pomInclude>projects/*/pom.xml</pomInclude>
</pomIncludes>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<goals>
<goal>clean</goal>
<goal>install</goal>
</goals>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${version.lib.groovy}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down Expand Up @@ -1360,6 +1396,12 @@
<version>${version.lib.maven.plugin.project}</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- dependency convergence -->
<groupId>org.apiguardian</groupId>
<artifactId>apiguardian-api</artifactId>
<version>${version.lib.apiguardian.api}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
16 changes: 16 additions & 0 deletions service/inject/maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<configuration>
<goalPrefix>helidon-inject</goalPrefix>
<skipErrorNoDescriptorsFound>false</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
86 changes: 86 additions & 0 deletions service/tests/inject/maven-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?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.
-->

<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.tests.inject</groupId>
<artifactId>helidon-service-tests-inject-project</artifactId>
<version>4.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>helidon-service-tests-inject-maven-plugin</artifactId>
<name>Helidon Service Tests Inject Maven Plugin</name>
<description>Tests for Maven Plugin</description>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.build-tools.common</groupId>
<artifactId>helidon-build-common-test-utils</artifactId>
<version>${version.plugin.helidon-build-tools}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*IT.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>install</goal>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
98 changes: 98 additions & 0 deletions service/tests/inject/maven-plugin/src/it/projects/test1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?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.
-->

<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">
<modelVersion>4.0.0</modelVersion>

<groupId>io.helidon.service.tests.inject.maven.plugin.test</groupId>
<artifactId>test-1</artifactId>
<version>@project.version@</version>
<name>Test Inject Maven Plugin 1</name>

<dependencies>
<dependency>
<groupId>io.helidon.service</groupId>
<artifactId>helidon-service-registry</artifactId>
<version>@project.version@</version>
</dependency>
<dependency>
<groupId>io.helidon.service.inject</groupId>
<artifactId>helidon-service-inject-api</artifactId>
<version>@project.version@</version>
</dependency>
<dependency>
<groupId>io.helidon.service.inject</groupId>
<artifactId>helidon-service-inject</artifactId>
<version>@project.version@</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.helidon.codegen</groupId>
<artifactId>helidon-codegen-apt</artifactId>
<version>@project.version@</version>
</path>
<path>
<groupId>io.helidon.service.inject</groupId>
<artifactId>helidon-service-inject-codegen</artifactId>
<version>@project.version@</version>
</path>
<path>
<groupId>io.helidon.codegen</groupId>
<artifactId>helidon-codegen-helidon-copyright</artifactId>
<version>@project.version@</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>io.helidon.service.inject</groupId>
<artifactId>helidon-service-inject-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>create-application</id>
<goals>
<goal>create-application</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.helidon.codegen</groupId>
<artifactId>helidon-codegen-helidon-copyright</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<configuration>
<failOnWarning>true</failOnWarning>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2022, 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.
*/

import io.helidon.build.common.test.utils.JUnitLauncher
import io.helidon.service.tests.inject.maven.plugin.ProjectsTestIT

//noinspection GroovyAssignabilityCheck,GrUnresolvedAccess
JUnitLauncher.builder()
.select(ProjectsTestIT.class, "test1", String.class)
.parameter("basedir", basedir.getAbsolutePath())
.reportsDir(basedir)
.outputFile(new File(basedir, "test.log"))
.suiteId("helidon-inject-maven-plugin-it-test1")
.suiteDisplayName("Helidon Inject Maven Plugin Integration Test 1")
.build()
.launch()
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.
*/

package my.module;

import io.helidon.service.inject.api.Injection;

@Injection.Singleton
class ServiceType {

}
Loading

0 comments on commit 11bb3ca

Please sign in to comment.