1 package org.apache.maven.plugins.war.packaging;
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.IOException;
24
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.plugin.MojoFailureException;
27 import org.apache.maven.plugin.logging.Log;
28 import org.apache.maven.plugin.logging.SystemStreamLog;
29
30
31
32
33
34 public class CopyUserManifestTask
35 extends AbstractWarPackagingTask
36 {
37
38
39 private Log log;
40
41 public Log getLog()
42 {
43 if ( log == null )
44 {
45 log = new SystemStreamLog();
46 }
47 return log;
48 }
49
50 public void setLog( Log log )
51 {
52 this.log = log;
53 }
54
55 public void performPackaging( WarPackagingContext context )
56 throws MojoExecutionException, MojoFailureException
57 {
58 File userManifest = context.getArchive().getManifestFile();
59 if ( userManifest != null )
60 {
61
62 try
63 {
64 getLog().info( "Copying manifest..." );
65 File metainfDir = new File( context.getWebappDirectory(), META_INF_PATH );
66 copyFile( context, userManifest, new File( metainfDir, "MANIFEST.MF" ), "META-INF/MANIFEST.MF", true );
67
68 }
69 catch ( IOException e )
70 {
71 throw new MojoExecutionException( "Error copying user manifest", e );
72 }
73 }
74
75 }
76
77 }