Skip to content

Commit 3761953

Browse files
authored
[MNG-8525] Add an integration test with Maven 4 Plugin Sample (#2055)
1 parent abc0a30 commit 3761953

File tree

9 files changed

+554
-0
lines changed

9 files changed

+554
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.it;
20+
21+
import java.io.File;
22+
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
25+
26+
/**
27+
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8525">MNG-8525</a>.
28+
*
29+
*/
30+
public class MavenITmng8525MavenDIPlugin extends AbstractMavenIntegrationTestCase {
31+
32+
private File testDir;
33+
34+
public MavenITmng8525MavenDIPlugin() {
35+
super("[4.0.0-rc-2,)");
36+
}
37+
38+
@BeforeEach
39+
public void setUp() throws Exception {
40+
testDir = extractResources("/mng-8525-maven-di-plugin");
41+
}
42+
43+
@Test
44+
public void testMavenDIPlugin() throws Exception {
45+
//
46+
// Build a plugin that uses a Maven DI plugin
47+
//
48+
Verifier v0 = newVerifier(testDir.getAbsolutePath());
49+
v0.setAutoclean(false);
50+
v0.deleteDirectory("target");
51+
v0.deleteArtifacts("org.apache.maven.its");
52+
v0.addCliArgument("install");
53+
v0.execute();
54+
v0.verifyErrorFreeLog();
55+
56+
//
57+
// Execute the Maven DI plugin
58+
//
59+
Verifier v1 = newVerifier(testDir.getAbsolutePath());
60+
v1.setAutoclean(false);
61+
v1.addCliArgument("org.apache.maven.its:mavendi-maven-plugin:0.0.1-SNAPSHOT:hello");
62+
v1.addCliArgument("-Dname=World");
63+
v1.execute();
64+
v1.verifyErrorFreeLog();
65+
v1.verifyTextInLog("Hello World! I am a component that is being used via field injection!");
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd">
21+
<modelVersion>4.1.0</modelVersion>
22+
23+
<groupId>org.apache.maven.its</groupId>
24+
<artifactId>mavendi-maven-plugin</artifactId>
25+
<version>0.0.1-SNAPSHOT</version>
26+
<packaging>maven-plugin</packaging>
27+
28+
<name>mavendi-maven-plugin Maven Plugin</name>
29+
<url>http://maven.apache.org</url>
30+
31+
<properties>
32+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33+
<javaVersion>17</javaVersion>
34+
<guiceVersion>6.0.0</guiceVersion>
35+
<mavenVersion>4.0.0-beta-5</mavenVersion>
36+
<mavenPluginPluginVersion>4.0.0-beta-1</mavenPluginPluginVersion>
37+
<mavenPluginTestingVersion>4.0.0-beta-2</mavenPluginTestingVersion>
38+
<mavenResolverVersion>2.0.2</mavenResolverVersion>
39+
</properties>
40+
41+
<dependencyManagement>
42+
<dependencies>
43+
<dependency>
44+
<groupId>org.junit</groupId>
45+
<artifactId>junit-bom</artifactId>
46+
<version>5.11.4</version>
47+
<type>pom</type>
48+
<scope>import</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.mockito</groupId>
52+
<artifactId>mockito-bom</artifactId>
53+
<version>5.15.2</version>
54+
<type>pom</type>
55+
<scope>import</scope>
56+
</dependency>
57+
</dependencies>
58+
</dependencyManagement>
59+
60+
<dependencies>
61+
<dependency>
62+
<groupId>org.apache.maven</groupId>
63+
<artifactId>maven-api-core</artifactId>
64+
<version>${mavenVersion}</version>
65+
<scope>provided</scope>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.apache.maven</groupId>
69+
<artifactId>maven-api-di</artifactId>
70+
<version>${mavenVersion}</version>
71+
<scope>provided</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.apache.maven</groupId>
75+
<artifactId>maven-api-meta</artifactId>
76+
<version>${mavenVersion}</version>
77+
<scope>provided</scope>
78+
</dependency>
79+
80+
<dependency>
81+
<groupId>org.apache.maven</groupId>
82+
<artifactId>maven-core</artifactId>
83+
<version>${mavenVersion}</version>
84+
<scope>test</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>org.apache.maven.resolver</groupId>
88+
<artifactId>maven-resolver-api</artifactId>
89+
<version>${mavenResolverVersion}</version>
90+
<scope>test</scope>
91+
</dependency>
92+
<dependency>
93+
<groupId>org.apache.maven</groupId>
94+
<artifactId>maven-api-impl</artifactId>
95+
<version>${mavenVersion}</version>
96+
<scope>test</scope>
97+
</dependency>
98+
<dependency>
99+
<groupId>com.google.inject</groupId>
100+
<artifactId>guice</artifactId>
101+
<version>${guiceVersion}</version>
102+
<scope>test</scope>
103+
</dependency>
104+
<dependency>
105+
<groupId>org.apache.maven.plugin-testing</groupId>
106+
<artifactId>maven-plugin-testing-harness</artifactId>
107+
<version>${mavenPluginTestingVersion}</version>
108+
<scope>test</scope>
109+
</dependency>
110+
<dependency>
111+
<groupId>org.junit.jupiter</groupId>
112+
<artifactId>junit-jupiter-api</artifactId>
113+
<scope>test</scope>
114+
</dependency>
115+
<dependency>
116+
<groupId>org.mockito</groupId>
117+
<artifactId>mockito-core</artifactId>
118+
<scope>test</scope>
119+
</dependency>
120+
<dependency>
121+
<groupId>org.mockito</groupId>
122+
<artifactId>mockito-junit-jupiter</artifactId>
123+
<scope>test</scope>
124+
</dependency>
125+
<dependency>
126+
<groupId>org.assertj</groupId>
127+
<artifactId>assertj-core</artifactId>
128+
<version>3.27.2</version>
129+
<scope>test</scope>
130+
</dependency>
131+
</dependencies>
132+
133+
<build>
134+
<plugins>
135+
<plugin>
136+
<groupId>org.apache.maven.plugins</groupId>
137+
<artifactId>maven-plugin-plugin</artifactId>
138+
<version>${mavenPluginPluginVersion}</version>
139+
<executions>
140+
<execution>
141+
<id>generate-helpmojo</id>
142+
<goals>
143+
<goal>helpmojo</goal>
144+
</goals>
145+
</execution>
146+
</executions>
147+
</plugin>
148+
</plugins>
149+
</build>
150+
151+
<profiles>
152+
<profile>
153+
<id>run-its</id>
154+
<build>
155+
<plugins>
156+
<plugin>
157+
<groupId>org.apache.maven.plugins</groupId>
158+
<artifactId>maven-invoker-plugin</artifactId>
159+
<version>3.6.1</version>
160+
<configuration>
161+
<showErrors>true</showErrors>
162+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
163+
<cloneClean>true</cloneClean>
164+
<pomIncludes>
165+
<pomInclude>*/pom.xml</pomInclude>
166+
</pomIncludes>
167+
<preBuildHookScript>setup</preBuildHookScript>
168+
<postBuildHookScript>verify</postBuildHookScript>
169+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
170+
<settingsFile>src/it/settings.xml</settingsFile>
171+
<scriptVariables>
172+
<remoteRepo>${project.build.directory}/remote-repo</remoteRepo>
173+
</scriptVariables>
174+
<filterProperties>
175+
<remoteRepo>${project.build.directory}/remote-repo</remoteRepo>
176+
</filterProperties>
177+
</configuration>
178+
<executions>
179+
<execution>
180+
<id>integration-test</id>
181+
<goals>
182+
<goal>install</goal>
183+
<goal>integration-test</goal>
184+
<goal>verify</goal>
185+
</goals>
186+
</execution>
187+
</executions>
188+
</plugin>
189+
</plugins>
190+
</build>
191+
</profile>
192+
</profiles>
193+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
invoker.goals=initialize
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd">
21+
<modelVersion>4.1.0</modelVersion>
22+
23+
<groupId>org.apache.maven.plugins.mvn4.its</groupId>
24+
<artifactId>mvn4-plugin-demo</artifactId>
25+
<version>1.0</version>
26+
27+
<description>Test a mvn4 plugin</description>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.apache.maven.its</groupId>
33+
<artifactId>mavendi-maven-plugin</artifactId>
34+
<version>@project.version@</version>
35+
<configuration>
36+
<name>World</name>
37+
</configuration>
38+
<executions>
39+
<execution>
40+
<goals>
41+
<goal>hello</goal>
42+
</goals>
43+
<phase>initialize</phase>
44+
</execution>
45+
</executions>
46+
</plugin>
47+
</plugins>
48+
</build>
49+
50+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
File buildLog = new File(basedir, 'build.log')
21+
assert buildLog.exists()
22+
assert buildLog.text.contains("[INFO] Hello World! I am a component that is being used via field injection!")

0 commit comments

Comments
 (0)