Skip to content

Commit 58dfa7d

Browse files
authored
[MNG-8299] IT for custom lifecycle phase ordering (#389)
Main PR: apache/maven#1802 --- https://issues.apache.org/jira/browse/MNG-8299
1 parent 444d7dd commit 58dfa7d

File tree

6 files changed

+168
-0
lines changed

6 files changed

+168
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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.apache.maven.shared.verifier.Verifier;
24+
import org.apache.maven.shared.verifier.util.ResourceExtractor;
25+
import org.junit.jupiter.api.Test;
26+
27+
/**
28+
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8299">MNG-8299</a>.
29+
*/
30+
class MavenITmng8299CustomLifecycleTest extends AbstractMavenIntegrationTestCase {
31+
32+
MavenITmng8299CustomLifecycleTest() {
33+
super("[2.0,4.0.0-alpha-13],[4.0.0-beta-5,)");
34+
}
35+
36+
/**
37+
* Verify that invoking the third phase will invoke the first two
38+
*/
39+
@Test
40+
void testPhaseOrdering() throws Exception {
41+
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8299-custom-lifecycle");
42+
43+
Verifier verifier = newVerifier(new File(testDir, "CustomLifecyclePlugin").getAbsolutePath());
44+
verifier.addCliArgument("install");
45+
verifier.execute();
46+
verifier.verifyErrorFreeLog();
47+
48+
verifier = newVerifier(new File(testDir, "CustomLifecycleProject").getAbsolutePath());
49+
verifier.addCliArgument("phase3");
50+
verifier.execute();
51+
verifier.verifyErrorFreeLog();
52+
verifier.verifyTextInLog("[INFO] Doing Phase 1 stuff. Oh yeah baby.");
53+
}
54+
}

core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public TestSuiteOrdering() {
120120
* the tests are to finishing. Newer tests are also more likely to fail, so this is
121121
* a fail fast technique as well.
122122
*/
123+
suite.addTestSuite(MavenITmng8299CustomLifecycleTest.class);
123124
suite.addTestSuite(MavenITmng7982DependencyManagementTransitivityTest.class);
124125
suite.addTestSuite(MavenITmng8294ParentChecksTest.class);
125126
suite.addTestSuite(MavenITmng8293BomImportFromReactor.class);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.nextmetaphor.plugin</groupId>
6+
<artifactId>CustomLifecyclePlugin</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<packaging>maven-plugin</packaging>
9+
<name>Custom Lifecycle Plugin</name>
10+
11+
<dependencies>
12+
<dependency>
13+
<groupId>org.apache.maven</groupId>
14+
<artifactId>maven-plugin-api</artifactId>
15+
<version>2.0</version>
16+
<scope>provided</scope>
17+
</dependency>
18+
</dependencies>
19+
20+
<build>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-plugin-plugin</artifactId>
25+
<version>3.6.4</version>
26+
<executions>
27+
<execution>
28+
<goals>
29+
<goal>descriptor</goal>
30+
</goals>
31+
<configuration>
32+
<goalPrefix>CustomLifecyclePlugin</goalPrefix>
33+
</configuration>
34+
</execution>
35+
</executions>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 com.nextmetaphor.plugin.mojo;
20+
21+
import org.apache.maven.plugin.AbstractMojo;
22+
import org.apache.maven.plugin.MojoExecutionException;
23+
24+
/**
25+
* Forks a zip lifecycle.
26+
* @goal phase1Goal
27+
*/
28+
public class CustomLifecyclePluginPhase1Mojo extends AbstractMojo {
29+
public void execute() throws MojoExecutionException {
30+
getLog().info("Doing Phase 1 stuff. Oh yeah baby.");
31+
}
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<component-set>
2+
<components>
3+
<component>
4+
<role>org.apache.maven.lifecycle.Lifecycle</role>
5+
<role-hint>customLifecyclePlugin_PackagingType</role-hint>
6+
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
7+
<configuration>
8+
<id>customLifecyclePlugin_LifecycleID</id>
9+
<phases>
10+
<phase>phase1</phase>
11+
<phase>phase2</phase>
12+
<phase>phase3</phase>
13+
</phases>
14+
<default-phases>
15+
<phase1>com.nextmetaphor.plugin:CustomLifecyclePlugin:phase1Goal</phase1>
16+
</default-phases>
17+
</configuration>
18+
</component>
19+
</components>
20+
</component-set>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.nextmetaphor.project</groupId>
6+
<artifactId>CustomLifecycleProject</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>Custom Lifecycle Project</name>
11+
12+
<build>
13+
<plugins>
14+
<plugin>
15+
<groupId>com.nextmetaphor.plugin</groupId>
16+
<artifactId>CustomLifecyclePlugin</artifactId>
17+
<version>1.0-SNAPSHOT</version>
18+
<extensions>true</extensions>
19+
</plugin>
20+
</plugins>
21+
</build>
22+
</project>

0 commit comments

Comments
 (0)