1 package org.apache.tomcat.maven.plugin.tomcat7;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import org.apache.maven.plugin.AbstractMojo;
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugins.annotations.Component;
24 import org.apache.maven.plugins.annotations.Parameter;
25 import org.apache.maven.settings.Settings;
26 import org.apache.tomcat.maven.common.deployer.TomcatManagerResponse;
27 import org.apache.tomcat.maven.common.messages.MessagesProvider;
28
29
30
31
32
33 public abstract class AbstractTomcat7Mojo
34 extends AbstractMojo
35 {
36 @Component
37 protected Settings settings;
38
39 @Component
40 protected MessagesProvider messagesProvider;
41
42
43
44
45
46
47
48
49
50 @Parameter(defaultValue = "/${project.artifactId}", property = "maven.tomcat.path", required = true)
51 protected String path;
52
53
54 protected String getPath()
55 {
56 return path;
57 }
58
59
60
61
62
63
64
65
66 protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse )
67 throws MojoExecutionException
68 {
69 int statusCode = tomcatResponse.getStatusCode();
70
71 if ( statusCode >= 400 )
72 {
73 getLog().error( messagesProvider.getMessage( "tomcatHttpStatusError", statusCode,
74 tomcatResponse.getReasonPhrase() ) );
75
76 throw new MojoExecutionException(
77 messagesProvider.getMessage( "tomcatHttpStatusError", statusCode,
78 tomcatResponse.getReasonPhrase() ) + ": "
79 + tomcatResponse.getHttpResponseBody() );
80 }
81 }
82 }