From 16fa596774ef88afba3265a7f173597150f114a2 Mon Sep 17 00:00:00 2001 From: rfscholte Date: Fri, 12 Mar 2021 17:21:19 +0100 Subject: [PATCH] [MNG-7110] Different behavior of extensions --- .../apache/maven/it/IntegrationTestSuite.java | 1 + .../MavenITmng7110ExtensionClassloader.java | 66 +++++++++++++++++ .../mng-7110-extensionclassloader/bom/pom.xml | 41 ++++++++++ .../extension/pom.xml | 31 ++++++++ .../src/main/resources/extension.txt | 16 ++++ .../mng-7110-extensionclassloader/lib/pom.xml | 31 ++++++++ .../lib/src/main/resources/lib.txt | 16 ++++ .../module/pom.xml | 74 +++++++++++++++++++ .../parent/pom.xml | 54 ++++++++++++++ 9 files changed, 330 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7110ExtensionClassloader.java create mode 100644 its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/bom/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/extension/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/extension/src/main/resources/extension.txt create mode 100644 its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/lib/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/lib/src/main/resources/lib.txt create mode 100644 its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/module/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/parent/pom.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 337e1a97e5..25b9375e84 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -106,6 +106,7 @@ public static Test suite() // Tests that don't run stable and need to be fixed // ------------------------------------------------------------------------------------------------------------- // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137 + suite.addTestSuite( MavenITmng7110ExtensionClassloader.class ); suite.addTestSuite( MavenITmng7051OptionalProfileActivationTest.class ); suite.addTestSuite( MavenITmng6957BuildConsumer.class ); suite.addTestSuite( MavenITmng7045DropUselessAndOutdatedCdiApiTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7110ExtensionClassloader.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7110ExtensionClassloader.java new file mode 100644 index 0000000000..dbf313c3ea --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7110ExtensionClassloader.java @@ -0,0 +1,66 @@ +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 java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.Reader; +import java.util.Properties; + +import org.apache.maven.it.util.ResourceExtractor; + +public class MavenITmng7110ExtensionClassloader + extends AbstractMavenIntegrationTestCase +{ + public MavenITmng7110ExtensionClassloader() + { + super( ALL_MAVEN_VERSIONS ); + } + + public void testVerifyResourceOfExtensionAndDependency() throws IOException, VerificationException + { + final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-7110-extensionclassloader" ); + + final Verifier extensionVerifier = newVerifier( new File( projectDir, "extension" ).getAbsolutePath() ); + extensionVerifier.executeGoal( "install" ); + extensionVerifier.verifyErrorFreeLog(); + + final Verifier libVerifier = newVerifier( new File( projectDir, "lib" ).getAbsolutePath() ); + libVerifier.executeGoal( "install" ); + libVerifier.verifyErrorFreeLog(); + + final Verifier bomVerifier = newVerifier( new File( projectDir, "bom" ).getAbsolutePath() ); + bomVerifier.executeGoal( "install" ); + bomVerifier.verifyErrorFreeLog(); + + final Verifier projectVerifier = newVerifier( new File( projectDir, "module" ).getAbsolutePath() ); + projectVerifier.executeGoal( "verify" ); + projectVerifier.verifyErrorFreeLog(); + + Properties properties = new Properties(); + Reader fileReader = new FileReader( new File( projectDir, "module/out.txt" ) ); + properties.load( fileReader ); + + assertEquals( "1", properties.getProperty( "extension.txt.count", "-1" ) ); + assertEquals( "1", properties.getProperty( "lib.txt.count", "-1" ) ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/bom/pom.xml b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/bom/pom.xml new file mode 100644 index 0000000000..96f011a0c8 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/bom/pom.xml @@ -0,0 +1,41 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng7110 + bom + 1.0 + pom + + + + + org.apache.maven.its.mng7110 + lib + 1.0 + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/extension/pom.xml b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/extension/pom.xml new file mode 100644 index 0000000000..c66323b53b --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/extension/pom.xml @@ -0,0 +1,31 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng7110 + extension + 1.0 + + diff --git a/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/extension/src/main/resources/extension.txt b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/extension/src/main/resources/extension.txt new file mode 100644 index 0000000000..90705e02e0 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/extension/src/main/resources/extension.txt @@ -0,0 +1,16 @@ +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. \ No newline at end of file diff --git a/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/lib/pom.xml b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/lib/pom.xml new file mode 100644 index 0000000000..634db8c46c --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/lib/pom.xml @@ -0,0 +1,31 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng7110 + lib + 1.0 + + diff --git a/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/lib/src/main/resources/lib.txt b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/lib/src/main/resources/lib.txt new file mode 100644 index 0000000000..90705e02e0 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/lib/src/main/resources/lib.txt @@ -0,0 +1,16 @@ +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. \ No newline at end of file diff --git a/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/module/pom.xml b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/module/pom.xml new file mode 100644 index 0000000000..6e720e083a --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/module/pom.xml @@ -0,0 +1,74 @@ + + + + + + 4.0.0 + + + + org.apache.maven.its.mng7110 + parent + 1.0 + ../parent + + module + + + + org.apache.maven.its.mng7110 + lib + 1.0 + + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-class-loader + 2.1-SNAPSHOT + + + verify + + load-dependencies + + + out.txt + lib.txt,extension.txt + + + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-class-loader + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/parent/pom.xml b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/parent/pom.xml new file mode 100644 index 0000000000..c08642ca84 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-7110-extensionclassloader/parent/pom.xml @@ -0,0 +1,54 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng7110 + parent + 1.0 + pom + + + + + org.apache.maven.its.mng7110 + bom + 1.0 + pom + import + + + + + + + + org.apache.maven.its.mng7110 + extension + 1.0 + + + + +