Repository: maven-integration-testing Updated Branches: refs/heads/MNG-5958 [created] 885253820
[MNG-5958] restore binary compatibility of Lifecycle.setPhases This closes #13 Project: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/commit/88525382 Tree: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/88525382 Diff: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/88525382 Branch: refs/heads/MNG-5958 Commit: 8852538208e508fdc7b58d6332ca683bfc0c9373 Parents: f31241a Author: Anton Tanasenko <atg.sleepl...@gmail.com> Authored: Thu Jan 7 04:01:28 2016 +0200 Committer: Christian Schulte <schu...@apache.org> Committed: Tue Jan 10 00:15:52 2017 +0100 ---------------------------------------------------------------------- .../apache/maven/it/IntegrationTestSuite.java | 1 + ...avenITmng5958LifecyclePhaseBinaryCompat.java | 45 +++++++++++++ .../test/resources/bootstrap/group-3/pom.xml | 6 ++ .../mng-5958-lifecycle-phases/bad/pom.xml | 53 +++++++++++++++ .../mng-5958-lifecycle-phases/good/pom.xml | 53 +++++++++++++++ .../resources/META-INF/plexus/components.xml | 4 +- .../core-it-plugins/mng5958-extension/pom.xml | 45 +++++++++++++ .../its/mng5958/AbstractLifecycleMapping.java | 71 ++++++++++++++++++++ .../maven/its/mng5958/BadLifecycleMapping.java | 45 +++++++++++++ .../maven/its/mng5958/GoodLifecycleMapping.java | 40 +++++++++++ .../resources/META-INF/plexus/components.xml | 62 +++++++++++++++++ core-it-support/core-it-plugins/pom.xml | 1 + 12 files changed, 424 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 48051c9..c4fdbd5 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -106,6 +106,7 @@ 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 ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5958LifecyclePhaseBinaryCompat.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5958LifecyclePhaseBinaryCompat.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5958LifecyclePhaseBinaryCompat.java new file mode 100644 index 0000000..3ee3fe1 --- /dev/null +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5958LifecyclePhaseBinaryCompat.java @@ -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(); + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-suite/src/test/resources/bootstrap/group-3/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/bootstrap/group-3/pom.xml b/core-it-suite/src/test/resources/bootstrap/group-3/pom.xml index bcaaca6..8250ce9 100644 --- a/core-it-suite/src/test/resources/bootstrap/group-3/pom.xml +++ b/core-it-suite/src/test/resources/bootstrap/group-3/pom.xml @@ -136,6 +136,12 @@ under the License. <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> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-suite/src/test/resources/mng-5958-lifecycle-phases/bad/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5958-lifecycle-phases/bad/pom.xml b/core-it-suite/src/test/resources/mng-5958-lifecycle-phases/bad/pom.xml new file mode 100644 index 0000000..d565ae0 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5958-lifecycle-phases/bad/pom.xml @@ -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> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-suite/src/test/resources/mng-5958-lifecycle-phases/good/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5958-lifecycle-phases/good/pom.xml b/core-it-suite/src/test/resources/mng-5958-lifecycle-phases/good/pom.xml new file mode 100644 index 0000000..0419dcd --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5958-lifecycle-phases/good/pom.xml @@ -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> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-support/core-it-plugins/mng5805-extension/src/main/resources/META-INF/plexus/components.xml ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/mng5805-extension/src/main/resources/META-INF/plexus/components.xml b/core-it-support/core-it-plugins/mng5805-extension/src/main/resources/META-INF/plexus/components.xml index e7fb615..a07744d 100644 --- a/core-it-support/core-it-plugins/mng5805-extension/src/main/resources/META-INF/plexus/components.xml +++ b/core-it-support/core-it-plugins/mng5805-extension/src/main/resources/META-INF/plexus/components.xml @@ -28,7 +28,7 @@ under the License. <lifecycles> <lifecycle> <id>default</id> - <phases> + <lifecyclePhases> <validate> <mojos> <mojo> @@ -48,7 +48,7 @@ under the License. </mojo> </mojos> </validate> - </phases> + </lifecyclePhases> </lifecycle> </lifecycles> </configuration> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-support/core-it-plugins/mng5958-extension/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/mng5958-extension/pom.xml b/core-it-support/core-it-plugins/mng5958-extension/pom.xml new file mode 100644 index 0000000..5f41294 --- /dev/null +++ b/core-it-support/core-it-plugins/mng5958-extension/pom.xml @@ -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> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/AbstractLifecycleMapping.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/AbstractLifecycleMapping.java b/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/AbstractLifecycleMapping.java new file mode 100644 index 0000000..9a9db7a --- /dev/null +++ b/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/AbstractLifecycleMapping.java @@ -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(); +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/BadLifecycleMapping.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/BadLifecycleMapping.java b/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/BadLifecycleMapping.java new file mode 100644 index 0000000..7dbf2b5 --- /dev/null +++ b/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/BadLifecycleMapping.java @@ -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; + } + +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/GoodLifecycleMapping.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/GoodLifecycleMapping.java b/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/GoodLifecycleMapping.java new file mode 100644 index 0000000..c14099d --- /dev/null +++ b/core-it-support/core-it-plugins/mng5958-extension/src/main/java/org/apache/maven/its/mng5958/GoodLifecycleMapping.java @@ -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; + } + +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-support/core-it-plugins/mng5958-extension/src/main/resources/META-INF/plexus/components.xml ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/mng5958-extension/src/main/resources/META-INF/plexus/components.xml b/core-it-support/core-it-plugins/mng5958-extension/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 0000000..e61d294 --- /dev/null +++ b/core-it-support/core-it-plugins/mng5958-extension/src/main/resources/META-INF/plexus/components.xml @@ -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> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/88525382/core-it-support/core-it-plugins/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/pom.xml b/core-it-support/core-it-plugins/pom.xml index 83b5f79..93abe85 100644 --- a/core-it-support/core-it-plugins/pom.xml +++ b/core-it-support/core-it-plugins/pom.xml @@ -81,6 +81,7 @@ under the License. <module>mng5805-extension</module> <module>mng5805-plugin</module> <module>mng5805-plugin-dep</module> + <module>mng5958-extension</module> </modules> <scm>