Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
SourceBundler |
|
| 3.0;3 |
1 | package org.apache.maven.plugin.source; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2005-2006 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
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 | 6 | public class SourceBundler |
33 | { |
|
34 | 1 | 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 | 6 | String[] includes = DEFAULT_INCLUDES; |
49 | ||
50 | 20 | for ( int i = 0; i < sourceDirectories.length; i++ ) |
51 | { |
|
52 | 14 | if ( sourceDirectories[i].exists() ) |
53 | { |
|
54 | 14 | archiver.addDirectory( sourceDirectories[i], includes, FileUtils.getDefaultExcludes() ); |
55 | } |
|
56 | } |
|
57 | ||
58 | 6 | archiver.setDestFile( outputFile ); |
59 | ||
60 | 6 | archiver.createArchive(); |
61 | 6 | } |
62 | } |