You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2019/07/21 17:13:22 UTC

[maven-dependency-plugin] branch master updated: [MDEP-653] Add log line to show the number of artifacts purged, transitivity and resolution fuzziness.

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c95b8f  [MDEP-653] Add log line to show the number of artifacts purged, transitivity and resolution fuzziness.
3c95b8f is described below

commit 3c95b8f5258302a7016074ab7c9d709b384ed658
Author: Pim Moerenhout <pi...@gmail.com>
AuthorDate: Fri Jul 19 12:40:28 2019 +0300

    [MDEP-653] Add log line to show the number of artifacts purged, transitivity and resolution fuzziness.
---
 .../purge-local-repository-log/invoker.properties  | 18 +++++++++
 src/it/projects/purge-local-repository-log/pom.xml | 47 ++++++++++++++++++++++
 .../purge-local-repository-log/verify.groovy       | 22 ++++++++++
 .../dependency/PurgeLocalRepositoryMojo.java       | 12 +++++-
 4 files changed, 98 insertions(+), 1 deletion(-)

diff --git a/src/it/projects/purge-local-repository-log/invoker.properties b/src/it/projects/purge-local-repository-log/invoker.properties
new file mode 100644
index 0000000..3c1911e
--- /dev/null
+++ b/src/it/projects/purge-local-repository-log/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}:purge-local-repository
diff --git a/src/it/projects/purge-local-repository-log/pom.xml b/src/it/projects/purge-local-repository-log/pom.xml
new file mode 100644
index 0000000..ced92c4
--- /dev/null
+++ b/src/it/projects/purge-local-repository-log/pom.xml
@@ -0,0 +1,47 @@
+<?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>purge-local-repository-log</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>Test</name>
+  <description>
+    Test dependency:purge-local-repository log messages
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.dependency</groupId>
+      <artifactId>purge-local-repository</artifactId>
+      <version>1.0</version>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/src/it/projects/purge-local-repository-log/verify.groovy b/src/it/projects/purge-local-repository-log/verify.groovy
new file mode 100644
index 0000000..0a09942
--- /dev/null
+++ b/src/it/projects/purge-local-repository-log/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" );
+assert buildLog.contains( 'Deleting 2 projects\' transitive dependencies from' );
+assert buildLog.contains( 'with artifact version resolution fuzziness' );
diff --git a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java
index 634ad47..771e60a 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java
@@ -61,6 +61,8 @@ import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverExcepti
 import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
 import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
 import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
+import org.apache.maven.shared.utils.logging.MessageBuilder;
+import org.apache.maven.shared.utils.logging.MessageUtils;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -349,7 +351,7 @@ public class PurgeLocalRepositoryMojo
     /**
      * Determines if all projects in the reactor should be purged from their dependencies. When this goal is started on
      * the command-line, it is always the case. When it is bound to a phase in the lifecycle, it is never the case.
-     * 
+     *
      * @return <code>true</code> if all projects in the reactor should be purged, <code>false</code> otherwise.
      */
     private boolean shouldPurgeAllProjectsInReactor()
@@ -624,6 +626,14 @@ public class PurgeLocalRepositoryMojo
     private void purgeArtifacts( Set<Artifact> artifacts )
         throws MojoFailureException
     {
+        MessageBuilder messageBuilder = MessageUtils.buffer();
+
+        getLog().info( messageBuilder.a( "Deleting " ).strong( artifacts.size() ).a( " projects' " )
+            .strong( actTransitively ? "transitive" : "direct" )
+            .a( " dependencies from " ).strong( localRepository.getBasedir() )
+            .a( " with artifact " ).strong( resolutionFuzziness ).a( " resolution fuzziness " )
+            .newline().toString() );
+
         for ( Artifact artifact : artifacts )
         {
             verbose( "Purging artifact: " + artifact.getId() );