Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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 = clean ${project.groupId}:${project.artifactId}:${project.version}:analyze
61 changes: 61 additions & 0 deletions src/it/projects/mdep-1645-verbose-no-duplicate-ignored/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?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>mdep-1645</artifactId>
<version>1.0-SNAPSHOT</version>

<name>Test</name>
<description>
Test dependency:analyze -Dverbose does not duplicate entries in ignored section
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.10.0</version>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 test;
import org.apache.commons.lang3.StringUtils;
public class App {
public void test() {
System.out.println(StringUtils.capitalize("hello"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.
*/

File buildLog = new File( basedir, "build.log" )
assert buildLog.exists()

String log = buildLog.getText( "UTF-8" )

// warning sections should be present
assert log.contains( '[WARNING] Used undeclared dependencies found:' )
assert log.contains( '[WARNING] org.apache.commons:commons-lang3:jar:3.12.0:compile' )
assert log.contains( '[WARNING] class org.apache.commons.lang3.StringUtils' )
assert log.contains( '[WARNING] Unused declared dependencies found:' )
assert log.contains( '[WARNING] org.apache.commons:commons-text:jar:1.10.0:compile' )
Comment thread
Copilot marked this conversation as resolved.

// when no ignoredDependencies are configured, the ignored sections should not appear
assert !log.contains( 'Ignored used undeclared dependencies' )
assert !log.contains( 'Ignored unused declared dependencies' )

return true
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.File;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -558,9 +559,18 @@ private void writeScriptableOutput(Set<Artifact> artifacts) {
}
}

/**
* Removes artifacts matching any of the given exclude patterns from the source set
* and returns the removed artifacts. When {@code excludes} is null or empty, no
* artifacts are removed and an empty set is returned.
*
* @param artifacts the source set of artifacts (mutated in place)
* @param excludes exclude patterns, may be null or empty
* @return the artifacts that were removed from the source set
*/
private Set<Artifact> filterDependencies(Set<Artifact> artifacts, String[] excludes) {
if (excludes == null || excludes.length == 0) {
return artifacts;
return Collections.emptySet();
}
ArtifactFilter filter = new StrictPatternExcludesArtifactFilter(Arrays.asList(excludes));
Set<Artifact> result = new LinkedHashSet<>();
Expand Down
Loading