1 package org.apache.tomcat.maven.plugin.tomcat6;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugins.annotations.Parameter;
24 import org.apache.tomcat.maven.common.deployer.TomcatManagerException;
25
26 import java.io.File;
27 import java.io.IOException;
28
29
30
31
32
33 public class AbstractDeployWarMojo
34 extends AbstractDeployMojo
35 {
36
37
38
39
40
41
42
43 @Parameter( defaultValue = "${project.build.directory}/${project.build.finalName}.war", required = true )
44 private File warFile;
45
46
47
48
49
50
51
52
53 @Override
54 protected File getWarFile()
55 {
56 return warFile;
57 }
58
59
60
61
62 @Override
63 protected void validateWarFile()
64 throws MojoExecutionException
65 {
66 if ( !warFile.exists() || !warFile.isFile() )
67 {
68 throw new MojoExecutionException(
69 messagesProvider.getMessage( "DeployMojo.missingWar", warFile.getPath() ) );
70 }
71 }
72
73
74
75
76 @Override
77 protected void deployWar()
78 throws MojoExecutionException, TomcatManagerException, IOException
79 {
80 validateWarFile();
81
82 getLog().info( messagesProvider.getMessage( "AbstractDeployMojo.deployingWar", getDeployedURL() ) );
83
84 log( getManager().deploy( getPath(), warFile, isUpdate(), getTag(), warFile.length() ).getHttpResponseBody() );
85 }
86 }