You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Mark Raynsford (JIRA)" <ji...@apache.org> on 2017/11/15 13:28:00 UTC

[jira] [Commented] (MDEP-584) Upgrade plexus-utils to version 3.1.0

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

Mark Raynsford commented on MDEP-584:
-------------------------------------

I've had look at this, and it seems to me like the new version of plexus-utils copies the last modified time of files, whereas the old version evidently didn't. Those tests above seem to depend upon the old behaviour.

Here's a patch to demonstrate what I mean:

{code:java}
diff --git a/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java
index 7cc11e286..fdb7280bf 100644
--- a/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java
+++ b/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java
@@ -666,12 +666,20 @@ public class TestCopyMojo
         assertEquals( time, copiedFile.lastModified() );
     }
 
+    /**
+     * Test that the given release artifact is copied, and the copy is overwritten if the Mojo is executed again.
+     *
+     * @throws Exception On errors
+     */
+
     public void testCopyOverWriteReleases()
         throws Exception
     {
         stubFactory.setCreateFiles( true );
         Artifact release = stubFactory.getReleaseArtifact();
-        assertTrue( release.getFile().setLastModified( System.currentTimeMillis() - 2000 ) );
+
+        assertTrue( release.getFile().setLastModified( 1000L ) );
+        assertEquals( 1000L, release.getFile().lastModified() );
 
         ArtifactItem item = new ArtifactItem( release );
 
@@ -685,13 +693,13 @@ public class TestCopyMojo
 
         File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
 
-        // round up to the next second
-        long time = System.currentTimeMillis() - 2000;
-        assertTrue( copiedFile.setLastModified( time ) );
+        assertTrue( copiedFile.setLastModified( 2000L ) );
+        assertEquals( 2000L, copiedFile.lastModified() );
 
         mojo.execute();
 
-        assertTrue( time < copiedFile.lastModified() );
+        long timeCopyNow = copiedFile.lastModified();
+        assertTrue( "Artifact time " + 2000L + " must be < " + timeCopyNow, 2000L < timeCopyNow );
     }
 
     public void testCopyOverWriteSnapshot()
{code}

Try the above patch with 3.0.24 and 3.1.0. You can see that the final value of copiedFile.lastModified() is 1000L when using 3.1.0, but is roughly equal to the current time on 3.0.24.


> Upgrade plexus-utils to version 3.1.0
> -------------------------------------
>
>                 Key: MDEP-584
>                 URL: https://issues.apache.org/jira/browse/MDEP-584
>             Project: Maven Dependency Plugin
>          Issue Type: Dependency upgrade
>    Affects Versions: 3.0.2
>            Reporter: Karl Heinz Marbaise
>            Assignee: Karl Heinz Marbaise
>            Priority: Minor
>             Fix For: 3.1.0
>
>
> Currently an upgrade will fail the following unit tests in maven-dependency plugin:
> {code}
> Results :
> Failed tests:
>   TestCopyMojo.testCopyOverWriteReleases:694
>   TestCopyMojo.testCopyOverWriteSnapshot:723
>   TestCopyDependenciesMojo.testOverWriteRelease:592 time = 1504955654000 should be < to 1504955652000
>   TestCopyDependenciesMojo.testOverWriteSnap:661
> Tests run: 244, Failures: 4, Errors: 0, Skipped: 0
> {code}
> I need to investigate those tests...



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)