This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push: new bbf57bca60 [MNG-8383] Fix unsupported type dependencies put on classpath (#1921) bbf57bca60 is described below commit bbf57bca605d8639c409b453b091164b285acaee Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Tue Nov 19 00:56:12 2024 +0100 [MNG-8383] Fix unsupported type dependencies put on classpath (#1921) --- .../maven/internal/impl/DefaultTypeRegistry.java | 5 +- .../MavenITmng8383UnknownTypeDependenciesTest.java | 47 ++++++ .../org/apache/maven/it/TestSuiteOrdering.java | 1 + .../.mvn/extensions.xml | 7 + .../mng-8383-unknown-type-dependencies/pom.xml | 165 +++++++++++++++++++++ .../src/main/proto/health/v1/health.proto | 22 +++ 6 files changed, 245 insertions(+), 2 deletions(-) diff --git a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java index 37e478ada3..af8344599c 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java +++ b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java @@ -95,8 +95,9 @@ public class DefaultTypeRegistry extends AbstractEventSpy implements TypeRegistr handler.getExtension(), handler.getClassifier(), handler.isIncludesDependencies(), - JavaPathType.CLASSES, - JavaPathType.MODULES); + handler.isAddedToClasspath() + ? new JavaPathType[] {JavaPathType.CLASSES, JavaPathType.MODULES} + : new JavaPathType[] {}); } return type; }); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8383UnknownTypeDependenciesTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8383UnknownTypeDependenciesTest.java new file mode 100644 index 0000000000..4f8c2ca370 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8383UnknownTypeDependenciesTest.java @@ -0,0 +1,47 @@ +/* + * 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 org.apache.maven.shared.verifier.util.ResourceExtractor; +import org.junit.jupiter.api.Test; + +/** + * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8383">MNG-8383</a>. + */ +class MavenITmng8383UnknownTypeDependenciesTest extends AbstractMavenIntegrationTestCase { + + MavenITmng8383UnknownTypeDependenciesTest() { + super("[4.0.0-beta-6,)"); + } + + /** + * Verify that dependencies of unknown types are not added to classpath + */ + @Test + void testUnknownTypeDependencies() throws Exception { + File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8383-unknown-type-dependencies"); + + Verifier verifier = newVerifier(testDir.getAbsolutePath()); + verifier.addCliArgument("generate-resources"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + } +} 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 afc6b4edcc..191f016a66 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 @@ -100,6 +100,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(MavenITmng8383UnknownTypeDependenciesTest.class); suite.addTestSuite(MavenITmng8379SettingsDecryptTest.class); suite.addTestSuite(MavenITmng8336UnknownPackagingTest.class); suite.addTestSuite(MavenITmng8340GeneratedPomInTargetTest.class); diff --git a/its/core-it-suite/src/test/resources/mng-8383-unknown-type-dependencies/.mvn/extensions.xml b/its/core-it-suite/src/test/resources/mng-8383-unknown-type-dependencies/.mvn/extensions.xml new file mode 100644 index 0000000000..fe1bf76c0d --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8383-unknown-type-dependencies/.mvn/extensions.xml @@ -0,0 +1,7 @@ +<extensions> + <extension> + <groupId>com.tisonkun.os</groupId> + <artifactId>os-detector-maven-plugin</artifactId> + <version>0.6.0</version> + </extension> +</extensions> diff --git a/its/core-it-suite/src/test/resources/mng-8383-unknown-type-dependencies/pom.xml b/its/core-it-suite/src/test/resources/mng-8383-unknown-type-dependencies/pom.xml new file mode 100644 index 0000000000..568ce855c7 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8383-unknown-type-dependencies/pom.xml @@ -0,0 +1,165 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.1.0" root="true"> + + <groupId>org.apache.maven.its.mng8383</groupId> + <artifactId>root</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <properties> + <protoc.version>3.25.5</protoc.version> + <grpc.version>1.65.1</grpc.version> + </properties> + + <dependencies> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protoc</artifactId> + <version>${protoc.version}</version> + <classifier>linux-aarch_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protoc</artifactId> + <version>${protoc.version}</version> + <classifier>linux-ppcle_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protoc</artifactId> + <version>${protoc.version}</version> + <classifier>linux-s390_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protoc</artifactId> + <version>${protoc.version}</version> + <classifier>linux-x86_32</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protoc</artifactId> + <version>${protoc.version}</version> + <classifier>linux-x86_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protoc</artifactId> + <version>${protoc.version}</version> + <classifier>osx-aarch_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protoc</artifactId> + <version>${protoc.version}</version> + <classifier>osx-x86_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protoc</artifactId> + <version>${protoc.version}</version> + <classifier>windows-x86_32</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protoc</artifactId> + <version>${protoc.version}</version> + <classifier>windows-x86_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>protoc-gen-grpc-java</artifactId> + <version>${grpc.version}</version> + <classifier>linux-aarch_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>protoc-gen-grpc-java</artifactId> + <version>${grpc.version}</version> + <classifier>linux-ppcle_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>protoc-gen-grpc-java</artifactId> + <version>${grpc.version}</version> + <classifier>linux-s390_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>protoc-gen-grpc-java</artifactId> + <version>${grpc.version}</version> + <classifier>linux-x86_32</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>protoc-gen-grpc-java</artifactId> + <version>${grpc.version}</version> + <classifier>linux-x86_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>protoc-gen-grpc-java</artifactId> + <version>${grpc.version}</version> + <classifier>osx-aarch_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>protoc-gen-grpc-java</artifactId> + <version>${grpc.version}</version> + <classifier>osx-x86_64</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>protoc-gen-grpc-java</artifactId> + <version>${grpc.version}</version> + <classifier>windows-x86_32</classifier> + <type>exe</type> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>protoc-gen-grpc-java</artifactId> + <version>${grpc.version}</version> + <classifier>windows-x86_64</classifier> + <type>exe</type> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.xolstice.maven.plugins</groupId> + <artifactId>protobuf-maven-plugin</artifactId> + <version>0.6.1</version> + <configuration> + <protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact> + <pluginId>grpc-java</pluginId> + <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact> + </configuration> + <executions> + <execution> + <id>compile</id> + <goals> + <goal>compile</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/its/core-it-suite/src/test/resources/mng-8383-unknown-type-dependencies/src/main/proto/health/v1/health.proto b/its/core-it-suite/src/test/resources/mng-8383-unknown-type-dependencies/src/main/proto/health/v1/health.proto new file mode 100644 index 0000000000..4945694ea4 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8383-unknown-type-dependencies/src/main/proto/health/v1/health.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package grpc.health.v1; + +message HealthCheckRequest { + string service = 1; +} + +message HealthCheckResponse { + enum ServingStatus { + UNKNOWN = 0; + SERVING = 1; + NOT_SERVING = 2; + } + ServingStatus status = 1; +} + +service Health { + rpc Check(HealthCheckRequest) returns (HealthCheckResponse); + + rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse); +} \ No newline at end of file