1 package org.apache.maven.plugin.source;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.codehaus.plexus.archiver.Archiver;
20 import org.codehaus.plexus.archiver.ArchiverException;
21 import org.codehaus.plexus.util.FileUtils;
22
23 import java.io.File;
24 import java.io.IOException;
25
26 /**
27 * Helper class that generates the jar file
28 *
29 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
30 * @version $Id: SourceBundler.java 420743 2006-07-11 07:01:47Z oching $
31 */
32 public class SourceBundler
33 {
34 private static final String[] DEFAULT_INCLUDES = new String[]{"**/*",};
35
36 /**
37 * Method to create an archive of the specified files
38 *
39 * @param outputFile the destination file of the generated archive
40 * @param sourceDirectories the directory where the files to be archived are located
41 * @param archiver the archiver object that will create the archive
42 * @throws ArchiverException
43 * @throws IOException
44 */
45 public void makeSourceBundle( File outputFile, File[] sourceDirectories, Archiver archiver )
46 throws ArchiverException, IOException
47 {
48 String[] includes = DEFAULT_INCLUDES;
49
50 for ( int i = 0; i < sourceDirectories.length; i++ )
51 {
52 if ( sourceDirectories[i].exists() )
53 {
54 archiver.addDirectory( sourceDirectories[i], includes, FileUtils.getDefaultExcludes() );
55 }
56 }
57
58 archiver.setDestFile( outputFile );
59
60 archiver.createArchive();
61 }
62 }