This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
commit 06b23d0008893d7d95c2643459764cdc4929835c Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Sat Nov 14 00:31:07 2026 +0100 Document pattern scope and test flat-list excludes for dependency:list --- src/it/mrm/repository/list-excludes-holder-1.0.pom | 39 ++++++++++++++++++++ .../list-excludes-transitive/invoker.properties | 19 ++++++++++ src/it/projects/list-excludes-transitive/pom.xml | 42 ++++++++++++++++++++++ .../list-excludes-transitive/transitive.properties | 19 ++++++++++ .../list-excludes-transitive/verify.groovy | 26 ++++++++++++++ .../resolvers/ResolveDependenciesMojo.java | 2 ++ src/site/markdown/usage.md.vm | 7 ++-- 7 files changed, 152 insertions(+), 2 deletions(-) diff --git a/src/it/mrm/repository/list-excludes-holder-1.0.pom b/src/it/mrm/repository/list-excludes-holder-1.0.pom new file mode 100644 index 00000000..c48f9862 --- /dev/null +++ b/src/it/mrm/repository/list-excludes-holder-1.0.pom @@ -0,0 +1,39 @@ +<?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>org.apache.maven.its.dependency</groupId> + <artifactId>list-excludes-holder</artifactId> + <version>1.0</version> + <packaging>pom</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>ResourceArtifact</artifactId> + <version>1.0</version> + </dependency> + </dependencies> +</project> diff --git a/src/it/projects/list-excludes-transitive/invoker.properties b/src/it/projects/list-excludes-transitive/invoker.properties new file mode 100644 index 00000000..e288dd64 --- /dev/null +++ b/src/it/projects/list-excludes-transitive/invoker.properties @@ -0,0 +1,19 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:list +invoker.userPropertiesFile = transitive.properties diff --git a/src/it/projects/list-excludes-transitive/pom.xml b/src/it/projects/list-excludes-transitive/pom.xml new file mode 100644 index 00000000..52cf127a --- /dev/null +++ b/src/it/projects/list-excludes-transitive/pom.xml @@ -0,0 +1,42 @@ +<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.dependency.its</groupId> + <artifactId>list-excludes-transitive</artifactId> + <version>1.0-SNAPSHOT</version> + + <description> + dependency:list with an excludes pattern: the excluded artifact is dropped, its transitive dependencies are not. + </description> + + <dependencies> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>list-excludes-holder</artifactId> + <version>1.0</version> + <type>pom</type> + </dependency> + </dependencies> +</project> diff --git a/src/it/projects/list-excludes-transitive/transitive.properties b/src/it/projects/list-excludes-transitive/transitive.properties new file mode 100644 index 00000000..bb79f1e4 --- /dev/null +++ b/src/it/projects/list-excludes-transitive/transitive.properties @@ -0,0 +1,19 @@ +# 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. +outputFile = target/transitive.txt +includeModuleInfo = false +excludes = :list-excludes-holder diff --git a/src/it/projects/list-excludes-transitive/verify.groovy b/src/it/projects/list-excludes-transitive/verify.groovy new file mode 100644 index 00000000..275fc01d --- /dev/null +++ b/src/it/projects/list-excludes-transitive/verify.groovy @@ -0,0 +1,26 @@ +/* + * 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 static org.assertj.core.api.Assertions.assertThat + +def lines = new File(basedir, "target/transitive.txt").readLines().collect { it.trim() } +assertThat(lines).noneMatch { it.contains("list-excludes-holder") } +assertThat(lines).contains("org.apache.maven.its.dependency:ResourceArtifact:jar:1.0:compile") + +return true diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index d09bdc98..42574fea 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -139,6 +139,8 @@ public class ResolveDependenciesMojo extends AbstractResolveMojo { * <code>includeGroupIds</code>, and the {@link #excludes} patterns take precedence. Unlike in * <code>dependency:tree</code>, which keeps the path to an included artifact, only the matching artifacts * are listed, and an excluded artifact does not remove its dependencies. + * Parent POMs added by <code>includeParents</code> are filtered too. For <code>resolve-sources</code>, the + * patterns match the declared dependencies, not the <code>sources</code> artifacts that are resolved for them. * <p> * The property <code>includes</code> is shared with <code>dependency:tree</code>, so one * <code>-Dincludes</code> value applies to both goals in the same command line. diff --git a/src/site/markdown/usage.md.vm b/src/site/markdown/usage.md.vm index ba98cbd9..df994e25 100644 --- a/src/site/markdown/usage.md.vm +++ b/src/site/markdown/usage.md.vm @@ -368,13 +368,16 @@ The `outputType` parameter (since 3.12.0) of `dependency:resolve`, `dependency:l mvn dependency:list -DoutputType=pom -DoutputFile=dependencies.xml ``` -The `includes` and `excludes` parameters (since 3.12.0) of `dependency:resolve` and `dependency:list` take the same comma-separated `[groupId]:[artifactId]:[type]:[version]` patterns as the parameters of `dependency:tree`, with `*` wildcards. They apply in addition to the other `include*` and `exclude*` parameters, and an exclusion wins over an inclusion. The goals list only the matching artifacts; unlike `dependency:tree`, they do not keep the path to an included artifact. +The `includes` and `excludes` parameters (since 3.12.0) of `dependency:resolve`, `dependency:list`, `dependency:collect` and `dependency:resolve-sources` take the same comma-separated `[groupId]:[artifactId]:[type]:[version]` patterns as the parameters of `dependency:tree`, with `*` wildcards. They apply in addition to the other `include*` and `exclude*` parameters, and an exclusion wins over an inclusion. The goals list only the matching artifacts, including parent POMs added by `includ [...] ``` -mvn dependency:list -Dincludes=org.springframework.* +mvn dependency:list -Dincludes=org.springframework +mvn dependency:list -Dincludes=org.springframework* mvn dependency:list -Dincludes=:::*-SNAPSHOT -Dexcludes=org.acme ``` +`org.springframework` matches that group id only; `org.springframework*` also matches groups such as `org.springframework.boot`. + `dependency:resolve-sources` ----------------------------
