1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.war.packaging;
20
21 import java.io.File;
22 import java.io.IOException;
23
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.apache.maven.plugin.logging.Log;
27 import org.apache.maven.plugin.logging.SystemStreamLog;
28
29
30
31
32
33 public class CopyUserManifestTask extends AbstractWarPackagingTask {
34
35
36 private Log log;
37
38
39
40
41
42
43 public Log getLog() {
44 if (log == null) {
45 log = new SystemStreamLog();
46 }
47 return log;
48 }
49
50
51
52
53
54
55 public void setLog(Log log) {
56 this.log = log;
57 }
58
59 public void performPackaging(WarPackagingContext context) throws MojoExecutionException, MojoFailureException {
60 File userManifest = context.getArchive().getManifestFile();
61 if (userManifest != null) {
62
63 try {
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 } catch (IOException e) {
69 throw new MojoExecutionException("Error copying user manifest", e);
70 }
71 }
72 }
73 }