mirror of https://github.com/apache/maven.git
[MNG-4811] Custom Maven Plugin regression in Maven 3.x, custom ComponentConfigurator causes infinite loop
o Added IT git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@998228 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
efd19269c5
commit
95eaeb853e
|
@ -83,6 +83,7 @@ public class IntegrationTestSuite
|
||||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||||
|
|
||||||
suite.addTestSuite( MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.class );
|
suite.addTestSuite( MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.class );
|
||||||
|
suite.addTestSuite( MavenITmng4811CustomComponentConfiguratorTest.class );
|
||||||
suite.addTestSuite( MavenITmng4800NearestWinsVsScopeWideningTest.class );
|
suite.addTestSuite( MavenITmng4800NearestWinsVsScopeWideningTest.class );
|
||||||
suite.addTestSuite( MavenITmng4795DepResolutionInReactorProjectForkedByLifecycleTest.class );
|
suite.addTestSuite( MavenITmng4795DepResolutionInReactorProjectForkedByLifecycleTest.class );
|
||||||
suite.addTestSuite( MavenITmng4791ProjectBuilderResolvesRemotePomArtifactTest.class );
|
suite.addTestSuite( MavenITmng4791ProjectBuilderResolvesRemotePomArtifactTest.class );
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
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;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4811">MNG-4811</a>.
|
||||||
|
*/
|
||||||
|
public class MavenITmng4811CustomComponentConfiguratorTest
|
||||||
|
extends AbstractMavenIntegrationTestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public MavenITmng4811CustomComponentConfiguratorTest()
|
||||||
|
{
|
||||||
|
super( "[2.0.3,3.0-alpha-1)[3.0,)" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify that plugins can use custom component configurators.
|
||||||
|
*/
|
||||||
|
public void testit()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4811" );
|
||||||
|
|
||||||
|
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||||
|
verifier.setAutoclean( false );
|
||||||
|
verifier.deleteDirectory( "target" );
|
||||||
|
verifier.executeGoal( "validate" );
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
verifier.resetStreams();
|
||||||
|
|
||||||
|
Properties props = verifier.loadProperties( "target/config.properties" );
|
||||||
|
assertEquals( "PASSED", props.getProperty( "stringParam" ) );
|
||||||
|
assertEquals( "configured", props.getProperty( "customParam" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?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.mng4811</groupId>
|
||||||
|
<artifactId>test</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
|
||||||
|
<name>Maven Integration Test :: MNG-4811</name>
|
||||||
|
<description>
|
||||||
|
Verify that plugins can use custom component configurators.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
|
<artifactId>maven-it-plugin-configuration</artifactId>
|
||||||
|
<version>2.1-SNAPSHOT</version>
|
||||||
|
<configuration>
|
||||||
|
<propertiesFile>target/config.properties</propertiesFile>
|
||||||
|
<stringParam>PASSED</stringParam>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>custom-config</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,57 @@
|
||||||
|
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.codehaus.classworlds.ClassRealm;
|
||||||
|
import org.codehaus.plexus.component.configurator.AbstractComponentConfigurator;
|
||||||
|
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
|
||||||
|
import org.codehaus.plexus.component.configurator.ConfigurationListener;
|
||||||
|
import org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter;
|
||||||
|
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
|
||||||
|
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A custom component configurator. Does not do much special compared to the basic one, but is sufficient to check
|
||||||
|
* general support of the specific API.
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
* @plexus.component role="org.codehaus.plexus.component.configurator.ComponentConfigurator" role-hint="coreit"
|
||||||
|
*/
|
||||||
|
public class CustomComponentConfigurator
|
||||||
|
extends AbstractComponentConfigurator
|
||||||
|
{
|
||||||
|
|
||||||
|
public void configureComponent( Object component, PlexusConfiguration configuration,
|
||||||
|
ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm,
|
||||||
|
ConfigurationListener listener )
|
||||||
|
throws ComponentConfigurationException
|
||||||
|
{
|
||||||
|
ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter();
|
||||||
|
|
||||||
|
converter.processConfiguration( converterLookup, component, containerRealm.getClassLoader(), configuration,
|
||||||
|
expressionEvaluator, listener );
|
||||||
|
|
||||||
|
if ( component instanceof CustomConfigMojo )
|
||||||
|
{
|
||||||
|
( (CustomConfigMojo) component ).customParam = "configured";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,186 @@
|
||||||
|
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.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps this mojo's configuration into a properties file. Note that this mojo uses a custom component configurator.
|
||||||
|
*
|
||||||
|
* @goal custom-config
|
||||||
|
* @phase validate
|
||||||
|
* @configurator coreit
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class CustomConfigMojo
|
||||||
|
extends AbstractMojo
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current project's base directory, used for path alignment.
|
||||||
|
*
|
||||||
|
* @parameter default-value="${basedir}"
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
private File basedir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path to the properties file into which to save the mojo configuration.
|
||||||
|
*
|
||||||
|
* @parameter expression="${config.propertiesFile}"
|
||||||
|
*/
|
||||||
|
private File propertiesFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A parameter being set only by the custom configurator as a proof of its execution.
|
||||||
|
*
|
||||||
|
* @parameter
|
||||||
|
*/
|
||||||
|
String customParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A parameter with a constant default value. <em>Note:</em> This has intentionally a different default value than
|
||||||
|
* the equally named parameter from {@link ConfigMojo}.
|
||||||
|
*
|
||||||
|
* @parameter default-value="test"
|
||||||
|
*/
|
||||||
|
private String defaultParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple parameter of type {@link java.lang.String}.
|
||||||
|
*
|
||||||
|
* @parameter expression="${config.stringParam}"
|
||||||
|
*/
|
||||||
|
private String stringParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple parameter of type {@link java.io.File}.
|
||||||
|
*
|
||||||
|
* @parameter expression="${config.fileParam}"
|
||||||
|
*/
|
||||||
|
private File fileParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array parameter of component type {@link java.lang.String}.
|
||||||
|
*
|
||||||
|
* @parameter
|
||||||
|
*/
|
||||||
|
private String[] stringParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array parameter of component type {@link java.io.File}.
|
||||||
|
*
|
||||||
|
* @parameter
|
||||||
|
*/
|
||||||
|
private File[] fileParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection parameter of type {@link java.util.List}.
|
||||||
|
*
|
||||||
|
* @parameter
|
||||||
|
*/
|
||||||
|
private List listParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection parameter of type {@link java.util.Set}.
|
||||||
|
*
|
||||||
|
* @parameter
|
||||||
|
*/
|
||||||
|
private Set setParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection parameter of type {@link java.util.Map}.
|
||||||
|
*
|
||||||
|
* @parameter
|
||||||
|
*/
|
||||||
|
private Map mapParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection parameter of type {@link java.util.Properties}.
|
||||||
|
*
|
||||||
|
* @parameter
|
||||||
|
*/
|
||||||
|
private Properties propertiesParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs this mojo.
|
||||||
|
*
|
||||||
|
* @throws MojoExecutionException If the output file could not be created.
|
||||||
|
*/
|
||||||
|
public void execute()
|
||||||
|
throws MojoExecutionException
|
||||||
|
{
|
||||||
|
getLog().info( "[MAVEN-CORE-IT-LOG] Using output file path: " + propertiesFile );
|
||||||
|
|
||||||
|
if ( propertiesFile == null )
|
||||||
|
{
|
||||||
|
throw new MojoExecutionException( "Path name for output file has not been specified" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !propertiesFile.isAbsolute() )
|
||||||
|
{
|
||||||
|
propertiesFile = new File( basedir, propertiesFile.getPath() ).getAbsoluteFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties configProps = new Properties();
|
||||||
|
|
||||||
|
dumpConfiguration( configProps );
|
||||||
|
|
||||||
|
getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file: " + propertiesFile );
|
||||||
|
|
||||||
|
PropertiesUtil.write( propertiesFile, configProps );
|
||||||
|
|
||||||
|
getLog().info( "[MAVEN-CORE-IT-LOG] Created output file: " + propertiesFile );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the mojo configuration into the specified properties.
|
||||||
|
*
|
||||||
|
* @param props The properties to dump the configuration into, must not be <code>null</code>.
|
||||||
|
*/
|
||||||
|
private void dumpConfiguration( Properties props )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* NOTE: This intentionally does not dump the absolute path of a file to check the actual value that was
|
||||||
|
* injected by Maven.
|
||||||
|
*/
|
||||||
|
PropertiesUtil.serialize( props, "propertiesFile", propertiesFile );
|
||||||
|
PropertiesUtil.serialize( props, "customParam", customParam );
|
||||||
|
PropertiesUtil.serialize( props, "defaultParam", defaultParam );
|
||||||
|
PropertiesUtil.serialize( props, "stringParam", stringParam );
|
||||||
|
PropertiesUtil.serialize( props, "fileParam", fileParam );
|
||||||
|
PropertiesUtil.serialize( props, "stringParams", stringParams );
|
||||||
|
PropertiesUtil.serialize( props, "fileParams", fileParams );
|
||||||
|
PropertiesUtil.serialize( props, "listParam", listParam );
|
||||||
|
PropertiesUtil.serialize( props, "setParam", setParam );
|
||||||
|
PropertiesUtil.serialize( props, "mapParam", mapParam );
|
||||||
|
PropertiesUtil.serialize( props, "propertiesParam", propertiesParam );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<component-set>
|
||||||
|
<components>
|
||||||
|
<component>
|
||||||
|
<role>org.codehaus.plexus.component.configurator.ComponentConfigurator</role>
|
||||||
|
<role-hint>coreit</role-hint>
|
||||||
|
<implementation>org.apache.maven.plugin.coreit.CustomComponentConfigurator</implementation>
|
||||||
|
<description>A custom component configurator.</description>
|
||||||
|
<isolated-realm>false</isolated-realm>
|
||||||
|
</component>
|
||||||
|
</components>
|
||||||
|
</component-set>
|
|
@ -1,12 +1,33 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<!--
|
||||||
|
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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>maven-it-plugins</artifactId>
|
<artifactId>maven-it-plugins</artifactId>
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
<version>2.1-SNAPSHOT</version>
|
<version>2.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>maven-it-plugin-error</artifactId>
|
<artifactId>maven-it-plugin-error</artifactId>
|
||||||
<packaging>maven-plugin</packaging>
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue