Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC9A6D4FC for ; Thu, 6 Sep 2012 22:19:16 +0000 (UTC) Received: (qmail 55213 invoked by uid 500); 6 Sep 2012 22:19:16 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 54947 invoked by uid 500); 6 Sep 2012 22:19:15 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 54936 invoked by uid 99); 6 Sep 2012 22:19:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2012 22:19:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2012 22:19:14 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5CA78238897F for ; Thu, 6 Sep 2012 22:18:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1381781 - /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java Date: Thu, 06 Sep 2012 22:18:31 -0000 To: dev@tomcat.apache.org From: olamy@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120906221831.5CA78238897F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olamy Date: Thu Sep 6 22:18:30 2012 New Revision: 1381781 URL: http://svn.apache.org/viewvc?rev=1381781&view=rev Log: [MTOMCAT-174] tomcatConfigurationFilesDirectory is not implemented Submitted by Robin Böhm. 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=1381781&r1=1381780&r2=1381781&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 Thu Sep 6 22:18:30 2012 @@ -47,6 +47,7 @@ import org.codehaus.plexus.util.Director import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -68,45 +69,45 @@ public abstract class AbstractExecWarMoj extends AbstractTomcat7Mojo { - @Parameter( defaultValue = "${project.artifact}", required = true, readonly = true ) + @Parameter ( defaultValue = "${project.artifact}", required = true, readonly = true ) private Artifact projectArtifact; /** * The maven project. */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) + @Parameter ( defaultValue = "${project}", required = true, readonly = true ) protected MavenProject project; - @Parameter( defaultValue = "${plugin.artifacts}", required = true ) + @Parameter ( defaultValue = "${plugin.artifacts}", required = true ) private List pluginArtifacts; - @Parameter( defaultValue = "${project.build.directory}" ) + @Parameter ( defaultValue = "${project.build.directory}" ) private File buildDirectory; /** * Path under {@link #buildDirectory} where this mojo may do temporary work. */ - @Parameter( defaultValue = "${project.build.directory}/tomcat7-maven-plugin-exec" ) + @Parameter ( defaultValue = "${project.build.directory}/tomcat7-maven-plugin-exec" ) private File pluginWorkDirectory; - @Parameter( property = "maven.tomcat.exec.war.tomcatConf", defaultValue = "src/main/tomcatconf" ) + @Parameter ( property = "maven.tomcat.exec.war.tomcatConf", defaultValue = "src/main/tomcatconf" ) private File tomcatConfigurationFilesDirectory; - @Parameter( defaultValue = "src/main/tomcatconf/server.xml", property = "maven.tomcat.exec.war.serverXml" ) + @Parameter ( defaultValue = "src/main/tomcatconf/server.xml", property = "maven.tomcat.exec.war.serverXml" ) private File serverXml; /** * Name of the generated exec JAR. */ - @Parameter( property = "tomcat.jar.finalName", - defaultValue = "${project.artifactId}-${project.version}-war-exec.jar", required = true ) + @Parameter ( property = "tomcat.jar.finalName", + defaultValue = "${project.artifactId}-${project.version}-war-exec.jar", required = true ) private String finalName; /** * The webapp context path to use for the web application being run. * The name to store webapp in exec jar. Do not use / */ - @Parameter( property = "maven.tomcat.path", defaultValue = "${project.artifactId}", required = true ) + @Parameter ( property = "maven.tomcat.path", defaultValue = "${project.artifactId}", required = true ) protected String path; @Parameter @@ -124,13 +125,13 @@ public abstract class AbstractExecWarMoj /** * Location of the local repository. */ - @Parameter( defaultValue = "${localRepository}", required = true, readonly = true ) + @Parameter ( defaultValue = "${localRepository}", required = true, readonly = true ) private ArtifactRepository local; /** * List of Remote Repositories used by the resolver */ - @Parameter( defaultValue = "${project.remoteArtifactRepositories}", required = true, readonly = true ) + @Parameter ( defaultValue = "${project.remoteArtifactRepositories}", required = true, readonly = true ) protected List remoteRepos; @Component @@ -139,35 +140,35 @@ public abstract class AbstractExecWarMoj /** * Attach or not the generated artifact to the build (use true if you want to install or deploy it) */ - @Parameter( property = "maven.tomcat.exec.war.attachArtifact", defaultValue = "true", required = true ) + @Parameter ( property = "maven.tomcat.exec.war.attachArtifact", defaultValue = "true", required = true ) private boolean attachArtifact; /** * the classifier to use for the attached/generated artifact */ - @Parameter( property = "maven.tomcat.exec.war.attachArtifactClassifier", defaultValue = "exec-war", - required = true ) + @Parameter ( property = "maven.tomcat.exec.war.attachArtifactClassifier", defaultValue = "exec-war", + required = true ) private String attachArtifactClassifier; /** * the type to use for the attached/generated artifact */ - @Parameter( property = "maven.tomcat.exec.war.attachArtifactType", defaultValue = "jar", required = true ) + @Parameter ( property = "maven.tomcat.exec.war.attachArtifactType", defaultValue = "jar", required = true ) private String attachArtifactClassifierType; /** * to enable naming when starting tomcat */ - @Parameter( property = "maven.tomcat.exec.war.enableNaming", defaultValue = "false", required = true ) + @Parameter ( property = "maven.tomcat.exec.war.enableNaming", defaultValue = "false", required = true ) private boolean enableNaming; /** * see http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html */ - @Parameter( property = "maven.tomcat.exec.war.accessLogValveFormat", defaultValue = "%h %l %u %t %r %s %b %I %D", - required = true ) + @Parameter ( property = "maven.tomcat.exec.war.accessLogValveFormat", defaultValue = "%h %l %u %t %r %s %b %I %D", + required = true ) private String accessLogValveFormat; /** @@ -186,14 +187,14 @@ public abstract class AbstractExecWarMoj /** * Main class to use for starting the standalone jar. */ - @Parameter( property = "maven.tomcat.exec.war.mainClass", - defaultValue = "org.apache.tomcat.maven.runner.Tomcat7RunnerCli", required = true ) + @Parameter ( property = "maven.tomcat.exec.war.mainClass", + defaultValue = "org.apache.tomcat.maven.runner.Tomcat7RunnerCli", required = true ) private String mainClass; /** * which connector protocol to use HTTP/1.1 or org.apache.coyote.http11.Http11NioProtocol */ - @Parameter( property = "maven.tomcat.exec.war.connectorHttpProtocol", defaultValue = "HTTP/1.1", required = true ) + @Parameter ( property = "maven.tomcat.exec.war.connectorHttpProtocol", defaultValue = "HTTP/1.1", required = true ) private String connectorHttpProtocol; public void execute() @@ -430,6 +431,13 @@ public abstract class AbstractExecWarMoj } } + if ( tomcatConfigurationFilesDirectory != null && tomcatConfigurationFilesDirectory.exists() ) + { + // Because its the tomcat default dir for configs + String aConfigOutputDir = "conf/"; + copyDirectoryContentIntoArchive( tomcatConfigurationFilesDirectory, aConfigOutputDir, os ); + } + } catch ( ManifestException e ) { @@ -460,6 +468,43 @@ public abstract class AbstractExecWarMoj } } + private void copyDirectoryContentIntoArchive( File pSourceFolder, String pDestinationPath, + ArchiveOutputStream pArchiveOutputSteam ) + throws FileNotFoundException, IOException + { + + // Scan the directory + DirectoryScanner directoryScanner = new DirectoryScanner(); + directoryScanner.setBasedir( pSourceFolder ); + directoryScanner.addDefaultExcludes(); + directoryScanner.scan(); + + // Each File + for ( String aIncludeFileName : directoryScanner.getIncludedFiles() ) + { + getLog().debug( "include configuration file : " + pDestinationPath + aIncludeFileName ); + File aInputFile = new File( pSourceFolder, aIncludeFileName ); + + FileInputStream aSourceFileInputStream = new FileInputStream( aInputFile ); + + pArchiveOutputSteam.putArchiveEntry( new JarArchiveEntry( pDestinationPath + aIncludeFileName ) ); + IOUtils.copy( aSourceFileInputStream, pArchiveOutputSteam ); + pArchiveOutputSteam.closeArchiveEntry(); + + } + + /* + // Each Dir + for (String aIncludeDir : directoryScanner.getIncludedDirectories()) { + File aSubDir = new File(pSourceFolder + "/" + aIncludeDir); + if(!pSourceFolder.equals(aSubDir)){ + getLog().debug("include configuration dir : " + pDestinationPath + "/" + aIncludeDir); + copyDirectoryContentIntoArchive(new File(pSourceFolder + "/" + aIncludeDir), pDestinationPath + "/" + aIncludeDir, pArchiveOutputSteam); + } + } + */ + } + /** * Resolves the plugin work dir as a sub directory of {@link #buildDirectory}, creating it if it does not exist. * --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org