From ff416e35183af13362780d57a1a18d54e4203171 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 19 Sep 2022 08:47:52 +0200 Subject: [PATCH] Fix link destination, fixes #89 --- .../components/io/resources/PlexusIoSymlinkResource.java | 2 +- .../io/resources/PlexusIoPlexusIoFileResourceTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoSymlinkResource.java b/src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoSymlinkResource.java index 9cdf4eda..135ee248 100644 --- a/src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoSymlinkResource.java +++ b/src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoSymlinkResource.java @@ -50,7 +50,7 @@ private PlexusIoSymlinkResource( @Nonnull File symlinkfile, String name, @Nonnul public String getSymlinkDestination() throws IOException { - return targetResource.getName(); + return symLinkDestination; } public PlexusIoResource getTarget() diff --git a/src/test/java/org/codehaus/plexus/components/io/resources/PlexusIoPlexusIoFileResourceTest.java b/src/test/java/org/codehaus/plexus/components/io/resources/PlexusIoPlexusIoFileResourceTest.java index 96e9141e..4b3ba449 100644 --- a/src/test/java/org/codehaus/plexus/components/io/resources/PlexusIoPlexusIoFileResourceTest.java +++ b/src/test/java/org/codehaus/plexus/components/io/resources/PlexusIoPlexusIoFileResourceTest.java @@ -7,6 +7,7 @@ import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; import org.codehaus.plexus.components.io.attributes.SymlinkUtils; +import org.codehaus.plexus.components.io.functions.SymlinkDestinationSupplier; import org.codehaus.plexus.util.Os; import org.junit.Test; @@ -31,6 +32,8 @@ public void testRealSymlink() assertTrue( r.isDirectory() ); final File target = SymlinkUtils.readSymbolicLink( file ); assertTrue( target.getName().endsWith( "targetDir" ) ); + assertTrue( r instanceof SymlinkDestinationSupplier ); + assertEquals( "targetDir/", ( ( SymlinkDestinationSupplier ) r ).getSymlinkDestination() ); } @Test