Author: olamy Date: Tue Oct 22 01:01:09 2013 New Revision: 1534436 URL: http://svn.apache.org/r1534436 Log: [MTOMCAT-239] src/main/webapp must not be mandatory when running a jar so create a fake one
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/RunMojo.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=1534436&r1=1534435&r2=1534436&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 Tue Oct 22 01:01:09 2013 @@ -477,6 +477,7 @@ public abstract class AbstractRunMojo /** * In case a module in your reactors has some web-fragments they will be read. * If you don't need that for performance reasons, you can deactivate it. + * * @since 2.2 */ @Parameter( property = "maven.tomcat.jarScan.allDirectories", defaultValue = "true" ) @@ -643,16 +644,15 @@ public abstract class AbstractRunMojo loader.setLoaderClass( classLoaderClass ); } - // https://issues.apache.org/jira/browse/MTOMCAT-239 // get the jar scanner to configure scanning directories as we can run a jar or a reactor project with a jar so // the entries is a directory (target/classes) JarScanner jarScanner = context.getJarScanner(); // normally this one only but just in case ... - if (jarScanner instanceof StandardJarScanner) + if ( jarScanner instanceof StandardJarScanner ) { - ((StandardJarScanner) jarScanner).setScanAllDirectories( jarScanAllDirectories ); + ( (StandardJarScanner) jarScanner ).setScanAllDirectories( jarScanAllDirectories ); } return context; @@ -810,7 +810,8 @@ public abstract class AbstractRunMojo * * @return the webapp directory */ - protected abstract File getDocBase(); + protected abstract File getDocBase() + throws IOException; /** * Gets the Tomcat context XML file to use. Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java?rev=1534436&r1=1534435&r2=1534436&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java (original) +++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java Tue Oct 22 01:01:09 2013 @@ -29,7 +29,6 @@ import org.apache.maven.plugins.annotati import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; -import org.apache.maven.shared.filtering.MavenFileFilter; import org.apache.maven.shared.filtering.MavenFileFilterRequest; import org.apache.maven.shared.filtering.MavenFilteringException; import org.apache.tomcat.maven.common.run.ClassLoaderEntriesCalculator; @@ -123,10 +122,35 @@ public class RunMojo */ @Override protected File getDocBase() + throws IOException { + // + if ( !warSourceDirectory.exists() ) + { + // we create a temporary file in build.directory + return createTempDirectory( new File( project.getBuild().getDirectory() ) ); + } return warSourceDirectory; } + private static File createTempDirectory( File baseTmpDirectory ) + throws IOException + { + final File temp = File.createTempFile( "temp", Long.toString( System.nanoTime() ), baseTmpDirectory ); + + if ( !( temp.delete() ) ) + { + throw new IOException( "Could not delete temp file: " + temp.getAbsolutePath() ); + } + + if ( !( temp.mkdir() ) ) + { + throw new IOException( "Could not create temp directory: " + temp.getAbsolutePath() ); + } + + return temp; + } + /** * {@inheritDoc} */ --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org