mirror of https://github.com/apache/maven.git
[MNG-4536] Long build time - enforcer running too many times
o Added IT git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@904187 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c28d4c9cb3
commit
8e1f46931a
|
@ -86,6 +86,7 @@ public class IntegrationTestSuite
|
||||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||||
|
|
||||||
suite.addTestSuite( MavenITmng4544ActiveComponentCollectionThreadSafeTest.class );
|
suite.addTestSuite( MavenITmng4544ActiveComponentCollectionThreadSafeTest.class );
|
||||||
|
suite.addTestSuite( MavenITmng4536RequiresNoProjectForkingMojoTest.class );
|
||||||
suite.addTestSuite( MavenITmng4522FailUponMissingDependencyParentPomTest.class );
|
suite.addTestSuite( MavenITmng4522FailUponMissingDependencyParentPomTest.class );
|
||||||
suite.addTestSuite( MavenITmng4500NoUpdateOfTimestampedSnapshotsTest.class );
|
suite.addTestSuite( MavenITmng4500NoUpdateOfTimestampedSnapshotsTest.class );
|
||||||
suite.addTestSuite( MavenITmng4498IgnoreBrokenMetadataTest.class );
|
suite.addTestSuite( MavenITmng4498IgnoreBrokenMetadataTest.class );
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
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.Verifier;
|
||||||
|
import org.apache.maven.it.util.ResourceExtractor;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4536">MNG-4536</a>.
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
public class MavenITmng4536RequiresNoProjectForkingMojoTest
|
||||||
|
extends AbstractMavenIntegrationTestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public MavenITmng4536RequiresNoProjectForkingMojoTest()
|
||||||
|
{
|
||||||
|
super( "[2.0.3,3.0-alpha-1),[3.0-alpha-7,)" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that forking mojos that require no project only fork the current project and not the entire reactor.
|
||||||
|
*/
|
||||||
|
public void testit()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4536" );
|
||||||
|
|
||||||
|
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||||
|
verifier.setAutoclean( false );
|
||||||
|
verifier.deleteDirectory( "target" );
|
||||||
|
verifier.deleteDirectory( "mod-a/target" );
|
||||||
|
verifier.deleteDirectory( "mod-b/target" );
|
||||||
|
verifier.executeGoal( "generate-sources" );
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
verifier.resetStreams();
|
||||||
|
|
||||||
|
assertEquals( 2, verifier.loadLines( "mod-a/target/touch.log", "UTF-8" ).size() );
|
||||||
|
assertEquals( 2, verifier.loadLines( "mod-b/target/touch.log", "UTF-8" ).size() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?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>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.maven.its.mng4536</groupId>
|
||||||
|
<artifactId>test</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.apache.maven.its.mng4536</groupId>
|
||||||
|
<artifactId>moda</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
|
||||||
|
<name>Maven Integration Test :: MNG-4536 :: Module A</name>
|
||||||
|
</project>
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?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>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.maven.its.mng4536</groupId>
|
||||||
|
<artifactId>test</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.apache.maven.its.mng4536</groupId>
|
||||||
|
<artifactId>modb</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
|
||||||
|
<name>Maven Integration Test :: MNG-4536 :: Module B</name>
|
||||||
|
</project>
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?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>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.apache.maven.its.mng4536</groupId>
|
||||||
|
<artifactId>test</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>Maven Integration Test :: MNG-4536</name>
|
||||||
|
<description>
|
||||||
|
Test that forking mojos that require no project only fork the current project and not the entire reactor.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>mod-a</module>
|
||||||
|
<module>mod-b</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
|
<artifactId>maven-it-plugin-fork</artifactId>
|
||||||
|
<version>2.1-SNAPSHOT</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>test</id>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>fork-lifecycle-no-project</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -34,6 +34,10 @@ under the License.
|
||||||
<name>Maven Integration Test Plugin :: Fork</name>
|
<name>Maven Integration Test Plugin :: Fork</name>
|
||||||
<inceptionYear>2006</inceptionYear>
|
<inceptionYear>2006</inceptionYear>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.test.skip>true</maven.test.skip>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
|
@ -44,6 +48,16 @@ under the License.
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-project</artifactId>
|
<artifactId>maven-project</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-utils</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-container-default</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class ForkLifecycleMojo
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
TouchMojo.touch( touchDirectory, "fork-lifecycle.txt", true );
|
TouchMojo.touch( touchDirectory, "fork-lifecycle.txt" );
|
||||||
|
|
||||||
if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package org.apache.maven.plugin.coreit;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @goal fork-lifecycle-no-project
|
||||||
|
* @requiresProject false
|
||||||
|
*
|
||||||
|
* @execute phase="generate-sources" lifecycle="foo"
|
||||||
|
*/
|
||||||
|
public class ForkLifecycleNoProjectMojo
|
||||||
|
extends AbstractMojo
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @parameter default-value="${project.build.finalName}"
|
||||||
|
*/
|
||||||
|
private String finalName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @parameter default-value="target"
|
||||||
|
*/
|
||||||
|
private File touchDirectory;
|
||||||
|
|
||||||
|
public void execute()
|
||||||
|
throws MojoExecutionException
|
||||||
|
{
|
||||||
|
TouchMojo.touch( touchDirectory, "fork-lifecycle-no-project.txt" );
|
||||||
|
|
||||||
|
if ( TouchMojo.FINAL_NAME.equals( finalName ) )
|
||||||
|
{
|
||||||
|
throw new MojoExecutionException( "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME
|
||||||
|
+ "\')." );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,6 @@ package org.apache.maven.plugin.coreit;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
@ -28,14 +27,11 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @goal touch
|
* @goal touch
|
||||||
*
|
*
|
||||||
* @phase process-sources
|
* @phase process-sources
|
||||||
*
|
|
||||||
* @description Goal which cleans the build
|
|
||||||
*/
|
*/
|
||||||
public class TouchMojo
|
public class TouchMojo
|
||||||
extends AbstractMojo
|
extends AbstractMojo
|
||||||
|
@ -54,94 +50,22 @@ public class TouchMojo
|
||||||
*/
|
*/
|
||||||
private File outputDirectory;
|
private File outputDirectory;
|
||||||
|
|
||||||
/** Test setting of plugin-artifacts on the PluginDescriptor instance.
|
|
||||||
* @parameter expression="${plugin.artifactMap}"
|
|
||||||
* @required
|
|
||||||
*/
|
|
||||||
private Map pluginArtifacts;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @parameter expression="target/test-basedir-alignment"
|
|
||||||
*/
|
|
||||||
private File basedirAlignmentDirectory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @parameter alias="pluginFile"
|
|
||||||
*/
|
|
||||||
private String pluginItem = "foo";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @parameter
|
|
||||||
*/
|
|
||||||
private String goalItem = "bar";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @parameter expression="${artifactToFile}"
|
|
||||||
*/
|
|
||||||
private String artifactToFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @parameter expression="${fail}"
|
|
||||||
*/
|
|
||||||
private boolean fail = false;
|
|
||||||
|
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
if ( fail )
|
|
||||||
{
|
|
||||||
throw new MojoExecutionException( "Failing per \'fail\' parameter (specified in pom or system properties)" );
|
|
||||||
}
|
|
||||||
|
|
||||||
getLog().info( "[MAVEN-CORE-IT-LOG] Project build directory " + project.getBuild().getDirectory() );
|
getLog().info( "[MAVEN-CORE-IT-LOG] Project build directory " + project.getBuild().getDirectory() );
|
||||||
|
|
||||||
|
touch( new File( project.getBuild().getDirectory() ), "touch.log" );
|
||||||
|
|
||||||
getLog().info( "[MAVEN-CORE-IT-LOG] Using output directory " + outputDirectory );
|
getLog().info( "[MAVEN-CORE-IT-LOG] Using output directory " + outputDirectory );
|
||||||
|
|
||||||
touch( outputDirectory, "touch.txt" );
|
touch( outputDirectory, "touch.txt" );
|
||||||
|
|
||||||
// This parameter should be aligned to the basedir as the parameter type is specified
|
|
||||||
// as java.io.File
|
|
||||||
|
|
||||||
if ( basedirAlignmentDirectory.getPath().equals( "target/test-basedir-alignment" ) )
|
|
||||||
{
|
|
||||||
throw new MojoExecutionException( "basedirAlignmentDirectory not aligned" );
|
|
||||||
}
|
|
||||||
|
|
||||||
touch( basedirAlignmentDirectory, "touch.txt" );
|
|
||||||
|
|
||||||
// Test parameter setting
|
|
||||||
if ( pluginItem != null )
|
|
||||||
{
|
|
||||||
touch( outputDirectory, pluginItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( goalItem != null )
|
|
||||||
{
|
|
||||||
touch( outputDirectory, goalItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( artifactToFile != null )
|
|
||||||
{
|
|
||||||
Artifact artifact = (Artifact) pluginArtifacts.get( artifactToFile );
|
|
||||||
|
|
||||||
File artifactFile = artifact.getFile();
|
|
||||||
|
|
||||||
String filename = artifactFile.getAbsolutePath().replace('/', '_').replace(':', '_') + ".txt";
|
|
||||||
|
|
||||||
touch( outputDirectory, filename );
|
|
||||||
}
|
|
||||||
|
|
||||||
project.getBuild().setFinalName( FINAL_NAME );
|
project.getBuild().setFinalName( FINAL_NAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void touch( File dir, String file )
|
static void touch( File dir, String file )
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
|
||||||
touch( dir, file, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void touch( File dir, String file, boolean append )
|
|
||||||
throws MojoExecutionException
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -152,7 +76,8 @@ public class TouchMojo
|
||||||
|
|
||||||
File touch = new File( dir, file );
|
File touch = new File( dir, file );
|
||||||
|
|
||||||
OutputStreamWriter w = new OutputStreamWriter( new FileOutputStream( touch, append ), "UTF-8" );
|
// NOTE: Using append mode to track execution count
|
||||||
|
OutputStreamWriter w = new OutputStreamWriter( new FileOutputStream( touch, true ), "UTF-8" );
|
||||||
|
|
||||||
w.write( file );
|
w.write( file );
|
||||||
w.write( "\n" );
|
w.write( "\n" );
|
||||||
|
@ -164,4 +89,5 @@ public class TouchMojo
|
||||||
throw new MojoExecutionException( "Error touching file", e );
|
throw new MojoExecutionException( "Error touching file", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue