mirror of https://github.com/apache/maven.git
o Extended IT plugin to allow testing of forking+aggregation
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@807971 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b12cc9b647
commit
ac12d6a88d
|
@ -0,0 +1,69 @@
|
|||
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 java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
/**
|
||||
* @goal fork-goal-aggregator
|
||||
* @aggregator true
|
||||
*
|
||||
* @execute goal="touch"
|
||||
*/
|
||||
public class ForkGoalAggregatorMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
/**
|
||||
* @parameter expression="${project}"
|
||||
*/
|
||||
private MavenProject project;
|
||||
|
||||
/**
|
||||
* @parameter expression="${reactorProjects}"
|
||||
*/
|
||||
private List reactorProjects;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
|
||||
{
|
||||
MavenProject executedProject = ( (MavenProject) it.next() ).getExecutionProject();
|
||||
|
||||
if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Unexpected result, final name of executed project "
|
||||
+ executedProject + " is " + executedProject.getBuild().getFinalName() + " (should be \'"
|
||||
+ TouchMojo.FINAL_NAME + "\')." );
|
||||
}
|
||||
}
|
||||
|
||||
if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME
|
||||
+ "\')." );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ import org.apache.maven.project.MavenProject;
|
|||
*
|
||||
* @execute goal="touch"
|
||||
*/
|
||||
public class CoreItGoalForkerMojo
|
||||
public class ForkGoalMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
/**
|
||||
|
@ -44,14 +44,16 @@ public class CoreItGoalForkerMojo
|
|||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
if ( !executedProject.getBuild().getFinalName().equals( "coreitified" ) )
|
||||
if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Unexpected result, final name of executed project is " + executedProject.getBuild().getFinalName() + " (should be: \'coreitified\')." );
|
||||
throw new MojoExecutionException( "Unexpected result, final name of executed project is "
|
||||
+ executedProject.getBuild().getFinalName() + " (should be \'" + TouchMojo.FINAL_NAME + "\')." );
|
||||
}
|
||||
|
||||
if ( project.getBuild().getFinalName().equals( "coreitified" ) )
|
||||
if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "forked project was polluted. (should NOT be: \'coreitified\')." );
|
||||
throw new MojoExecutionException( "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME
|
||||
+ "\')." );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
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 java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
/**
|
||||
* @goal fork-lifecycle-aggregator
|
||||
* @aggregator true
|
||||
*
|
||||
* @execute phase="generate-sources" lifecycle="foo"
|
||||
*/
|
||||
public class ForkLifecycleAggregatorMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* @parameter expression="${project}"
|
||||
*/
|
||||
private MavenProject project;
|
||||
|
||||
/**
|
||||
* @parameter expression="${reactorProjects}"
|
||||
*/
|
||||
private List reactorProjects;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
|
||||
{
|
||||
MavenProject executedProject = ( (MavenProject) it.next() ).getExecutionProject();
|
||||
|
||||
if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Unexpected result, final name of executed project "
|
||||
+ executedProject + " is " + executedProject.getBuild().getFinalName() + " (should be \'"
|
||||
+ TouchMojo.FINAL_NAME + "\')." );
|
||||
}
|
||||
}
|
||||
|
||||
if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME
|
||||
+ "\')." );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ import org.apache.maven.project.MavenProject;
|
|||
*
|
||||
* @execute phase="generate-sources" lifecycle="foo"
|
||||
*/
|
||||
public class CoreItForkerMojo
|
||||
public class ForkLifecycleMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
/**
|
||||
|
@ -44,14 +44,16 @@ public class CoreItForkerMojo
|
|||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
if ( !executedProject.getBuild().getFinalName().equals( "coreitified" ) )
|
||||
if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Unexpected result, final name of executed project is " + executedProject.getBuild().getFinalName() + " (should be: \'coreitified\')." );
|
||||
throw new MojoExecutionException( "Unexpected result, final name of executed project is "
|
||||
+ executedProject.getBuild().getFinalName() + " (should be \'" + TouchMojo.FINAL_NAME + "\')." );
|
||||
}
|
||||
|
||||
if ( project.getBuild().getFinalName().equals( "coreitified" ) )
|
||||
if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
|
||||
{
|
||||
throw new MojoExecutionException( "forked project was polluted. (should NOT be: \'coreitified\')." );
|
||||
throw new MojoExecutionException( "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME
|
||||
+ "\')." );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,9 +36,12 @@ import java.util.Map;
|
|||
*
|
||||
* @description Goal which cleans the build
|
||||
*/
|
||||
public class CoreItMojo
|
||||
public class TouchMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
static final String FINAL_NAME = "coreitified";
|
||||
|
||||
/**
|
||||
* @parameter expression="${project}"
|
||||
*/
|
||||
|
@ -48,7 +51,7 @@ public class CoreItMojo
|
|||
* @parameter expression="${project.build.directory}"
|
||||
* @required
|
||||
*/
|
||||
private String outputDirectory;
|
||||
private File outputDirectory;
|
||||
|
||||
/** Test setting of plugin-artifacts on the PluginDescriptor instance.
|
||||
* @parameter expression="${plugin.artifactMap}"
|
||||
|
@ -88,8 +91,12 @@ public class CoreItMojo
|
|||
{
|
||||
throw new MojoExecutionException( "Failing per \'fail\' parameter (specified in pom or system properties)" );
|
||||
}
|
||||
|
||||
touch( new File( outputDirectory ), "touch.txt" );
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Project build directory " + project.getBuild().getDirectory() );
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Using output directory " + outputDirectory );
|
||||
|
||||
touch( outputDirectory, "touch.txt" );
|
||||
|
||||
// This parameter should be aligned to the basedir as the parameter type is specified
|
||||
// as java.io.File
|
||||
|
@ -100,18 +107,16 @@ public class CoreItMojo
|
|||
}
|
||||
|
||||
touch( basedirAlignmentDirectory, "touch.txt" );
|
||||
|
||||
File outDir = new File( outputDirectory );
|
||||
|
||||
// Test parameter setting
|
||||
if ( pluginItem != null )
|
||||
{
|
||||
touch( outDir, pluginItem );
|
||||
touch( outputDirectory, pluginItem );
|
||||
}
|
||||
|
||||
if ( goalItem != null )
|
||||
{
|
||||
touch( outDir, goalItem );
|
||||
touch( outputDirectory, goalItem );
|
||||
}
|
||||
|
||||
if ( artifactToFile != null )
|
||||
|
@ -122,10 +127,10 @@ public class CoreItMojo
|
|||
|
||||
String filename = artifactFile.getAbsolutePath().replace('/', '_').replace(':', '_') + ".txt";
|
||||
|
||||
touch( outDir, filename );
|
||||
touch( outputDirectory, filename );
|
||||
}
|
||||
|
||||
project.getBuild().setFinalName( "coreitified" );
|
||||
project.getBuild().setFinalName( FINAL_NAME );
|
||||
}
|
||||
|
||||
private static void touch( File dir, String file )
|
Loading…
Reference in New Issue