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/05/28 17:53:09 UTC
svn commit: r1343301 -
/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
Author: olamy
Date: Mon May 28 15:53:09 2012
New Revision: 1343301
URL: http://svn.apache.org/viewvc?rev=1343301&view=rev
Log:
[MTOMCAT-155] allow exec-war war run dependencies that are generated in current mvn execution, but not yet installed to maven repo
Submitted by Peter Lynch.
Modified:
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java?rev=1343301&r1=1343300&r2=1343301&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java (original)
+++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java Mon May 28 15:53:09 2012
@@ -66,8 +66,6 @@ import java.util.jar.JarFile;
public abstract class AbstractExecWarMojo
extends AbstractTomcat7Mojo
{
-
-
/**
* @parameter default-value="${project.artifact}"
* @required
@@ -96,6 +94,13 @@ public abstract class AbstractExecWarMoj
private File buildDirectory;
/**
+ * Path under {@link #buildDirectory} where this mojo may do temporary work.
+ *
+ * @parameter default-value="tomcat7-maven-plugin-exec"
+ */
+ private String pluginWorkDirectory;
+
+ /**
* @parameter default-value="src/main/tomcatconf" expression="${maven.tomcat.exec.war.tomcatConf}"
*/
private File tomcatConfigurationFilesDirectory;
@@ -105,7 +110,6 @@ public abstract class AbstractExecWarMoj
*/
private File serverXml;
-
/**
* Name of the generated exec JAR.
*
@@ -324,15 +328,17 @@ public abstract class AbstractExecWarMoj
dependency.getClassifier() );
artifactResolver.resolve( artifact, this.remoteRepos, this.local );
- File warFile = new File( buildDirectory, artifact.getFile().getName() );
- String warFileName = artifact.getFile().getName();
- FileUtils.copyFile( artifact.getFile(), warFile );
+
+ File warFileToBundle = new File( resolvePluginWorkDir(), artifact.getFile().getName() );
+ FileUtils.copyFile( artifact.getFile(), warFileToBundle );
+
if ( warRunDependency.contextXml != null )
{
- warFile = addContextXmlToWar( warRunDependency.contextXml, warFile );
+ warFileToBundle = addContextXmlToWar( warRunDependency.contextXml, warFileToBundle );
}
+ final String warFileName = artifact.getFile().getName();
os.putArchiveEntry( new JarArchiveEntry( warFileName ) );
- IOUtils.copy( new FileInputStream( warFile ), os );
+ IOUtils.copy( new FileInputStream( warFileToBundle ), os );
os.closeArchiveEntry();
String propertyWarValue = properties.getProperty( Tomcat7Runner.WARS_KEY );
String contextPath =
@@ -498,6 +504,21 @@ public abstract class AbstractExecWarMoj
}
}
+ /**
+ * Resolves the plugin work dir as a sub directory of {@link #buildDirectory}, creating it if it does not exist.
+ *
+ * @return File representing the resolved plugin work dir
+ * @throws MojoExecutionException if the plugin work dir cannot be created
+ */
+ protected File resolvePluginWorkDir() throws MojoExecutionException {
+ File workDir = new File(buildDirectory, pluginWorkDirectory);
+ if(!workDir.exists() && !workDir.mkdirs()){
+ throw new MojoExecutionException("Could not create plugin work directory at " + workDir.getAbsolutePath());
+ };
+ return workDir;
+
+ }
+
private String[] toStringArray( List list )
{
if ( list == null || list.isEmpty() )
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1343301 - /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
Posted by Olivier Lamy <ol...@apache.org>.
2012/5/28 Konstantin Kolinko <kn...@gmail.com>:
> 2012/5/28 <ol...@apache.org>:
>> Author: olamy
>> Date: Mon May 28 15:53:09 2012
>> New Revision: 1343301
>>
>> URL: http://svn.apache.org/viewvc?rev=1343301&view=rev
>> Log:
>> [MTOMCAT-155] allow exec-war war run dependencies that are generated in current mvn execution, but not yet installed to maven repo
>> Submitted by Peter Lynch.
>>
>> Modified:
>> tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
>>
>>(...)
>> @@ -96,6 +94,13 @@ public abstract class AbstractExecWarMoj
>> private File buildDirectory;
>>
>> /**
>> + * Path under {@link #buildDirectory} where this mojo may do temporary work.
>> + *
>> + * @parameter default-value="tomcat7-maven-plugin-exec"
>> + */
>> + private String pluginWorkDirectory;
>
> 1. Would it be better to make it a File instead of a String, like
> other fields there ?
>
> 2. It might be useful to allow absolute paths here.
>
> E.g. if one wants to move it to the system temporary directory, or to
> a RAM drive.
sounds good idea.
I will change that.
Thanks for the review!
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
--
Olivier Lamy
Talend: http://coders.talend.com
http://twitter.com/olamy | http://linkedin.com/in/olamy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1343301 - /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/5/28 <ol...@apache.org>:
> Author: olamy
> Date: Mon May 28 15:53:09 2012
> New Revision: 1343301
>
> URL: http://svn.apache.org/viewvc?rev=1343301&view=rev
> Log:
> [MTOMCAT-155] allow exec-war war run dependencies that are generated in current mvn execution, but not yet installed to maven repo
> Submitted by Peter Lynch.
>
> Modified:
> tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
>
>(...)
> @@ -96,6 +94,13 @@ public abstract class AbstractExecWarMoj
> private File buildDirectory;
>
> /**
> + * Path under {@link #buildDirectory} where this mojo may do temporary work.
> + *
> + * @parameter default-value="tomcat7-maven-plugin-exec"
> + */
> + private String pluginWorkDirectory;
1. Would it be better to make it a File instead of a String, like
other fields there ?
2. It might be useful to allow absolute paths here.
E.g. if one wants to move it to the system temporary directory, or to
a RAM drive.
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org