mirror of
https://github.com/apache/maven.git
synced 2025-02-08 02:59:22 +00:00
[MNG-6566] Plugins that require a certain phase should not fork goals that are already in the execution plan.
This resolves #74
This commit is contained in:
parent
0b3c0cab86
commit
bc3cdccb68
@ -107,6 +107,7 @@ public static Test suite()
|
|||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||||
|
|
||||||
|
suite.addTestSuite( MavenITmng6566ExecuteAnnotationShouldNotReExecuteGoalsTest.class );
|
||||||
suite.addTestSuite( MavenITmng6754TimestampInMultimoduleProject.class );
|
suite.addTestSuite( MavenITmng6754TimestampInMultimoduleProject.class );
|
||||||
suite.addTestSuite( MavenITmng6981ProjectListShouldIncludeChildrenTest.class );
|
suite.addTestSuite( MavenITmng6981ProjectListShouldIncludeChildrenTest.class );
|
||||||
suite.addTestSuite( MavenITmng6972AllowAccessToGraphPackageTest.class );
|
suite.addTestSuite( MavenITmng6972AllowAccessToGraphPackageTest.class );
|
||||||
|
@ -0,0 +1,102 @@
|
|||||||
|
package org.apache.maven.it;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.it.util.ResourceExtractor;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
public class MavenITmng6566ExecuteAnnotationShouldNotReExecuteGoalsTest
|
||||||
|
extends AbstractMavenIntegrationTestCase
|
||||||
|
{
|
||||||
|
private static final String RESOURCE_PATH = "/mng-6566-execute-annotation-should-not-re-execute-goals";
|
||||||
|
private static final String PLUGIN_KEY = "org.apache.maven.its.mng6566:plugin:1.0-SNAPSHOT";
|
||||||
|
|
||||||
|
private File testDir;
|
||||||
|
|
||||||
|
public MavenITmng6566ExecuteAnnotationShouldNotReExecuteGoalsTest()
|
||||||
|
{
|
||||||
|
super( "[4.0.0-alpha-1,)" );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUp()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
testDir = ResourceExtractor.simpleExtractResources( getClass(), RESOURCE_PATH );
|
||||||
|
|
||||||
|
File pluginDir = new File( testDir, "plugin" );
|
||||||
|
Verifier verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
|
||||||
|
verifier.executeGoal( "install" );
|
||||||
|
verifier.resetStreams();
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRunsCompileGoalOnceWithDirectPluginInvocation()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File consumerDir = new File( testDir, "consumer" );
|
||||||
|
|
||||||
|
Verifier verifier = newVerifier( consumerDir.getAbsolutePath() );
|
||||||
|
verifier.setLogFileName( "log-direct-plugin-invocation.txt" );
|
||||||
|
verifier.executeGoal( PLUGIN_KEY + ":require-compile-phase" );
|
||||||
|
verifier.resetStreams();
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
|
||||||
|
assertCompiledOnce( verifier );
|
||||||
|
verifier.verifyTextInLog( "MNG-6566 plugin require-compile-phase goal executed" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test uses the <pre>require-compile-phase</pre> goal of the test plugin.
|
||||||
|
*/
|
||||||
|
public void testRunsCompileGoalOnceWithPhaseExecution()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File consumerDir = new File( testDir, "consumer" );
|
||||||
|
|
||||||
|
Verifier verifier = newVerifier( consumerDir.getAbsolutePath() );
|
||||||
|
verifier.setLogFileName( "log-phase-execution.txt" );
|
||||||
|
verifier.executeGoal( "compile" );
|
||||||
|
verifier.resetStreams();
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
|
||||||
|
assertCompiledOnce( verifier );
|
||||||
|
verifier.verifyTextInLog( "MNG-6566 plugin require-compile-phase goal executed" );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertCompiledOnce( Verifier verifier )
|
||||||
|
throws VerificationException
|
||||||
|
{
|
||||||
|
List<String> lines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
|
||||||
|
int counter = 0;
|
||||||
|
for ( String line : lines )
|
||||||
|
{
|
||||||
|
if ( line.contains( "maven-compiler-plugin:0.1-stub-SNAPSHOT:compile") )
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertThat( "Compile goal was expected to run once", counter, is( 1 ) );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<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>org.apache.maven.its.mng6566</groupId>
|
||||||
|
<artifactId>consumer</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.its.mng6566</groupId>
|
||||||
|
<artifactId>plugin</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>require-compile-phase</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>compile</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>0.1-stub-SNAPSHOT</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<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>org.apache.maven.its.mng6566</groupId>
|
||||||
|
<artifactId>plugin</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven-version>3.6.0</maven-version>
|
||||||
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||||
|
<artifactId>maven-plugin-annotations</artifactId>
|
||||||
|
<version>${maven-version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
|
<version>${maven-version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,37 @@
|
|||||||
|
package testmojo;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Execute;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
|
||||||
|
@Mojo( name = "require-compile-phase" )
|
||||||
|
@Execute( phase = LifecyclePhase.COMPILE )
|
||||||
|
public class RequiresCompilePhaseMojo extends AbstractMojo
|
||||||
|
{
|
||||||
|
public void execute() throws MojoExecutionException, MojoFailureException
|
||||||
|
{
|
||||||
|
getLog().info( "MNG-6566 plugin require-compile-phase goal executed" );
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user