[MNG-5958] restore binary compatibility of Lifecycle.setPhases

Modify tests for MNG-5805

This closes #13 #18
This commit is contained in:
Anton Tanasenko 2016-01-07 04:01:28 +02:00 committed by Christian Schulte
parent 46278d17b2
commit 89afd751a0
16 changed files with 609 additions and 1 deletions

View File

@ -106,10 +106,12 @@ public class IntegrationTestSuite
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
suite.addTestSuite( MavenITmng5958LifecyclePhaseBinaryCompat.class );
suite.addTestSuite( MavenITmng5898BuildMultimoduleWithEARFailsToResolveWARTest.class );
suite.addTestSuite( MavenITmng5840ParentVersionRanges.class );
suite.addTestSuite( MavenITmng5840RelativePathReactorMatching.class );
suite.addTestSuite( MavenITmng5805PkgTypeMojoConfiguration.class );
suite.addTestSuite( MavenITmng5805PkgTypeMojoConfiguration2.class );
suite.addTestSuite( MavenITmng5783PluginDependencyFiltering.class );
suite.addTestSuite( MavenITmng5774ConfigurationProcessorsTest.class );
suite.addTestSuite( MavenITmng5771CoreExtensionsTest.class );

View File

@ -10,7 +10,7 @@ public class MavenITmng5805PkgTypeMojoConfiguration
public MavenITmng5805PkgTypeMojoConfiguration()
{
super( "(3.3.3,)" );
super( "(3.3.3,3.5.0)" );
}
public void testPkgTypeMojoConfiguration()

View File

@ -0,0 +1,30 @@
package org.apache.maven.it;
import java.io.File;
import org.apache.maven.it.util.ResourceExtractor;
public class MavenITmng5805PkgTypeMojoConfiguration2
extends AbstractMavenIntegrationTestCase
{
public MavenITmng5805PkgTypeMojoConfiguration2()
{
super( "(3.3.3,)" );
}
public void testPkgTypeMojoConfiguration()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5805-pkg-type-mojo-configuration2" );
Verifier verifier;
verifier = newVerifier( testDir.getAbsolutePath() );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.verifyTextInLog( "CLASS_NAME=org.apache.maven.its.mng5805.TestClass1" );
verifier.resetStreams();
}
}

View File

@ -0,0 +1,45 @@
package org.apache.maven.it;
import java.io.File;
import org.apache.maven.it.util.ResourceExtractor;
public class MavenITmng5958LifecyclePhaseBinaryCompat
extends AbstractMavenIntegrationTestCase
{
public MavenITmng5958LifecyclePhaseBinaryCompat()
{
super( "(3.3.9,)" );
}
public void testGood()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5958-lifecycle-phases/good" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.verifyTextInLog( "CLASS_NAME=java.lang.String" );
verifier.resetStreams();
}
public void testBad()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5958-lifecycle-phases/bad" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try
{
verifier.executeGoal( "validate" );
}
catch ( VerificationException e )
{
verifier.verifyTextInLog( "[ERROR] Internal error: java.lang.ClassCastException: "
+ "org.apache.maven.lifecycle.mapping.LifecyclePhase cannot be cast to java.lang.String -> [Help 1]" );
}
verifier.resetStreams();
}
}

View File

@ -136,6 +136,18 @@ under the License.
<version>${itPluginVersion}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-extension2</artifactId>
<version>${itPluginVersion}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5958-pkg-type-extension</artifactId>
<version>${itPluginVersion}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>

View File

@ -0,0 +1,40 @@
<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mng-5805-pkg-type-mojo-configuration</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-project2</artifactId>
<version>0.1</version>
<packaging>mng5805</packaging>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-extension2</artifactId>
<version>2.1-SNAPSHOT</version>
</extension>
</extensions>
</build>
</project>

View File

@ -0,0 +1,53 @@
<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mng-5958-lifecycle-phases</groupId>
<artifactId>mng-5958-lifecycle-phases-project</artifactId>
<version>0.1</version>
<packaging>mng5958-bad</packaging>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5958-pkg-type-extension</artifactId>
<version>2.1-SNAPSHOT</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-plugin</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<className>java.lang.String</className>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,53 @@
<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mng-5958-lifecycle-phases</groupId>
<artifactId>mng-5958-lifecycle-phases-project</artifactId>
<version>0.1</version>
<packaging>mng5958-good</packaging>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5958-pkg-type-extension</artifactId>
<version>2.1-SNAPSHOT</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-plugin</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<className>java.lang.String</className>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,37 @@
<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-it-plugins</artifactId>
<groupId>org.apache.maven.its.plugins</groupId>
<version>2.1-SNAPSHOT</version>
</parent>
<artifactId>mng-5805-pkg-type-mojo-configuration-extension2</artifactId>
<packaging>jar</packaging>
<name>Maven IT Plugin :: mng-5805 extension mk2</name>
</project>

View File

