-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MNG-8299] IT for custom lifecycle phase ordering (#389)
- Loading branch information
Showing
6 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8299CustomLifecycleTest.java
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,54 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.maven.it; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.maven.shared.verifier.Verifier; | ||
import org.apache.maven.shared.verifier.util.ResourceExtractor; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8299">MNG-8299</a>. | ||
*/ | ||
class MavenITmng8299CustomLifecycleTest extends AbstractMavenIntegrationTestCase { | ||
|
||
MavenITmng8299CustomLifecycleTest() { | ||
super("[2.0,4.0.0-alpha-13],[4.0.0-beta-5,)"); | ||
} | ||
|
||
/** | ||
* Verify that invoking the third phase will invoke the first two | ||
*/ | ||
@Test | ||
void testPhaseOrdering() throws Exception { | ||
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8299-custom-lifecycle"); | ||
|
||
Verifier verifier = newVerifier(new File(testDir, "CustomLifecyclePlugin").getAbsolutePath()); | ||
verifier.addCliArgument("install"); | ||
verifier.execute(); | ||
verifier.verifyErrorFreeLog(); | ||
|
||
verifier = newVerifier(new File(testDir, "CustomLifecycleProject").getAbsolutePath()); | ||
verifier.addCliArgument("phase3"); | ||
verifier.execute(); | ||
verifier.verifyErrorFreeLog(); | ||
verifier.verifyTextInLog("[INFO] Doing Phase 1 stuff. Oh yeah baby."); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
core-it-suite/src/test/resources/mng-8299-custom-lifecycle/CustomLifecyclePlugin/pom.xml
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,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.nextmetaphor.plugin</groupId> | ||
<artifactId>CustomLifecyclePlugin</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>maven-plugin</packaging> | ||
<name>Custom Lifecycle Plugin</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
<version>2.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-plugin-plugin</artifactId> | ||
<version>3.6.4</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>descriptor</goal> | ||
</goals> | ||
<configuration> | ||
<goalPrefix>CustomLifecyclePlugin</goalPrefix> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
32 changes: 32 additions & 0 deletions
32
...clePlugin/src/main/java/com/nextmetaphor/plugin/mojo/CustomLifecyclePluginPhase1Mojo.java
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,32 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 com.nextmetaphor.plugin.mojo; | ||
|
||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
|
||
/** | ||
* Forks a zip lifecycle. | ||
* @goal phase1Goal | ||
*/ | ||
public class CustomLifecyclePluginPhase1Mojo extends AbstractMojo { | ||
public void execute() throws MojoExecutionException { | ||
getLog().info("Doing Phase 1 stuff. Oh yeah baby."); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...-custom-lifecycle/CustomLifecyclePlugin/src/main/resources/META-INF/plexus/components.xml
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,20 @@ | ||
<component-set> | ||
<components> | ||
<component> | ||
<role>org.apache.maven.lifecycle.Lifecycle</role> | ||
<role-hint>customLifecyclePlugin_PackagingType</role-hint> | ||
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation> | ||
<configuration> | ||
<id>customLifecyclePlugin_LifecycleID</id> | ||
<phases> | ||
<phase>phase1</phase> | ||
<phase>phase2</phase> | ||
<phase>phase3</phase> | ||
</phases> | ||
<default-phases> | ||
<phase1>com.nextmetaphor.plugin:CustomLifecyclePlugin:phase1Goal</phase1> | ||
</default-phases> | ||
</configuration> | ||
</component> | ||
</components> | ||
</component-set> |
22 changes: 22 additions & 0 deletions
22
core-it-suite/src/test/resources/mng-8299-custom-lifecycle/CustomLifecycleProject/pom.xml
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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.nextmetaphor.project</groupId> | ||
<artifactId>CustomLifecycleProject</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>Custom Lifecycle Project</name> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.nextmetaphor.plugin</groupId> | ||
<artifactId>CustomLifecyclePlugin</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |