[ 
https://issues.apache.org/jira/browse/MDEP-923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848913#comment-17848913
 ] 

ASF GitHub Bot commented on MDEP-923:
-------------------------------------

elharo commented on code in PR #389:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/389#discussion_r1611510587


##########
src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.plugins.dependency.utils;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.FileUtils;
+import org.sonatype.plexus.build.incremental.BuildContext;
+
+/**
+ * Provide a copyFile method in one place.
+ */
+@Named
+@Singleton
+public class CopyUtil {
+
+    private final BuildContext buildContext;
+
+    @Inject
+    public CopyUtil(BuildContext buildContext) {
+        this.buildContext = buildContext;
+    }
+
+    /**
+     * Does the actual copy of the file and logging.
+     *
+     * @param source represents the file to copy.
+     * @param destination file name of destination file.
+     * @throws IOException with a message if an error occurs.
+     */
+    public void copyFile(Log log, File source, File destination) throws 
IOException, MojoExecutionException {
+        log.info("Copying " + source + " to " + destination);

Review Comment:
   Log message is likely noise. Either thew copy succeeds and no one wants to 
read this, ior it fails and an exception is thrown. Demote to debug or remove 
it.



##########
src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java:
##########
@@ -80,7 +80,7 @@ public void assertNoMarkerFile(Artifact artifact) throws 
MojoExecutionException
         assertFalse(handle.isMarkerSet());
     }
 
-    public void testCopyFile() throws MojoExecutionException, IOException {
+    public void testCopyFile() throws Exception {

Review Comment:
   did this change to throw a raw exception? Otherwise it's better to declare 
the actual exceptions instead of the common superclass. 



##########
src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.plugins.dependency.utils;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.FileUtils;
+import org.sonatype.plexus.build.incremental.BuildContext;
+
+/**
+ * Provide a copyFile method in one place.
+ */
+@Named
+@Singleton
+public class CopyUtil {
+
+    private final BuildContext buildContext;
+
+    @Inject
+    public CopyUtil(BuildContext buildContext) {
+        this.buildContext = buildContext;
+    }
+
+    /**
+     * Does the actual copy of the file and logging.
+     *
+     * @param source represents the file to copy.
+     * @param destination file name of destination file.
+     * @throws IOException with a message if an error occurs.
+     */
+    public void copyFile(Log log, File source, File destination) throws 
IOException, MojoExecutionException {
+        log.info("Copying " + source + " to " + destination);
+
+        if (source.isDirectory()) {
+            // usual case is a future jar packaging, but there are special 
cases: classifier and other packaging
+            throw new MojoExecutionException("Artifact has not been packaged 
yet. When used on reactor artifact, "
+                    + "copy should be executed after packaging: see 
MDEP-187.");

Review Comment:
   I wonder if we need a URL here? Non-Maven team members might not recognize 
the issue tracker ID





> Code cleanups
> -------------
>
>                 Key: MDEP-923
>                 URL: https://issues.apache.org/jira/browse/MDEP-923
>             Project: Maven Dependency Plugin
>          Issue Type: Task
>            Reporter: Slawomir Jaranowski
>            Assignee: Slawomir Jaranowski
>            Priority: Major
>             Fix For: 3.7.0
>
>
> * remove usage of deprecated API where possible
>  * cleanup pom after update to 42
>  * exclude transitive dependencies on org.apache.maven
>  * add {{@project.version@}} in ITs
>  * Remove plexus logger from DependencySilentLog
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to