From cb9d2c97076222604b22bdba99d2bcc4907c1c96 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 25 Apr 2024 12:01:06 +0200 Subject: [PATCH] [3.9.x] [MNG-8106] IT (#337) Created IT that does "wrong" (as same directory has once G and once A role), and verify that both level metadata is present. In other words, but none is dropped. --- https://issues.apache.org/jira/browse/MNG-8106 --- ...Tmng8106OverlappingDirectoryRolesTest.java | 58 +++++++++++++++ .../apache/maven/it/TestSuiteOrdering.java | 1 + .../test/resources/mng-8106/jar/.mvn/.gitkeep | 0 .../src/test/resources/mng-8106/jar/pom.xml | 47 ++++++++++++ .../resources/mng-8106/plugin/.mvn/.gitkeep | 0 .../test/resources/mng-8106/plugin/pom.xml | 74 +++++++++++++++++++ .../apache/maven/its/plugins/MavenPlugin.java | 35 +++++++++ 7 files changed, 215 insertions(+) create mode 100644 core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8106OverlappingDirectoryRolesTest.java create mode 100644 core-it-suite/src/test/resources/mng-8106/jar/.mvn/.gitkeep create mode 100644 core-it-suite/src/test/resources/mng-8106/jar/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-8106/plugin/.mvn/.gitkeep create mode 100644 core-it-suite/src/test/resources/mng-8106/plugin/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-8106/plugin/src/main/java/org/apache/maven/its/plugins/MavenPlugin.java diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8106OverlappingDirectoryRolesTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8106OverlappingDirectoryRolesTest.java new file mode 100644 index 000000000..80e38b072 --- /dev/null +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8106OverlappingDirectoryRolesTest.java @@ -0,0 +1,58 @@ +/* + * 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. + */ +package org.apache.maven.it; + +import java.io.File; +import java.io.FileReader; + +import org.apache.maven.shared.verifier.Verifier; +import org.apache.maven.shared.verifier.util.ResourceExtractor; +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.codehaus.plexus.util.xml.Xpp3DomBuilder; +import org.junit.jupiter.api.Test; + +public class MavenITmng8106OverlappingDirectoryRolesTest extends AbstractMavenIntegrationTestCase { + public MavenITmng8106OverlappingDirectoryRolesTest() { + // Broken in: 3.9.0..3.9.6 && 4.0.0-alpha-1..4.0.0-alpha-13 + super("[,3.9.0),(3.9.6,3.999.999],[4.0.0-beta-1,)"); + } + + @Test + public void testDirectoryOverlap() throws Exception { + File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8106"); + + Verifier verifier = newVerifier(new File(testDir, "plugin").getAbsolutePath()); + verifier.addCliArgument("install"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + + verifier = newVerifier(new File(testDir, "jar").getAbsolutePath()); + verifier.addCliArgument("install"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + + File metadataFile = new File(new File(verifier.getLocalRepository()), "mng-8106/it/maven-metadata-local.xml"); + Xpp3Dom dom; + try (FileReader reader = new FileReader(metadataFile)) { + dom = Xpp3DomBuilder.build(reader); + } + assertTrue("metadata missing A level data", dom.getChild("versioning") != null); + assertTrue("metadata missing G level data", dom.getChild("plugins") != null); + } +} diff --git a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java index 159406bdd..0cd88ba47 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java @@ -120,6 +120,7 @@ public TestSuiteOrdering() { * the tests are to finishing. Newer tests are also more likely to fail, so this is * a fail fast technique as well. */ + suite.addTestSuite(MavenITmng8106OverlappingDirectoryRolesTest.class); suite.addTestSuite(MavenITmng7939PluginsValidationExcludesTest.class); suite.addTestSuite(MavenITmng7804PluginExecutionOrderTest.class); suite.addTestSuite(MavenITmng7836AlternativePomSyntaxTest.class); diff --git a/core-it-suite/src/test/resources/mng-8106/jar/.mvn/.gitkeep b/core-it-suite/src/test/resources/mng-8106/jar/.mvn/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/core-it-suite/src/test/resources/mng-8106/jar/pom.xml b/core-it-suite/src/test/resources/mng-8106/jar/pom.xml new file mode 100644 index 000000000..a8d93c46c --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8106/jar/pom.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + + mng-8106 + it + 0.1 + jar + + + 3.8.6 + + + + + org.apache.maven + maven-model + ${maven-version} + provided + + + org.apache.maven + maven-core + ${maven-version} + provided + + + + diff --git a/core-it-suite/src/test/resources/mng-8106/plugin/.mvn/.gitkeep b/core-it-suite/src/test/resources/mng-8106/plugin/.mvn/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/core-it-suite/src/test/resources/mng-8106/plugin/pom.xml b/core-it-suite/src/test/resources/mng-8106/plugin/pom.xml new file mode 100644 index 000000000..b7d27b7c3 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8106/plugin/pom.xml @@ -0,0 +1,74 @@ + + + + 4.0.0 + + mng-8106.it + plugin + 0.1 + maven-plugin + + + 3.8.6 + 3.2 + + + + + org.apache.maven + maven-plugin-api + ${mavenVersion} + provided + + + org.apache.maven + maven-model + ${mavenVersion} + provided + + + org.apache.maven + maven-core + ${mavenVersion} + provided + + + org.apache.maven.plugin-tools + maven-plugin-annotations + ${mavenPluginPluginVersion} + provided + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + + plugin + + + + + + + diff --git a/core-it-suite/src/test/resources/mng-8106/plugin/src/main/java/org/apache/maven/its/plugins/MavenPlugin.java b/core-it-suite/src/test/resources/mng-8106/plugin/src/main/java/org/apache/maven/its/plugins/MavenPlugin.java new file mode 100644 index 000000000..2e4f074cc --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8106/plugin/src/main/java/org/apache/maven/its/plugins/MavenPlugin.java @@ -0,0 +1,35 @@ +/* + * 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. + */ +package org.apache.maven.its.plugins; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Mojo(name = "plugin") +public class MavenPlugin extends AbstractMojo { + + private static final Logger log = LoggerFactory.getLogger(MavenPlugin.class); + + public void execute() throws MojoExecutionException { + log.info("Booo"); + } +}