You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/09/29 14:24:54 UTC
[maven-dependency-plugin] 03/04: [MDEP-752] Add ignoredPackagings
options for analyze
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 e438ab483dde08db4ee7002cd2a3c35a93e6d7ae
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Sun Sep 12 17:09:17 2021 +0200
[MDEP-752] Add ignoredPackagings options for analyze
By default pom and ear packaging are ignored from analyzing
Closes #165
---
.../ear/pom.xml | 42 +++++++++++++++
.../ejb/pom.xml | 35 ++++++++++++
.../ejb/src/main/java/Main.java | 23 ++++++++
.../invoker.properties | 18 +++++++
.../pom.xml | 62 ++++++++++++++++++++++
.../verify.groovy | 29 ++++++++++
.../ear/pom.xml | 42 +++++++++++++++
.../ejb/pom.xml | 35 ++++++++++++
.../ejb/src/main/java/Main.java | 23 ++++++++
.../invoker.properties | 18 +++++++
.../pom.xml | 44 +++++++++++++++
.../verify.groovy | 28 ++++++++++
.../dependency/analyze/AbstractAnalyzeMojo.java | 13 +++--
13 files changed, 409 insertions(+), 3 deletions(-)
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/ear/pom.xml b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/ear/pom.xml
new file mode 100644
index 0000000..ea80642
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/ear/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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.its.dependency</groupId>
+ <artifactId>mdep-752-analyze-ignored-packaging-defaults</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>mdep-752-ear</artifactId>
+ <packaging>ear</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.dependency</groupId>
+ <artifactId>mdep-752-ejb</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/ejb/pom.xml b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/ejb/pom.xml
new file mode 100644
index 0000000..546cbba
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/ejb/pom.xml
@@ -0,0 +1,35 @@
+<?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>
+
+ <parent>
+ <groupId>org.apache.maven.its.dependency</groupId>
+ <artifactId>mdep-752-analyze-ignored-packaging-defaults</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>mdep-752-ejb</artifactId>
+ <packaging>ejb</packaging>
+
+</project>
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/ejb/src/main/java/Main.java b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/ejb/src/main/java/Main.java
new file mode 100644
index 0000000..5e405ff
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/ejb/src/main/java/Main.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+
+public class Main
+{
+}
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/invoker.properties b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/invoker.properties
new file mode 100644
index 0000000..0eca1be
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/invoker.properties
@@ -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 = ${project.groupId}:${project.artifactId}:${project.version}:analyze
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/pom.xml b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/pom.xml
new file mode 100644
index 0000000..6ef4da9
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/pom.xml
@@ -0,0 +1,62 @@
+<?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-752-analyze-ignored-packaging-defaults</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <description>
+ Test dependency:analyze with default ignored packaging
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <modules>
+ <module>ear</module>
+ <module>ejb</module>
+ </modules>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <failOnWarning>true</failOnWarning>
+ <ignoredPackagings>
+ <ignoredPackaging>pom</ignoredPackaging>
+ <ignoredPackaging>ear</ignoredPackaging>
+ <ignoredPackaging>ejb</ignoredPackaging>
+ </ignoredPackagings>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/verify.groovy b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/verify.groovy
new file mode 100644
index 0000000..fc6fb25
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/verify.groovy
@@ -0,0 +1,29 @@
+/*
+ * 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 file = new File( basedir, "build.log" );
+assert file.exists();
+
+String buildLog = file.getText( "UTF-8" );
+assert buildLog.contains( 'ignoredPackagings = [pom, ear, ejb]' );
+assert buildLog.contains( '[INFO] Skipping pom project' );
+assert buildLog.contains( '[INFO] Skipping ear project' );
+assert buildLog.contains( '[INFO] Skipping ejb project' );
+
+return true;
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/ear/pom.xml b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/ear/pom.xml
new file mode 100644
index 0000000..ea80642
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/ear/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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.its.dependency</groupId>
+ <artifactId>mdep-752-analyze-ignored-packaging-defaults</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>mdep-752-ear</artifactId>
+ <packaging>ear</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.dependency</groupId>
+ <artifactId>mdep-752-ejb</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/ejb/pom.xml b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/ejb/pom.xml
new file mode 100644
index 0000000..546cbba
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/ejb/pom.xml
@@ -0,0 +1,35 @@
+<?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>
+
+ <parent>
+ <groupId>org.apache.maven.its.dependency</groupId>
+ <artifactId>mdep-752-analyze-ignored-packaging-defaults</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>mdep-752-ejb</artifactId>
+ <packaging>ejb</packaging>
+
+</project>
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/ejb/src/main/java/Main.java b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/ejb/src/main/java/Main.java
new file mode 100644
index 0000000..5e405ff
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/ejb/src/main/java/Main.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+
+public class Main
+{
+}
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/invoker.properties b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/invoker.properties
new file mode 100644
index 0000000..0eca1be
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/invoker.properties
@@ -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 = ${project.groupId}:${project.artifactId}:${project.version}:analyze
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/pom.xml b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/pom.xml
new file mode 100644
index 0000000..c11b388
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/pom.xml
@@ -0,0 +1,44 @@
+<?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-752-analyze-ignored-packaging-defaults</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <description>
+ Test dependency:analyze with default ignored packaging
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <modules>
+ <module>ear</module>
+ <module>ejb</module>
+ </modules>
+
+</project>
diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/verify.groovy b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/verify.groovy
new file mode 100644
index 0000000..8c8ba1e
--- /dev/null
+++ b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/verify.groovy
@@ -0,0 +1,28 @@
+/*
+ * 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 file = new File( basedir, "build.log" );
+assert file.exists();
+
+String buildLog = file.getText( "UTF-8" );
+assert buildLog.contains( 'ignoredPackagings = [pom, ear]' );
+assert buildLog.contains( '[INFO] Skipping pom project' );
+assert buildLog.contains( '[INFO] Skipping ear project' );
+
+return true;
diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
index d2bb601..d5e36ac 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
@@ -222,6 +222,14 @@ public abstract class AbstractAnalyzeMojo
@Parameter
private String[] ignoredUnusedDeclaredDependencies = new String[0];
+ /**
+ * List of project packaging that will be ignored.
+ *
+ * @since 3.2.1
+ */
+ @Parameter( defaultValue = "pom,ear" )
+ private List<String> ignoredPackagings = new ArrayList<>();
+
// Mojo methods -----------------------------------------------------------
/*
@@ -237,9 +245,9 @@ public abstract class AbstractAnalyzeMojo
return;
}
- if ( "pom".equals( project.getPackaging() ) )
+ if ( ignoredPackagings.contains( project.getPackaging() ) )
{
- getLog().info( "Skipping pom project" );
+ getLog().info( "Skipping " + project.getPackaging() + " project" );
return;
}
@@ -521,7 +529,6 @@ public abstract class AbstractAnalyzeMojo
}
private List<Artifact> filterDependencies( Set<Artifact> artifacts, String[] excludes )
- throws MojoExecutionException
{
ArtifactFilter filter = new StrictPatternExcludesArtifactFilter( Arrays.asList( excludes ) );
List<Artifact> result = new ArrayList<>();