File tree Expand file tree Collapse file tree 5 files changed +32
-2
lines changed
main/java/org/codehaus/plexus/archiver/dir
java/org/codehaus/plexus/archiver
resources/symlinks/src/aDirWithALink Expand file tree Collapse file tree 5 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 10
10
</parent >
11
11
12
12
<artifactId >plexus-archiver</artifactId >
13
- <version >2.10-beta-2- SNAPSHOT</version >
13
+ <version >2.10-SNAPSHOT</version >
14
14
15
15
<name >Plexus Archiver Component</name >
16
16
Original file line number Diff line number Diff line change 22
22
import org .codehaus .plexus .archiver .ResourceIterator ;
23
23
import org .codehaus .plexus .archiver .util .ArchiveEntryUtils ;
24
24
import org .codehaus .plexus .archiver .util .ResourceUtils ;
25
+ import org .codehaus .plexus .components .io .attributes .SymlinkUtils ;
26
+ import org .codehaus .plexus .components .io .functions .SymlinkDestinationSupplier ;
25
27
import org .codehaus .plexus .components .io .resources .PlexusIoResource ;
26
28
27
29
import java .io .File ;
@@ -79,7 +81,14 @@ public void execute()
79
81
String fileName = f .getName ();
80
82
final String destDir = destDirectory .getCanonicalPath ();
81
83
fileName = destDir + File .separator + fileName ;
82
- copyFile ( f , fileName );
84
+ PlexusIoResource resource = f .getResource ();
85
+ if (resource instanceof SymlinkDestinationSupplier ){
86
+ String dest = ((SymlinkDestinationSupplier )resource ).getSymlinkDestination ();
87
+ File target = new File (dest );
88
+ SymlinkUtils .createSymbolicLink (new File (fileName ), target );
89
+ } else {
90
+ copyFile (f , fileName );
91
+ }
83
92
}
84
93
}
85
94
catch ( final IOException ioe )
Original file line number Diff line number Diff line change 1
1
package org .codehaus .plexus .archiver ;
2
2
3
3
import org .codehaus .plexus .PlexusTestCase ;
4
+ import org .codehaus .plexus .archiver .dir .DirectoryArchiver ;
4
5
import org .codehaus .plexus .archiver .tar .TarArchiver ;
5
6
import org .codehaus .plexus .archiver .tar .TarLongFileMode ;
6
7
import org .codehaus .plexus .archiver .tar .TarUnArchiver ;
7
8
import org .codehaus .plexus .archiver .zip .ZipArchiver ;
8
9
import org .codehaus .plexus .archiver .zip .ZipUnArchiver ;
10
+ import org .codehaus .plexus .components .io .attributes .SymlinkUtils ;
9
11
import org .codehaus .plexus .util .Os ;
10
12
11
13
import java .io .File ;
@@ -84,4 +86,21 @@ public void testSymlinkZip()
84
86
unarchiver .setDestFile ( output );
85
87
unarchiver .extract ();
86
88
}
89
+
90
+ public void testSymlinkDirArchiver ()
91
+ throws Exception
92
+ {
93
+ DirectoryArchiver archiver = (DirectoryArchiver ) lookup ( Archiver .ROLE , "dir" );
94
+
95
+ File dummyContent = getTestFile ( "src/test/resources/symlinks/src" );
96
+ archiver .addDirectory ( dummyContent );
97
+ final File archiveFile = new File ( "target/output/dirarchiver-symlink" );
98
+ archiveFile .mkdirs ();
99
+ archiver .setDestFile ( archiveFile );
100
+ archiver .createArchive ();
101
+
102
+ assertTrue ( Files .isSymbolicLink (new File ("target/output/dirarchiver-symlink/symR" ).toPath ()));
103
+ assertTrue (Files .isSymbolicLink (new File ("target/output/dirarchiver-symlink/aDirWithALink/backOutsideToFileX" ).toPath ()));
104
+ }
105
+
87
106
}
Original file line number Diff line number Diff line change 12
12
import java .io .*;
13
13
14
14
@ SuppressWarnings ("ResultOfMethodCallIgnored" )
15
+ @ Ignore
15
16
public class ConcurrentJarCreatorTest {
16
17
@ Test
17
18
public void concurrent ()
Original file line number Diff line number Diff line change
1
+ ../fileX.txt
You can’t perform that action at this time.
0 commit comments