@ -0,0 +1,71 @@
<?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.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>mng5805</role-hint>
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
<configuration>
<lifecycles>
<lifecycle>
<id>default</id>
<lifecyclePhases>
<validate>
<mojos>
<mojo>
<goal>
org.apache.maven.its.plugins:mng-5805-pkg-type-mojo-configuration-plugin:2.1-SNAPSHOT:test
</goal>
<configuration>
<className>org.apache.maven.its.mng5805.TestClass1</className>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>mng-5805-pkg-type-mojo-configuration-plugin-dep</artifactId>
<version>2.1-SNAPSHOT</version>
</dependency>
</dependencies>
</mojo>
</mojos>
</validate>
</lifecyclePhases>
</lifecycle>
</lifecycles>
</configuration>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>mng5805</role-hint>
<implementation>
org.apache.maven.artifact.handler.DefaultArtifactHandler
</implementation>
<configuration>
<extension>zip</extension>
<type>mng5805</type>
<packaging>mng5805</packaging>
</configuration>
</component>
</components>
</component-set>

View File

@ -0,0 +1,45 @@
<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-it-plugins</artifactId>
<groupId>org.apache.maven.its.plugins</groupId>
<version>2.1-SNAPSHOT</version>
</parent>
<artifactId>mng-5958-pkg-type-extension</artifactId>
<packaging>jar</packaging>
<name>Maven IT Plugin :: mng-5958 extension</name>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.3.9</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,71 @@
package org.apache.maven.its.mng5958;
/*
* 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.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.maven.lifecycle.mapping.Lifecycle;
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
/**
* @author Anton Tanasenko
*/
public abstract class AbstractLifecycleMapping implements LifecycleMapping
{
private Map<String, Lifecycle> lifecycleMap;
public Map<String, Lifecycle> getLifecycles()
{
if ( lifecycleMap != null )
{
return lifecycleMap;
}
lifecycleMap = new LinkedHashMap<>();
Lifecycle lifecycle = new Lifecycle();
lifecycle.setId( "default" );
lifecycle.setPhases( initPhases() );
lifecycleMap.put( "default", lifecycle );
return lifecycleMap;
}
public Map<String, String> getPhases( String lifecycle )
{
Lifecycle lifecycleMapping = getLifecycles().get( lifecycle );
if ( lifecycleMapping != null )
{
return lifecycleMapping.getPhases();
}
return null;
}
public List<String> getOptionalMojos( String lifecycle )
{
return null;
}
// raw map on purpose
protected abstract Map initPhases();
}

View File

@ -0,0 +1,45 @@
package org.apache.maven.its.mng5958;
/*
* 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.LinkedHashMap;
import java.util.Map;
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
/**
* @author Anton Tanasenko
*/
public class BadLifecycleMapping extends AbstractLifecycleMapping
{
@Override
protected Map<String, String> initPhases()
{
Map phases = new LinkedHashMap<>();
LifecyclePhase lp = new LifecyclePhase();
lp.set( "org.apache.maven.its.plugins:mng-5805-pkg-type-mojo-configuration-plugin:2.1-SNAPSHOT:test" );
phases.put( "validate", lp );
return phases;
}
}

View File

@ -0,0 +1,40 @@
package org.apache.maven.its.mng5958;
/*
* 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.LinkedHashMap;
import java.util.Map;
/**
* @author Anton Tanasenko
*/
public class GoodLifecycleMapping extends AbstractLifecycleMapping
{
@Override
protected Map<String, String> initPhases()
{
Map<String, String> phases = new LinkedHashMap<>();
phases.put( "validate",
"org.apache.maven.its.plugins:mng-5805-pkg-type-mojo-configuration-plugin:2.1-SNAPSHOT:test" );
return phases;
}
}

View File

@ -0,0 +1,62 @@
<?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.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>mng5958-good</role-hint>
<implementation>org.apache.maven.its.mng5958.GoodLifecycleMapping</implementation>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>mng5958</role-hint>
<implementation>
org.apache.maven.artifact.handler.DefaultArtifactHandler
</implementation>
<configuration>
<extension>zip</extension>
<type>mng5858-good</type>
<packaging>mng5858-good</packaging>
</configuration>
</component>
<component>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>mng5958-bad</role-hint>
<implementation>org.apache.maven.its.mng5958.BadLifecycleMapping</implementation>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>mng5958-bad</role-hint>
<implementation>
org.apache.maven.artifact.handler.DefaultArtifactHandler
</implementation>
<configuration>
<extension>zip</extension>
<type>mng5858-bad</type>
<packaging>mng5858-bad</packaging>
</configuration>
</component>
</components>
</component-set>

View File

@ -79,8 +79,10 @@ under the License.
<module>maven-it-plugin-plexus-lifecycle</module>
<module>maven-it-plugin-settings</module>
<module>mng5805-extension</module>
<module>mng5805-extension2</module>
<module>mng5805-plugin</module>
<module>mng5805-plugin-dep</module>
<module>mng5958-extension</module>
</modules>
<scm>