You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ol...@apache.org on 2012/07/10 00:11:00 UTC
svn commit: r1359427 - in /tomcat/maven-plugin/trunk:
common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/config/
tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/
tomcat7-maven-plugin/src/main/java/org/apac...
Author: olamy
Date: Mon Jul 9 22:10:59 2012
New Revision: 1359427
URL: http://svn.apache.org/viewvc?rev=1359427&view=rev
Log:
[MTOMCAT-167] Add the ability to specify context.xml files for each additional Webapp being deployed
Submitted by Nigel Sim.
Modified:
tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/config/AbstractWebapp.java
tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractRunMojo.java
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunMojo.java
Modified: tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/config/AbstractWebapp.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/config/AbstractWebapp.java?rev=1359427&r1=1359426&r2=1359427&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/config/AbstractWebapp.java (original)
+++ tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/config/AbstractWebapp.java Mon Jul 9 22:10:59 2012
@@ -22,6 +22,8 @@ package org.apache.tomcat.maven.common.c
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.Artifact;
+import java.io.File;
+
/**
* @since 2.0
*/
@@ -60,6 +62,8 @@ public class AbstractWebapp
private Artifact artifact;
+ private File contextFile;
+
public AbstractWebapp()
{
super();
@@ -149,4 +153,14 @@ public class AbstractWebapp
this.artifact = artifact;
}
+ public void setContextFile( File contextFile )
+ {
+ this.contextFile = contextFile;
+ }
+
+ public File getContextFile()
+ {
+ return contextFile;
+ }
+
}
\ No newline at end of file
Modified: tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractRunMojo.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractRunMojo.java?rev=1359427&r1=1359426&r2=1359427&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractRunMojo.java (original)
+++ tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractRunMojo.java Mon Jul 9 22:10:59 2012
@@ -993,21 +993,26 @@ public abstract class AbstractRunMojo
// provided scope, not is it optional
if ( "war".equals( artifact.getType() ) && !artifact.isOptional() && filter.include( artifact ) )
{
- addContextFromArtifact( container, contexts, artifact, "/" + artifact.getArtifactId() );
+ addContextFromArtifact( container, contexts, artifact, "/" + artifact.getArtifactId(), null );
}
}
for ( AbstractWebapp additionalWebapp : getAdditionalWebapps() )
{
- addContextFromArtifact( container, contexts, getArtifact( additionalWebapp ),
- "/" + additionalWebapp.getContextPath() );
+ String contextPath = additionalWebapp.getContextPath();
+ if ( !contextPath.startsWith( "/" ) )
+ {
+ contextPath = "/" + contextPath;
+ }
+ addContextFromArtifact( container, contexts, getArtifact( additionalWebapp ), contextPath,
+ additionalWebapp.getContextFile() );
}
return contexts;
}
private void addContextFromArtifact( Embedded container, List<Context> contexts, Artifact artifact,
- String contextPath )
+ String contextPath, File contextXml )
throws MojoExecutionException
{
getLog().info( "Deploy warfile: " + String.valueOf( artifact.getFile() ) + " to contextPath: " + contextPath );
@@ -1040,10 +1045,11 @@ public abstract class AbstractRunMojo
WebappLoader webappLoader = new WebappLoader( Thread.currentThread().getContextClassLoader() );
Context context = container.createContext( contextPath, artifactWarDir.getAbsolutePath() );
context.setLoader( webappLoader );
- File contextFile = getContextFile();
+
+ File contextFile = contextXml != null ? contextXml : getContextFile();
if ( contextFile != null )
{
- context.setConfigFile( getContextFile().getAbsolutePath() );
+ context.setConfigFile( contextFile.getAbsolutePath() );
}
contexts.add( context );
}
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=1359427&r1=1359426&r2=1359427&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 Mon Jul 9 22:10:59 2012
@@ -1180,21 +1180,26 @@ public abstract class AbstractRunMojo
// provided scope, not is it optional
if ( "war".equals( artifact.getType() ) && !artifact.isOptional() && filter.include( artifact ) )
{
- addContextFromArtifact( container, contexts, artifact, "/" + artifact.getArtifactId() );
+ addContextFromArtifact( container, contexts, artifact, "/" + artifact.getArtifactId(), null );
}
}
for ( AbstractWebapp additionalWebapp : getAdditionalWebapps() )
{
- addContextFromArtifact( container, contexts, getArtifact( additionalWebapp ),
- "/" + additionalWebapp.getContextPath() );
+ String contextPath = additionalWebapp.getContextPath();
+ if ( !contextPath.startsWith( "/" ) )
+ {
+ contextPath = "/" + contextPath;
+ }
+ addContextFromArtifact( container, contexts, getArtifact( additionalWebapp ), contextPath,
+ additionalWebapp.getContextFile() );
}
return contexts;
}
private void addContextFromArtifact( Tomcat container, List<Context> contexts, Artifact artifact,
- String contextPath )
+ String contextPath, File contextXml )
throws MojoExecutionException, MalformedURLException
{
getLog().info( "Deploy warfile: " + String.valueOf( artifact.getFile() ) + " to contextPath: " + contextPath );
@@ -1227,11 +1232,13 @@ public abstract class AbstractRunMojo
WebappLoader webappLoader = new WebappLoader( Thread.currentThread().getContextClassLoader() );
Context context = container.addContext( contextPath, artifactWarDir.getAbsolutePath() );
context.setLoader( webappLoader );
- File contextFile = getContextFile();
+
+ File contextFile = contextXml != null ? contextXml : getContextFile();
if ( contextFile != null )
{
- context.setConfigFile( getContextFile().toURI().toURL() );
+ context.setConfigFile( contextFile.toURI().toURL() );
}
+
contexts.add( context );
// container.getHost().addChild(context);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org