From a14732597bb10fa378cb117979707cf37bcfa240 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 15 Nov 2024 10:24:21 +0100 Subject: [PATCH] [MNG-8336] Only inject plugins information if requested (#1904) --- .../maven/project/DefaultProjectBuilder.java | 6 ++- .../MavenITmng8336UnknownPackagingTest.java | 53 +++++++++++++++++++ .../apache/maven/it/TestSuiteOrdering.java | 1 + .../mng-8336-unknown-packaging/pom.xml | 28 ++++++++++ .../danthe1st/mavenrepro/MavenRepro.java | 27 ++++++++++ 5 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8336UnknownPackagingTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-8336-unknown-packaging/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-8336-unknown-packaging/src/main/java/io/github/danthe1st/mavenrepro/MavenRepro.java diff --git a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index c473f43774..428f0aa199 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -936,6 +936,10 @@ public class DefaultProjectBuilder implements ProjectBuilder { } project.setRemoteArtifactRepositories(remoteRepositories); - return lifecycleBindingsInjector.injectLifecycleBindings(model3.getDelegate(), request, problems); + if (projectBuildingRequest.isProcessPlugins()) { + return lifecycleBindingsInjector.injectLifecycleBindings(model3.getDelegate(), request, problems); + } else { + return model3.getDelegate(); + } } } diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8336UnknownPackagingTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8336UnknownPackagingTest.java new file mode 100644 index 0000000000..e66b3ce86f --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8336UnknownPackagingTest.java @@ -0,0 +1,53 @@ +/* + * 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.util.List; + +import org.apache.maven.shared.verifier.Verifier; +import org.apache.maven.shared.verifier.util.ResourceExtractor; +import org.junit.jupiter.api.Test; + +/** + * This is a test set for MNG-8336. + */ +class MavenITmng8336UnknownPackagingTest extends AbstractMavenIntegrationTestCase { + + MavenITmng8336UnknownPackagingTest() { + super("[4.0.0-beta-6,)"); + } + + /** + * Verify that the build succeeds + */ + @Test + void testUnknownPackaging() throws Exception { + File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8336-unknown-packaging"); + + Verifier verifier = newVerifier(testDir.getAbsolutePath(), "remote"); + verifier.addCliArgument("clean"); + verifier.addCliArgument("org.codehaus.mojo:license-maven-plugin:2.4.0:add-third-party"); + verifier.execute(); + + // verify log + List lines = verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false); + assertTrue(lines.stream().noneMatch(s -> s.contains("Unable to obtain POM for artifact"))); + } +} diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java index 4bf5b649eb..e515f130a3 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java @@ -120,6 +120,7 @@ public class TestSuiteOrdering implements ClassOrderer { * the tests are to finishing. Newer tests are also more likely to fail, so this is * a fail fast technique as well. */ + suite.addTestSuite(MavenITmng8336UnknownPackagingTest.class); suite.addTestSuite(MavenITmng8340GeneratedPomInTargetTest.class); suite.addTestSuite(MavenITmng8360SubprojectProfileActivationTest.class); suite.addTestSuite(MavenITmng8347TransitiveDependencyManagerTest.class); diff --git a/its/core-it-suite/src/test/resources/mng-8336-unknown-packaging/pom.xml b/its/core-it-suite/src/test/resources/mng-8336-unknown-packaging/pom.xml new file mode 100644 index 0000000000..f864f104f8 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8336-unknown-packaging/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + io.github.danthe1st + maven-repro + 0.0.1-SNAPSHOT + + 17 + + + + org.apache.pdfbox + pdfbox-io + 3.0.2 + + + + + + maven-compiler-plugin + 3.13.0 + + 17 + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-8336-unknown-packaging/src/main/java/io/github/danthe1st/mavenrepro/MavenRepro.java b/its/core-it-suite/src/test/resources/mng-8336-unknown-packaging/src/main/java/io/github/danthe1st/mavenrepro/MavenRepro.java new file mode 100644 index 0000000000..11368fbbec --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8336-unknown-packaging/src/main/java/io/github/danthe1st/mavenrepro/MavenRepro.java @@ -0,0 +1,27 @@ +/* + * 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 io.github.danthe1st.mavenrepro; + +public class MavenRepro { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } +}