1 package org.apache.maven.plugins.shade.resource;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.FileInputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.util.List;
27 import java.util.jar.JarEntry;
28 import java.util.jar.JarOutputStream;
29
30 import org.codehaus.plexus.util.IOUtil;
31
32
33
34
35
36 public class IncludeResourceTransformer
37 implements ResourceTransformer
38 {
39 File file;
40 String resource;
41
42 public boolean canTransformResource( String r )
43 {
44 return false;
45 }
46
47 public void processResource( String resource, InputStream is, List relocators )
48 throws IOException
49 {
50
51 }
52
53 public boolean hasTransformedResource()
54 {
55 return file != null ? file.exists() : false;
56 }
57
58 public void modifyOutputStream( JarOutputStream jos )
59 throws IOException
60 {
61 jos.putNextEntry( new JarEntry( resource ) );
62
63 InputStream in = new FileInputStream( file );
64 IOUtil.copy( in, jos );
65 in.close();
66 }
67 }