2929import org .codehaus .plexus .components .io .attributes .PlexusIoResourceAttributes ;
3030import org .codehaus .plexus .components .io .resources .PlexusIoFileResource ;
3131import org .codehaus .plexus .components .io .resources .PlexusIoResource ;
32+ import org .codehaus .plexus .components .io .resources .PlexusIoResourceCollection ;
3233import org .codehaus .plexus .components .io .resources .PlexusIoResourceWithAttributes ;
3334
3435/**
@@ -43,6 +44,9 @@ public class ArchiveEntry
4344 public static final int DIRECTORY = 2 ;
4445
4546 public static final int SYMLINK = 3 ;
47+
48+ private PlexusIoResourceCollection collection ;
49+
4650 @ Nonnull private PlexusIoResource resource ;
4751
4852 private final String name ;
@@ -59,11 +63,14 @@ public class ArchiveEntry
5963 * @param resource original filename
6064 * @param type FILE or DIRECTORY
6165 * @param mode octal unix style permissions
66+ * @param collection
6267 */
63- private ArchiveEntry ( String name , @ Nonnull PlexusIoResource resource , int type , int mode )
68+ private ArchiveEntry ( String name , @ Nonnull PlexusIoResource resource , int type , int mode ,
69+ PlexusIoResourceCollection collection )
6470 {
6571 this .name = name ;
6672 this .resource = resource ;
73+ this .collection = collection ;
6774 this .attributes = ( resource instanceof PlexusIoResourceWithAttributes )
6875 ? ( (PlexusIoResourceWithAttributes ) resource ).getAttributes () : null ;
6976 this .type = type ;
@@ -108,7 +115,7 @@ public File getFile()
108115 public InputStream getInputStream ()
109116 throws IOException
110117 {
111- return resource .getContents ();
118+ return collection != null ? collection . getInputStream ( resource ) : resource .getContents ();
112119 }
113120
114121 /**
@@ -139,15 +146,16 @@ public int getMode()
139146 ( type == FILE ? UnixStat .FILE_FLAG : type == SYMLINK ? UnixStat .LINK_FLAG : UnixStat .DIR_FLAG );
140147 }
141148
142- public static ArchiveEntry createFileEntry ( String target , PlexusIoResource resource , int permissions )
149+ public static ArchiveEntry createFileEntry ( String target , PlexusIoResource resource , int permissions ,
150+ PlexusIoResourceCollection collection )
143151 throws ArchiverException
144152 {
145153 if ( resource .isDirectory () )
146154 {
147155 throw new ArchiverException ( "Not a file: " + resource .getName () );
148156 }
149157 final int type = resource .isSymbolicLink () ? SYMLINK : FILE ;
150- return new ArchiveEntry ( target , resource , type , permissions );
158+ return new ArchiveEntry ( target , resource , type , permissions , collection );
151159 }
152160
153161 public static ArchiveEntry createFileEntry ( String target , File file , int permissions )
@@ -169,7 +177,7 @@ public static ArchiveEntry createFileEntry( String target, File file, int permis
169177 }
170178
171179 final PlexusIoFileResource res = PlexusIoFileResource .justAFile ( file , attrs );
172- return new ArchiveEntry ( target , res , FILE , permissions );
180+ return new ArchiveEntry ( target , res , FILE , permissions , null );
173181 }
174182
175183 public static ArchiveEntry createDirectoryEntry ( String target , @ Nonnull PlexusIoResource resource , int permissions )
@@ -180,7 +188,7 @@ public static ArchiveEntry createDirectoryEntry( String target, @Nonnull PlexusI
180188 throw new ArchiverException ( "Not a directory: " + resource .getName () );
181189 }
182190 final int type = resource .isSymbolicLink () ? SYMLINK : DIRECTORY ;
183- return new ArchiveEntry ( target , resource , type , permissions );
191+ return new ArchiveEntry ( target , resource , type , permissions , null );
184192 }
185193
186194 public static ArchiveEntry createDirectoryEntry ( String target , final File file , int permissions )
@@ -192,7 +200,7 @@ public static ArchiveEntry createDirectoryEntry( String target, final File file,
192200 }
193201
194202 final PlexusIoFileResource res = new PlexusIoFileResource ( file , ArchiverAttributeUtils .getFileAttributes (file ));
195- return new ArchiveEntry ( target , res , DIRECTORY , permissions );
203+ return new ArchiveEntry ( target , res , DIRECTORY , permissions , null );
196204 }
197205
198206 public static ArchiveEntry createEntry ( String target , File file , int filePerm , int dirPerm )
@@ -215,7 +223,8 @@ else if ( file.isFile() )
215223 public static ArchiveEntry createSymlinkEntry (String symlinkName , int permissions , String symlinkDestination )
216224 {
217225 File symlinkFile = new File (symlinkName );
218- final ArchiveEntry archiveEntry = new ArchiveEntry (symlinkName , new PlexusIoVirtualSymlinkResource (symlinkFile , symlinkDestination ), SYMLINK , permissions );
226+ final ArchiveEntry archiveEntry = new ArchiveEntry (symlinkName , new PlexusIoVirtualSymlinkResource (symlinkFile , symlinkDestination ), SYMLINK , permissions ,
227+ null );
219228 return archiveEntry ;
220229 }
221230
0 commit comments