Author: olamy
Date: Fri Jan 11 13:59:27 2013
New Revision: 1432054
URL: http://svn.apache.org/viewvc?rev=1432054&view=rev
Log:
[MTOMCAT-119] tomcat7:run-war fails because it expects META-INF\context.xml
Submitted by Glen Mazza
Modified:
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunMojo.java
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunWarMojo.java
Modified:
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunMojo.java
URL:
http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunMojo.java?rev=1432054&r1=1432053&r2=1432054&view=diff
==============================================================================
---
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunMojo.java
(original)
+++
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunMojo.java
Fri Jan 11 13:59:27 2013
@@ -344,6 +344,16 @@ public abstract class AbstractRunMojo
protected File contextFile;
/**
+ * The default context file to check for if contextFile not configured.
+ * If no contextFile configured and the below default not present, no
+ * contextFile will be sent to Tomcat, resulting in the latter's default
+ * context configuration being used instead.
+ */
+ @Parameter( defaultValue =
"${project.build.directory}/${project.build.finalName}/META-INF/context.xml",
+ readonly = true )
+ private File defaultContextFile;
+
+ /**
* The protocol to run the Tomcat server on.
* By default it's HTTP/1.1.
*
@@ -532,12 +542,21 @@ public abstract class AbstractRunMojo
String baseDir = getDocBase().getAbsolutePath();
- File overridedContextFile = getContextFile();
+ File overriddenContextFile = getContextFile();
+
+ StandardContext standardContext = null;
- if ( overridedContextFile != null && overridedContextFile.exists() )
+ if ( overriddenContextFile != null && overriddenContextFile.exists() )
{
- StandardContext standardContext = parseContextFile(
overridedContextFile );
+ standardContext = parseContextFile( overriddenContextFile );
+ }
+ else if (defaultContextFile.exists())
+ {
+ standardContext = parseContextFile( defaultContextFile );
+ }
+ if (standardContext != null)
+ {
if ( standardContext.getPath() != null )
{
contextPath = standardContext.getPath();
@@ -566,11 +585,18 @@ public abstract class AbstractRunMojo
context.setLoader( loader );
- if ( overridedContextFile != null )
+ if ( overriddenContextFile != null )
{
- context.setConfigFile( overridedContextFile.toURI().toURL() );
+ // here, send file to Tomcat for it to complain if missing
+ context.setConfigFile( overriddenContextFile.toURI().toURL() );
+ }
+ else if (defaultContextFile.exists())
+ {
+ // here, only sending default file if it indeed exists
+ // otherwise Tomcat will create a default context
+ context.setConfigFile( defaultContextFile.toURI().toURL() );
}
-
+
if ( classLoaderClass != null )
{
loader.setLoaderClass( classLoaderClass );
Modified:
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunWarMojo.java
URL:
http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunWarMojo.java?rev=1432054&r1=1432053&r2=1432054&view=diff
==============================================================================
---
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunWarMojo.java
(original)
+++
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunWarMojo.java
Fri Jan 11 13:59:27 2013
@@ -39,15 +39,9 @@ public abstract class AbstractRunWarMojo
/**
* The path of the exploded WAR directory to run.
*/
- @Parameter( defaultValue =
"${project.build.directory}/${project.build.finalName}", required = true )
+ @Parameter( property = "maven.tomcat.warDirectory", defaultValue =
"${project.build.directory}/${project.build.finalName}", required = true )
private File warDirectory;
- /**
- * The path of the Tomcat context XML file.
- */
- @Parameter( defaultValue =
"${project.build.directory}/${project.build.finalName}/META-INF/context.xml" )
- private File contextFile;
-
// ----------------------------------------------------------------------
// AbstractRunMojo Implementation
// ----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]