mirror of https://github.com/apache/maven.git
[MNG-2771] Provide a means of loading custom substitute components instead of default Maven components
o Added it0124 to ensure POM extensions can override default component implementations (currently broken and commented-out) git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@550826 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ab1fd9c6e
commit
5b3c8f9b00
|
@ -176,6 +176,7 @@ public class IntegrationTestSuite
|
||||||
//suite.addTestSuite( MavenIT0121TransitiveDepManVersion.class ); -- MNG-3038
|
//suite.addTestSuite( MavenIT0121TransitiveDepManVersion.class ); -- MNG-3038
|
||||||
// suite.addTestSuite( MavenIT0122ReactorDependencyResolutionTest.class ); -- MNG-3023
|
// suite.addTestSuite( MavenIT0122ReactorDependencyResolutionTest.class ); -- MNG-3023
|
||||||
// suite.addTestSuite( MavenIT0123SnapshotRangeRepositoryTest.class ); -- MNG-2994
|
// suite.addTestSuite( MavenIT0123SnapshotRangeRepositoryTest.class ); -- MNG-2994
|
||||||
|
// suite.addTestSuite( MavenIT0124PomExtensionComponentOverrideTest.class ); -- MNG-2771
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.apache.maven.integrationtests;
|
||||||
|
|
||||||
|
import org.apache.maven.it.Verifier;
|
||||||
|
import org.apache.maven.it.util.ResourceExtractor;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class MavenIT0124PomExtensionComponentOverrideTest
|
||||||
|
extends AbstractMavenIntegrationTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test that ensures the POM extensions can override default component implementations.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void testit0124() throws Exception
|
||||||
|
{
|
||||||
|
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0124-pomExtensionComponentOverride/extension" );
|
||||||
|
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||||
|
verifier.executeGoal( "install" );
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
verifier.resetStreams();
|
||||||
|
|
||||||
|
testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0124-pomExtensionComponentOverride/plugin" );
|
||||||
|
verifier = new Verifier( testDir.getAbsolutePath() );
|
||||||
|
verifier.executeGoal( "install" );
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
verifier.resetStreams();
|
||||||
|
|
||||||
|
testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0124-pomExtensionComponentOverride/project" );
|
||||||
|
verifier = new Verifier( testDir.getAbsolutePath() );
|
||||||
|
verifier.executeGoal( "verify" );
|
||||||
|
verifier.verifyErrorFreeLog();
|
||||||
|
verifier.resetStreams();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<name>Maven Integration Test :: it0124</name>
|
||||||
|
<groupId>org.apache.maven.its.it0124</groupId>
|
||||||
|
<artifactId>maven-it-it0124-extension</artifactId>
|
||||||
|
<description>Project that provides an alternative ArtifactFactory implementation for testing.</description>
|
||||||
|
<version>1.0</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-artifact</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.apache.maven.its.it0124;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.artifact.factory.DefaultArtifactFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple alternative artifact factory implementation for testing.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
|
||||||
|
*/
|
||||||
|
public class CustomArtifactFactory
|
||||||
|
extends DefaultArtifactFactory
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<!--
|
||||||
|
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.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||||
|
<implementation>org.apache.maven.its.it0124.CustomArtifactFactory</implementation>
|
||||||
|
</component>
|
||||||
|
</components>
|
||||||
|
</component-set>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<name>Maven Integration Test :: it0124</name>
|
||||||
|
<groupId>org.apache.maven.its.it0124</groupId>
|
||||||
|
<artifactId>maven-it-it0124-plugin</artifactId>
|
||||||
|
<packaging>maven-plugin</packaging>
|
||||||
|
<description>Plugin that writes the injected artifact factory implementation to a file.</description>
|
||||||
|
<version>1.0</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-artifact</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,78 @@
|
||||||
|
package org.apache.maven.its.it0124;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.BufferedOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
|
import org.apache.maven.artifact.factory.DefaultArtifactFactory;
|
||||||
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple mojo to write the injected artifact factory implementation to a file.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
|
||||||
|
* @goal lookup
|
||||||
|
*/
|
||||||
|
public class LookupMojo extends AbstractMojo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @component
|
||||||
|
*/
|
||||||
|
private ArtifactFactory artifactFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @parameter expression="${project.build.directory}"
|
||||||
|
*/
|
||||||
|
private String buildDirectory;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.apache.maven.plugin.Mojo#execute()
|
||||||
|
*/
|
||||||
|
public void execute() throws MojoExecutionException, MojoFailureException
|
||||||
|
{
|
||||||
|
File file = new File( buildDirectory, "lookup.log" );
|
||||||
|
|
||||||
|
if ( !file.getParentFile().mkdirs() )
|
||||||
|
{
|
||||||
|
throw new MojoExecutionException( "Cannot create build directory" );
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Writer writer = new FileWriter( file );
|
||||||
|
writer.write( artifactFactory == null ? "null" : artifactFactory.getClass().getName() );
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
catch ( IOException exception )
|
||||||
|
{
|
||||||
|
throw new MojoExecutionException( "Cannot create lookup.log", exception );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<name>Maven Integration Test :: it0124</name>
|
||||||
|
<groupId>org.apache.maven.its.it0124</groupId>
|
||||||
|
<artifactId>maven-it-it0124</artifactId>
|
||||||
|
<description>Test that ensures the POM extensions can override default component implementations.</description>
|
||||||
|
<version>1.0</version>
|
||||||
|
<build>
|
||||||
|
<extensions>
|
||||||
|
<extension>
|
||||||
|
<groupId>org.apache.maven.its.it0124</groupId>
|
||||||
|
<artifactId>maven-it-it0124-extension</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</extension>
|
||||||
|
</extensions>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.its.it0124</groupId>
|
||||||
|
<artifactId>maven-it-it0124-plugin</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>lookup</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-verifier-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<verificationFile>src/test/verifier/verifications-test.xml</verificationFile>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<verifications>
|
||||||
|
<files>
|
||||||
|
<file>
|
||||||
|
<location>target/lookup.log</location>
|
||||||
|
<contains>org.apache.maven.its.it0124.CustomArtifactFactory</contains>
|
||||||
|
</file>
|
||||||
|
</files>
|
||||||
|
</verifications>
|
|
@ -123,5 +123,6 @@
|
||||||
<module>it0121-transitiveDepManVersion</module>
|
<module>it0121-transitiveDepManVersion</module>
|
||||||
<module>it0122-reactorDependencyResolution</module>
|
<module>it0122-reactorDependencyResolution</module>
|
||||||
<module>it0123-snapshotRangeRepository</module>
|
<module>it0123-snapshotRangeRepository</module>
|
||||||
|
<!-- <module>it0124-pomExtensionComponentOverride</module> not fixed yet -->
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue