[MNG-4786] [regression] Ant-based mojo using maven-script-ant:2.1.0+ causes NPE

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@991258 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-08-31 16:53:49 +00:00
parent 7921107194
commit 149f4eb440
5 changed files with 163 additions and 4 deletions

View File

@ -81,6 +81,7 @@ public class IntegrationTestSuite
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
suite.addTestSuite( MavenITmng4786AntBased21xMojoSupportTest.class );
suite.addTestSuite( MavenITmng4781DeploymentToNexusStagingRepoTest.class );
suite.addTestSuite( MavenITmng4779MultipleDepsWithVersionRangeFromLocalRepoTest.class );
suite.addTestSuite( MavenITmng4776ForkedReactorPluginVersionResolutionTest.class );
@ -158,7 +159,7 @@ public class IntegrationTestSuite
suite.addTestSuite( MavenITmng4402DuplicateChildModuleTest.class );
suite.addTestSuite( MavenITmng4401RepositoryOrderForParentPomTest.class );
suite.addTestSuite( MavenITmng4400RepositoryOrderTest.class );
suite.addTestSuite( MavenITmng4396AntBasedMojoSupportTest.class );
suite.addTestSuite( MavenITmng4396AntBased20xMojoSupportTest.class );
suite.addTestSuite( MavenITmng4393ParseExternalParenPomLenientTest.class );
suite.addTestSuite( MavenITmng4387QuietLoggingTest.class );
suite.addTestSuite( MavenITmng4386DebugLoggingTest.class );

View File

@ -29,17 +29,18 @@ import java.io.File;
*
* @author Benjamin Bentmann
*/
public class MavenITmng4396AntBasedMojoSupportTest
public class MavenITmng4396AntBased20xMojoSupportTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng4396AntBasedMojoSupportTest()
public MavenITmng4396AntBased20xMojoSupportTest()
{
super( ALL_MAVEN_VERSIONS );
}
/**
* Verify that plugins whose mojos are implemented as Ant scripts can be invoked.
* Verify that plugins whose mojos are implemented as Ant scripts and use the Maven 2.0.x Ant support can be
* invoked.
*/
public void testit()
throws Exception

View File

@ -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-4786">MNG-4786</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng4786AntBased21xMojoSupportTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng4786AntBased21xMojoSupportTest()
{
super( "[2.0.3,3.0-alpha-1),[3.0-beta-4,)" );
}
/**
* Verify that plugins whose mojos are implemented as Ant scripts and use the Maven 2.1.x Ant support can be
* invoked. The essential bits here are that Ant-based mojos are instantiated via a custom component factory, yet
* must undergo the same IoC as for regular Java components. And the 2.1.x Ant support actually requires injection
* of a logger.
*/
public void testit()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4786" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
verifier.assertFilePresent( "target/ant.txt" );
}
}

View File

@ -51,5 +51,21 @@ under the License.
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-script-ant</artifactId>
<version>2.1.0</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,79 @@
<?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.mng4786</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<name>Maven Integration Test :: MNG-4786</name>
<description>
Verify that plugins whose mojos are implemented as Ant scripts and use the Maven 2.1.x Ant support can be
invoked. The essential bits here are that Ant-based mojos are instantiated via a custom component factory, yet
must undergo the same IoC as for regular Java components. And the 2.1.x Ant support actually requires injection
of a logger.
</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-ant-based</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<outputFile>target/ant.txt</outputFile>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>validate</phase>
<goals>
<goal>touch</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-script-ant</artifactId>
<version>2.1.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>