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 2014/08/13 02:17:08 UTC
svn commit: r1617630 [3/3] - in /tomcat/maven-plugin/branches/tc8.x: ./
tomcat8-maven-plugin/ tomcat8-maven-plugin/src/it/simple-war-exec-project/
tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/
tomcat8-maven-plugin/src/main/...
Modified: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/adjust-embedded-tomcat-version.apt.vm
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/adjust-embedded-tomcat-version.apt.vm?rev=1617630&r1=1617629&r2=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/adjust-embedded-tomcat-version.apt.vm (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/adjust-embedded-tomcat-version.apt.vm Wed Aug 13 00:17:06 2014
@@ -44,7 +44,7 @@ Adjust Tomcat Version
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<version>${project.version}</version>
<dependencies>
<dependency>
Modified: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/index.apt?rev=1617630&r1=1617629&r2=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/index.apt (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/index.apt Wed Aug 13 00:17:06 2014
@@ -28,7 +28,7 @@
Tomcat Maven Plugin
- The Tomcat7 Maven Plugin provides goals to manipulate WAR projects within the {{{http://tomcat.apache.org/}Tomcat}} servlet container version 7.x
+ The Tomcat8 Maven Plugin provides goals to manipulate WAR projects within the {{{http://tomcat.apache.org/}Tomcat}} servlet container version 7.x
* Goals Overview
Modified: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/usage.apt.vm
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/usage.apt.vm?rev=1617630&r1=1617629&r2=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/usage.apt.vm (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/site/apt/usage.apt.vm Wed Aug 13 00:17:06 2014
@@ -28,7 +28,7 @@
Usage
- If no explicit configuration is provided then the Tomcat7 Maven Plugin defaults to
+ If no explicit configuration is provided then the Tomcat8 Maven Plugin defaults to
the following:
* Tomcat manager URL of <<<http://localhost:8080/manager>>>
@@ -55,7 +55,7 @@ Usage
...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<url>http://www.mydomain.com:1234/mymanager</url>
@@ -87,7 +87,7 @@ Usage
...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<server>myserver</server>
@@ -138,7 +138,7 @@ Usage
...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<path>/mycontext</path>
@@ -167,7 +167,7 @@ Usage
...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<path>/\${project.build.finalName}</path>
Copied: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarOnlyProjectIT.java (from r1612479, tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7DeployWarOnlyProjectIT.java)
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarOnlyProjectIT.java?p2=tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarOnlyProjectIT.java&p1=tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7DeployWarOnlyProjectIT.java&r1=1612479&r2=1617630&rev=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7DeployWarOnlyProjectIT.java (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarOnlyProjectIT.java Wed Aug 13 00:17:06 2014
@@ -23,7 +23,7 @@ import org.apache.tomcat.maven.it.Abstra
/**
* @author Olivier Lamy
*/
-public class Tomcat7DeployWarOnlyProjectIT
+public class Tomcat8DeployWarOnlyProjectIT
extends AbstractDeployWarOnlyProjectIT
{
// no op
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarOnlyProjectIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarOnlyProjectIT.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarProjectIT.java (from r1612479, tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7DeployWarProjectIT.java)
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarProjectIT.java?p2=tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarProjectIT.java&p1=tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7DeployWarProjectIT.java&r1=1612479&r2=1617630&rev=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7DeployWarProjectIT.java (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarProjectIT.java Wed Aug 13 00:17:06 2014
@@ -23,7 +23,7 @@ import org.apache.tomcat.maven.it.Abstra
/**
* @author Olivier Lamy
*/
-public class Tomcat7DeployWarProjectIT
+public class Tomcat8DeployWarProjectIT
extends AbstractDeployWarProjectIT
{
// no op
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarProjectIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8DeployWarProjectIT.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8RunMultiConfigIT.java (from r1612479, tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7RunMultiConfigIT.java)
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8RunMultiConfigIT.java?p2=tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8RunMultiConfigIT.java&p1=tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7RunMultiConfigIT.java&r1=1612479&r2=1617630&rev=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7RunMultiConfigIT.java (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8RunMultiConfigIT.java Wed Aug 13 00:17:06 2014
@@ -24,7 +24,7 @@ import org.apache.tomcat.maven.it.Abstra
/**
* @author Olivier Lamy
*/
-public class Tomcat7RunMultiConfigIT
+public class Tomcat8RunMultiConfigIT
extends AbstractTomcatRunMultiConfigIT
{
@Override
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8RunMultiConfigIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8RunMultiConfigIT.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8SimpleWarProjectIT.java (from r1612479, tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7SimpleWarProjectIT.java)
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8SimpleWarProjectIT.java?p2=tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8SimpleWarProjectIT.java&p1=tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7SimpleWarProjectIT.java&r1=1612479&r2=1617630&rev=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat7SimpleWarProjectIT.java (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8SimpleWarProjectIT.java Wed Aug 13 00:17:06 2014
@@ -24,7 +24,7 @@ import org.apache.tomcat.maven.it.Abstra
/**
* @author Olivier Lamy
*/
-public class Tomcat7SimpleWarProjectIT
+public class Tomcat8SimpleWarProjectIT
extends AbstractSimpleWarProjectIT
{
protected int getTimeout()
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8SimpleWarProjectIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/java/org/apache/tomcat/maven/it/Tomcat8SimpleWarProjectIT.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/deploy-only-war-project/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/deploy-only-war-project/pom.xml?rev=1617630&r1=1617629&r2=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/deploy-only-war-project/pom.xml (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/deploy-only-war-project/pom.xml Wed Aug 13 00:17:06 2014
@@ -44,7 +44,7 @@
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
@@ -59,7 +59,7 @@
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<executions>
<execution>
<id>tomcat-run</id>
Modified: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/deploy-war-project/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/deploy-war-project/pom.xml?rev=1617630&r1=1617629&r2=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/deploy-war-project/pom.xml (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/deploy-war-project/pom.xml Wed Aug 13 00:17:06 2014
@@ -44,7 +44,7 @@
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
@@ -59,7 +59,7 @@
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<executions>
<execution>
<id>tomcat-run</id>
Modified: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/simple-war-project/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/simple-war-project/pom.xml?rev=1617630&r1=1617629&r2=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/simple-war-project/pom.xml (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/simple-war-project/pom.xml Wed Aug 13 00:17:06 2014
@@ -44,7 +44,7 @@
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
@@ -59,7 +59,7 @@
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<executions>
<execution>
<id>tomcat-run</id>
Modified: tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/tomcat-run-multi-config/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/tomcat-run-multi-config/pom.xml?rev=1617630&r1=1617629&r2=1617630&view=diff
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/tomcat-run-multi-config/pom.xml (original)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-maven-plugin/src/test/resources/tomcat-run-multi-config/pom.xml Wed Aug 13 00:17:06 2014
@@ -40,7 +40,7 @@
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
@@ -55,7 +55,7 @@
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
+ <artifactId>tomcat8-maven-plugin</artifactId>
<executions>
<execution>
<id>tomcat-run</id>
Added: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/NOTES.TXT
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/NOTES.TXT?rev=1617630&view=auto
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/NOTES.TXT (added)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/NOTES.TXT Wed Aug 13 00:17:06 2014
@@ -0,0 +1,39 @@
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+
+The generated standalone jar will contains:
+* wars in the root: foo.war
+* tomcat classes in jar
+* file tomcat.standalone.properties with possible values :
+ * useServerXml=true/false to use directly the one provided
+ in the maven plugin configuration
+ * wars=foo.war|contextpath;bar.war ( |contextpath is optionnal if empty use the war name)
+ * enableNaming=true/false
+ * accessLogValveFormat=
+ * connectorhttpProtocol: HTTP/1.1 or org.apache.coyote.http11.Http11NioProtocol
+
+* optionnal: conf/ with usual tomcat configuration files
+
+On start:
+1. create a .extract directory with all the tomcat configuration
+2. check if -serverXml is set: if yes use it
+ 2.1. check in tomcat.standalone.properties if useServerXml=true
+ if use extract it to .extract/conf and use it with
+ other files located in /conf (except if .extract already here )
+ 2.2. if not use data from cli: -httpPort, -httpsPort, -ajpPort
+3. now extract wars to .extract/webapps/ (except if .extract already here )
+4. start Tomcat embded with necessary configuration and add webapps.
Added: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/pom.xml?rev=1617630&view=auto
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/pom.xml (added)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/pom.xml Wed Aug 13 00:17:06 2014
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <groupId>org.apache.tomcat.maven</groupId>
+ <version>2.3-SNAPSHOT</version>
+ </parent>
+ <artifactId>tomcat8-war-runner</artifactId>
+ <version>2.3-SNAPSHOT</version>
+ <name>Apache Tomcat Maven Plugin :: Tomcat 8.x War Runner</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ </dependency>
+
+ <!-- tomcat dependencies -->
+ <dependency>
+ <groupId>org.eclipse.jdt.core.compiler</groupId>
+ <artifactId>ecj</artifactId>
+ <version>3.7</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-util</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-coyote</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-api</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jdbc</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-dbcp</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-servlet-api</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jsp-api</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jasper</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jasper-el</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-el-api</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-catalina</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-tribes</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-catalina-ha</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-annotations-api</artifactId>
+ <version>${tomcat8Version}</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java?rev=1617630&view=auto
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java (added)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java Wed Aug 13 00:17:06 2014
@@ -0,0 +1,131 @@
+package org.apache.tomcat.maven.runner;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Properties;
+
+
+/**
+ * Password obfuscate utility class. Lifted from Jetty org.mortbay.jetty.security.Password
+ * <p/>
+ * <p/>
+ * Passwords that begin with OBF: are de obfuscated.
+ * <p/>
+ * Passwords can be obfuscated by running Obfuscate as a main class. Obfuscated password are required if a system needs
+ * to recover the full password (eg. so that it may be passed to another system).
+ * <p/>
+ * They are not secure, but prevent casual observation.
+ *
+ * @see <a
+ * href="http://grepcode.com/file_/repo1.maven.org/maven2/org.mortbay.jetty/jetty/6.1.11/org/mortbay/jetty/security/Password.java/?v=source"
+ * >Jetty Source org.mortbay.jetty.security.Password</a>
+ * @since 2.0
+ */
+public class PasswordUtil
+{
+ public static final String __OBFUSCATE = "OBF:";
+
+ /* ------------------------------------------------------------ */
+ public static String obfuscate( String s )
+ {
+ StringBuilder buf = new StringBuilder();
+ byte[] b = s.getBytes();
+
+ buf.append( __OBFUSCATE );
+ for ( int i = 0; i < b.length; i++ )
+ {
+ byte b1 = b[i];
+ byte b2 = b[s.length() - ( i + 1 )];
+ int i1 = 127 + b1 + b2;
+ int i2 = 127 + b1 - b2;
+ int i0 = i1 * 256 + i2;
+ String x = Integer.toString( i0, 36 );
+
+ switch ( x.length() )
+ {
+ case 1:
+ buf.append( '0' );
+ case 2:
+ buf.append( '0' );
+ case 3:
+ buf.append( '0' );
+ default:
+ buf.append( x );
+ }
+ }
+ return buf.toString();
+
+ }
+
+ /* ------------------------------------------------------------ */
+ public static String deobfuscate( String s )
+ {
+ if ( s.startsWith( __OBFUSCATE ) )
+ {
+ s = s.substring( __OBFUSCATE.length() );
+
+ byte[] b = new byte[s.length() / 2];
+ int l = 0;
+ for ( int i = 0; i < s.length(); i += 4 )
+ {
+ String x = s.substring( i, i + 4 );
+ int i0 = Integer.parseInt( x, 36 );
+ int i1 = ( i0 / 256 );
+ int i2 = ( i0 % 256 );
+ b[l++] = (byte) ( ( i1 + i2 - 254 ) / 2 );
+ }
+ return new String( b, 0, l );
+ }
+ else
+ {
+ return s;
+ }
+
+ }
+
+ public static void deobfuscateSystemProps()
+ {
+ Properties props = System.getProperties();
+ for ( Object obj : props.keySet() )
+ {
+ if ( obj instanceof String )
+ {
+ String key = (String) obj;
+ String value = (String) props.getProperty( key );
+ if ( value != null && value.startsWith( __OBFUSCATE ) )
+ {
+ System.setProperty( key, deobfuscate( value ) );
+ }
+ }
+ }
+ }
+
+ public static void main( String[] args )
+ {
+ if ( args[0].startsWith( __OBFUSCATE ) )
+ {
+ System.out.println( PasswordUtil.deobfuscate( args[1] ) );
+ }
+ else
+ {
+ System.out.println( PasswordUtil.obfuscate( args[1] ) );
+ }
+ }
+}
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java?rev=1617630&view=auto
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java (added)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java Wed Aug 13 00:17:06 2014
@@ -0,0 +1,826 @@
+package org.apache.tomcat.maven.runner;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Host;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.startup.Catalina;
+import org.apache.catalina.startup.ContextConfig;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.catalina.valves.AccessLogValve;
+import org.apache.juli.ClassLoaderLogManager;
+import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.http.fileupload.FileUtils;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.logging.LogManager;
+
+/**
+ * FIXME add junit for that but when https://issues.apache.org/bugzilla/show_bug.cgi?id=52028 fixed
+ * Main class used to run the standalone wars in a Apache Tomcat instance.
+ *
+ * @author Olivier Lamy
+ * @since 2.0
+ */
+public class Tomcat8Runner
+{
+ // true/false to use the server.xml located in the jar /conf/server.xml
+ public static final String USE_SERVER_XML_KEY = "useServerXml";
+
+ // contains war name wars=foo.war,bar.war
+ public static final String WARS_KEY = "wars";
+
+ public static final String ARCHIVE_GENERATION_TIMESTAMP_KEY = "generationTimestamp";
+
+ public static final String ENABLE_NAMING_KEY = "enableNaming";
+
+ public static final String ACCESS_LOG_VALVE_FORMAT_KEY = "accessLogValveFormat";
+
+ public static final String CODE_SOURCE_CONTEXT_PATH = "codeSourceContextPath";
+
+ /**
+ * key of the property which contains http protocol : HTTP/1.1 or org.apache.coyote.http11.Http11NioProtocol
+ */
+ public static final String HTTP_PROTOCOL_KEY = "connectorhttpProtocol";
+
+ /**
+ * key for default http port defined in the plugin
+ */
+ public static final String HTTP_PORT_KEY = "httpPort";
+
+
+ public int httpPort;
+
+ public int httpsPort;
+
+ public int maxPostSize = 2097152;
+
+ public int ajpPort;
+
+ public String serverXmlPath;
+
+ public Properties runtimeProperties;
+
+ public boolean resetExtract;
+
+ public boolean debug = false;
+
+ public String clientAuth = "false";
+
+ public String keyAlias = null;
+
+ public String httpProtocol;
+
+ public String extractDirectory = ".extract";
+
+ public File extractDirectoryFile;
+
+ public String codeSourceContextPath = null;
+
+ public File codeSourceWar = null;
+
+ public String loggerName;
+
+ Catalina container;
+
+ Tomcat tomcat;
+
+ String uriEncoding = "ISO-8859-1";
+
+ /**
+ * key = context of the webapp, value = war path on file system
+ */
+ Map<String, String> webappWarPerContext = new HashMap<String, String>();
+
+ public Tomcat8Runner()
+ {
+ // no op
+ }
+
+ public void run()
+ throws Exception
+ {
+
+ PasswordUtil.deobfuscateSystemProps();
+
+ if ( loggerName != null && loggerName.length() > 0 )
+ {
+ installLogger( loggerName );
+ }
+
+ this.extractDirectoryFile = new File( this.extractDirectory );
+
+ debugMessage( "use extractDirectory:" + extractDirectoryFile.getPath() );
+
+ boolean archiveTimestampChanged = false;
+
+ // compare timestamp stored during previous run if exists
+ File timestampFile = new File( extractDirectoryFile, ".tomcat_executable_archive.timestamp" );
+
+ Properties timestampProps = loadProperties( timestampFile );
+
+ if ( timestampFile.exists() )
+ {
+ String timestampValue = timestampProps.getProperty( Tomcat8Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY );
+ if ( timestampValue != null )
+ {
+ long timestamp = Long.parseLong( timestampValue );
+ archiveTimestampChanged =
+ Long.parseLong( runtimeProperties.getProperty( Tomcat8Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY ) )
+ > timestamp;
+
+ debugMessage( "read timestamp from file " + timestampValue + ", archiveTimestampChanged: "
+ + archiveTimestampChanged );
+ }
+
+ }
+
+ codeSourceContextPath = runtimeProperties.getProperty( CODE_SOURCE_CONTEXT_PATH );
+ if ( codeSourceContextPath != null && !codeSourceContextPath.isEmpty() )
+ {
+ codeSourceWar = AccessController.doPrivileged( new PrivilegedAction<File>()
+ {
+ public File run()
+ {
+ try
+ {
+ File src =
+ new File( Tomcat8Runner.class.getProtectionDomain().getCodeSource().getLocation().toURI() );
+ if ( src.getName().endsWith( ".war" ) )
+ {
+ return src;
+ }
+ else
+ {
+ debugMessage( "ERROR: Code source is not a war file, ignoring." );
+ }
+ }
+ catch ( URISyntaxException e )
+ {
+ debugMessage( "ERROR: Could not find code source. " + e.getMessage() );
+
+ }
+ return null;
+ }
+ } );
+ }
+
+ // do we have to extract content
+ {
+ if ( !extractDirectoryFile.exists() || resetExtract || archiveTimestampChanged )
+ {
+ extract();
+ //if archiveTimestampChanged or timestamp file not exists store the last timestamp from the archive
+ if ( archiveTimestampChanged || !timestampFile.exists() )
+ {
+ timestampProps.put( Tomcat8Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY, runtimeProperties.getProperty(
+ Tomcat8Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY ) );
+ saveProperties( timestampProps, timestampFile );
+ }
+ }
+ else
+ {
+ String wars = runtimeProperties.getProperty( WARS_KEY );
+ populateWebAppWarPerContext( wars );
+ }
+ }
+
+ // create tomcat various paths
+ new File( extractDirectory, "conf" ).mkdirs();
+ new File( extractDirectory, "logs" ).mkdirs();
+ new File( extractDirectory, "webapps" ).mkdirs();
+ new File( extractDirectory, "work" ).mkdirs();
+ File tmpDir = new File( extractDirectory, "temp" );
+ tmpDir.mkdirs();
+
+ System.setProperty( "java.io.tmpdir", tmpDir.getAbsolutePath() );
+
+ System.setProperty( "catalina.base", extractDirectoryFile.getAbsolutePath() );
+ System.setProperty( "catalina.home", extractDirectoryFile.getAbsolutePath() );
+
+ // start with a server.xml
+ if ( serverXmlPath != null || useServerXml() )
+ {
+ container = new Catalina();
+ container.setUseNaming( this.enableNaming() );
+ if ( serverXmlPath != null && new File( serverXmlPath ).exists() )
+ {
+ container.setConfigFile( serverXmlPath );
+ }
+ else
+ {
+ container.setConfigFile( new File( extractDirectory, "conf/server.xml" ).getAbsolutePath() );
+ }
+ container.start();
+ }
+ else
+ {
+ tomcat = new Tomcat()
+ {
+ public Context addWebapp( Host host, String url, String name, String path )
+ {
+
+ Context ctx = new StandardContext();
+ ctx.setName( name );
+ ctx.setPath( url );
+ ctx.setDocBase( path );
+
+ ContextConfig ctxCfg = new ContextConfig();
+ ctx.addLifecycleListener( ctxCfg );
+
+ ctxCfg.setDefaultWebXml( new File( extractDirectory, "conf/web.xml" ).getAbsolutePath() );
+
+ if ( host == null )
+ {
+ getHost().addChild( ctx );
+ }
+ else
+ {
+ host.addChild( ctx );
+ }
+
+ return ctx;
+ }
+ };
+
+ if ( this.enableNaming() )
+ {
+ System.setProperty( "catalina.useNaming", "true" );
+ tomcat.enableNaming();
+ }
+
+ tomcat.getHost().setAppBase( new File( extractDirectory, "webapps" ).getAbsolutePath() );
+
+ String connectorHttpProtocol = runtimeProperties.getProperty( HTTP_PROTOCOL_KEY );
+
+ if ( httpProtocol != null && httpProtocol.trim().length() > 0 )
+ {
+ connectorHttpProtocol = httpProtocol;
+ }
+
+ debugMessage( "use connectorHttpProtocol:" + connectorHttpProtocol );
+
+ if ( httpPort > 0 )
+ {
+ Connector connector = new Connector( connectorHttpProtocol );
+ connector.setPort( httpPort );
+ connector.setMaxPostSize( maxPostSize );
+
+ if ( httpsPort > 0 )
+ {
+ connector.setRedirectPort( httpsPort );
+ }
+ connector.setURIEncoding( uriEncoding );
+
+ tomcat.getService().addConnector( connector );
+
+ tomcat.setConnector( connector );
+ }
+
+ // add a default acces log valve
+ AccessLogValve alv = new AccessLogValve();
+ alv.setDirectory( new File( extractDirectory, "logs" ).getAbsolutePath() );
+ alv.setPattern( runtimeProperties.getProperty( Tomcat8Runner.ACCESS_LOG_VALVE_FORMAT_KEY ) );
+ tomcat.getHost().getPipeline().addValve( alv );
+
+ // create https connector
+ if ( httpsPort > 0 )
+ {
+ Connector httpsConnector = new Connector( connectorHttpProtocol );
+ httpsConnector.setPort( httpsPort );
+ httpsConnector.setMaxPostSize( maxPostSize );
+ httpsConnector.setSecure( true );
+ httpsConnector.setProperty( "SSLEnabled", "true" );
+ httpsConnector.setProperty( "sslProtocol", "TLS" );
+ httpsConnector.setURIEncoding( uriEncoding );
+
+ String keystoreFile = System.getProperty( "javax.net.ssl.keyStore" );
+ String keystorePass = System.getProperty( "javax.net.ssl.keyStorePassword" );
+ String keystoreType = System.getProperty( "javax.net.ssl.keyStoreType", "jks" );
+
+ if ( keystoreFile != null )
+ {
+ httpsConnector.setAttribute( "keystoreFile", keystoreFile );
+ }
+ if ( keystorePass != null )
+ {
+ httpsConnector.setAttribute( "keystorePass", keystorePass );
+ }
+ httpsConnector.setAttribute( "keystoreType", keystoreType );
+
+ String truststoreFile = System.getProperty( "javax.net.ssl.trustStore" );
+ String truststorePass = System.getProperty( "javax.net.ssl.trustStorePassword" );
+ String truststoreType = System.getProperty( "javax.net.ssl.trustStoreType", "jks" );
+ if ( truststoreFile != null )
+ {
+ httpsConnector.setAttribute( "truststoreFile", truststoreFile );
+ }
+ if ( truststorePass != null )
+ {
+ httpsConnector.setAttribute( "truststorePass", truststorePass );
+ }
+ httpsConnector.setAttribute( "truststoreType", truststoreType );
+
+ httpsConnector.setAttribute( "clientAuth", clientAuth );
+ httpsConnector.setAttribute( "keyAlias", keyAlias );
+
+ tomcat.getService().addConnector( httpsConnector );
+
+ if ( httpPort <= 0 )
+ {
+ tomcat.setConnector( httpsConnector );
+ }
+ }
+
+ // create ajp connector
+ if ( ajpPort > 0 )
+ {
+ Connector ajpConnector = new Connector( "org.apache.coyote.ajp.AjpProtocol" );
+ ajpConnector.setPort( ajpPort );
+ ajpConnector.setURIEncoding( uriEncoding );
+ tomcat.getService().addConnector( ajpConnector );
+ }
+
+ // add webapps
+ for ( Map.Entry<String, String> entry : this.webappWarPerContext.entrySet() )
+ {
+ String baseDir = null;
+ Context context = null;
+ if ( entry.getKey().equals( "/" ) )
+ {
+ baseDir = new File( extractDirectory, "webapps/ROOT.war" ).getAbsolutePath();
+ context = tomcat.addWebapp( "", baseDir );
+ }
+ else
+ {
+ baseDir = new File( extractDirectory, "webapps/" + entry.getValue() ).getAbsolutePath();
+ context = tomcat.addWebapp( entry.getKey(), baseDir );
+ }
+
+ URL contextFileUrl = getContextXml( baseDir );
+ if ( contextFileUrl != null )
+ {
+ context.setConfigFile( contextFileUrl );
+ }
+ }
+
+ if ( codeSourceWar != null )
+ {
+ String baseDir = new File( extractDirectory, "webapps/" + codeSourceWar.getName() ).getAbsolutePath();
+ Context context = tomcat.addWebapp( codeSourceContextPath, baseDir );
+ URL contextFileUrl = getContextXml( baseDir );
+ if ( contextFileUrl != null )
+ {
+ context.setConfigFile( contextFileUrl );
+ }
+ }
+
+ tomcat.start();
+
+ Runtime.getRuntime().addShutdownHook( new TomcatShutdownHook() );
+
+ }
+
+ waitIndefinitely();
+
+ }
+
+ protected class TomcatShutdownHook
+ extends Thread
+ {
+
+ protected TomcatShutdownHook()
+ {
+ // no op
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ Tomcat8Runner.this.stop();
+ }
+ catch ( Throwable ex )
+ {
+ ExceptionUtils.handleThrowable( ex );
+ System.out.println( "fail to properly shutdown Tomcat:" + ex.getMessage() );
+ }
+ finally
+ {
+ // If JULI is used, shut JULI down *after* the server shuts down
+ // so log messages aren't lost
+ LogManager logManager = LogManager.getLogManager();
+ if ( logManager instanceof ClassLoaderLogManager )
+ {
+ ( (ClassLoaderLogManager) logManager ).shutdown();
+ }
+ }
+ }
+ }
+
+ private URL getContextXml( String warPath )
+ throws IOException
+ {
+ InputStream inputStream = null;
+ try
+ {
+ String urlStr = "jar:file:" + warPath + "!/META-INF/context.xml";
+ debugMessage( "search context.xml in url:'" + urlStr + "'" );
+ URL url = new URL( urlStr );
+ inputStream = url.openConnection().getInputStream();
+ if ( inputStream != null )
+ {
+ return url;
+ }
+ }
+ catch ( FileNotFoundException e )
+ {
+ return null;
+ }
+ finally
+ {
+ closeQuietly( inputStream );
+ }
+ return null;
+ }
+
+ private static void closeQuietly( InputStream inputStream )
+ {
+ if ( inputStream == null )
+ {
+ return;
+ }
+ try
+ {
+ inputStream.close();
+ }
+ catch ( IOException e )
+ {
+ // ignore exception here
+ }
+ }
+
+ private void waitIndefinitely()
+ {
+ Object lock = new Object();
+
+ synchronized ( lock )
+ {
+ try
+ {
+ lock.wait();
+ }
+ catch ( InterruptedException exception )
+ {
+ throw new Error( "InterruptedException on wait Indefinitely lock:" + exception.getMessage(),
+ exception );
+ }
+ }
+ }
+
+ public void stop()
+ throws Exception
+ {
+ if ( container != null )
+ {
+ container.stop();
+ }
+ if ( tomcat != null )
+ {
+ tomcat.stop();
+ }
+ }
+
+ protected void extract()
+ throws Exception
+ {
+
+ if ( extractDirectoryFile.exists() )
+ {
+ debugMessage( "delete extractDirectory:" + extractDirectoryFile.getAbsolutePath() );
+ FileUtils.deleteDirectory( extractDirectoryFile );
+ }
+
+ if ( !this.extractDirectoryFile.exists() )
+ {
+ boolean created = this.extractDirectoryFile.mkdirs();
+ if ( !created )
+ {
+ throw new Exception( "FATAL: impossible to create directory:" + this.extractDirectoryFile.getPath() );
+ }
+ }
+
+ // ensure webapp dir is here
+ boolean created = new File( extractDirectory, "webapps" ).mkdirs();
+ if ( !created )
+ {
+ throw new Exception(
+ "FATAL: impossible to create directory:" + this.extractDirectoryFile.getPath() + "/webapps" );
+
+ }
+
+ String wars = runtimeProperties.getProperty( WARS_KEY );
+ populateWebAppWarPerContext( wars );
+
+ for ( Map.Entry<String, String> entry : webappWarPerContext.entrySet() )
+ {
+ debugMessage( "webappWarPerContext entry key/value: " + entry.getKey() + "/" + entry.getValue() );
+ InputStream inputStream = null;
+ try
+ {
+ File expandFile = null;
+ inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream( entry.getValue() );
+ if ( !useServerXml() )
+ {
+ if ( entry.getKey().equals( "/" ) )
+ {
+ expandFile = new File( extractDirectory, "webapps/ROOT.war" );
+ }
+ else
+ {
+ expandFile = new File( extractDirectory, "webapps/" + entry.getValue() );
+ }
+ }
+ else
+ {
+ expandFile = new File( extractDirectory, "webapps/" + entry.getValue() );
+ }
+
+ debugMessage( "expand to file:" + expandFile.getPath() );
+
+ // MTOMCAT-211 ensure parent directories created
+ File parentFile = expandFile.getParentFile();
+ if ( !parentFile.mkdirs() && !parentFile.isDirectory() )
+ {
+ throw new Exception( "FATAL: impossible to create directories:" + parentFile );
+ }
+
+ expand( inputStream, expandFile );
+
+ }
+ finally
+ {
+ if ( inputStream != null )
+ {
+ inputStream.close();
+ }
+ }
+ }
+
+ //Copy code source to webapps folder
+ if ( codeSourceWar != null )
+ {
+ FileInputStream inputStream = null;
+ try
+ {
+ File expandFile = new File( extractDirectory, "webapps/" + codeSourceContextPath + ".war" );
+ inputStream = new FileInputStream( codeSourceWar );
+ debugMessage( "move code source to file:" + expandFile.getPath() );
+ expand( inputStream, expandFile );
+ }
+ finally
+ {
+ if ( inputStream != null )
+ {
+ inputStream.close();
+ }
+ }
+ }
+
+ // expand tomcat configuration files if there
+ expandConfigurationFile( "catalina.properties", extractDirectoryFile );
+ expandConfigurationFile( "logging.properties", extractDirectoryFile );
+ expandConfigurationFile( "tomcat-users.xml", extractDirectoryFile );
+ expandConfigurationFile( "catalina.policy", extractDirectoryFile );
+ expandConfigurationFile( "context.xml", extractDirectoryFile );
+ expandConfigurationFile( "server.xml", extractDirectoryFile );
+ expandConfigurationFile( "web.xml", extractDirectoryFile );
+
+ }
+
+ private static void expandConfigurationFile( String fileName, File extractDirectory )
+ throws Exception
+ {
+ InputStream inputStream = null;
+ try
+ {
+ inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream( "conf/" + fileName );
+ if ( inputStream != null )
+ {
+ File confDirectory = new File( extractDirectory, "conf" );
+ if ( !confDirectory.exists() )
+ {
+ confDirectory.mkdirs();
+ }
+ expand( inputStream, new File( confDirectory, fileName ) );
+ }
+ }
+ finally
+ {
+ if ( inputStream != null )
+ {
+ inputStream.close();
+ }
+ }
+
+ }
+
+ /**
+ * @param warsValue we can value in format: wars=foo.war|contextpath;bar.war ( |contextpath is optionnal if empty use the war name)
+ * so here we return war file name and populate webappWarPerContext
+ */
+ private void populateWebAppWarPerContext( String warsValue )
+ {
+ if ( warsValue == null )
+ {
+ return;
+ }
+
+ StringTokenizer st = new StringTokenizer( warsValue, ";" );
+ while ( st.hasMoreTokens() )
+ {
+ String warValue = st.nextToken();
+ debugMessage( "populateWebAppWarPerContext warValue:" + warValue );
+ String warFileName = "";
+ String contextValue = "";
+ int separatorIndex = warValue.indexOf( "|" );
+ if ( separatorIndex >= 0 )
+ {
+ warFileName = warValue.substring( 0, separatorIndex );
+ contextValue = warValue.substring( separatorIndex + 1, warValue.length() );
+
+ }
+ else
+ {
+ warFileName = contextValue;
+ }
+ debugMessage( "populateWebAppWarPerContext contextValue/warFileName:" + contextValue + "/" + warFileName );
+ this.webappWarPerContext.put( contextValue, warFileName );
+ }
+ }
+
+
+ /**
+ * Expand the specified input stream into the specified file.
+ *
+ * @param input InputStream to be copied
+ * @param file The file to be created
+ * @throws java.io.IOException if an input/output error occurs
+ */
+ private static void expand( InputStream input, File file )
+ throws IOException
+ {
+ BufferedOutputStream output = null;
+ try
+ {
+ output = new BufferedOutputStream( new FileOutputStream( file ) );
+ byte buffer[] = new byte[2048];
+ while ( true )
+ {
+ int n = input.read( buffer );
+ if ( n <= 0 )
+ {
+ break;
+ }
+ output.write( buffer, 0, n );
+ }
+ }
+ finally
+ {
+ if ( output != null )
+ {
+ try
+ {
+ output.close();
+ }
+ catch ( IOException e )
+ {
+ // Ignore
+ }
+ }
+ }
+ }
+
+ public boolean useServerXml()
+ {
+ return Boolean.parseBoolean( runtimeProperties.getProperty( USE_SERVER_XML_KEY, Boolean.FALSE.toString() ) );
+ }
+
+
+ public void debugMessage( String message )
+ {
+ if ( debug )
+ {
+ System.out.println( message );
+ }
+ }
+
+
+ public boolean enableNaming()
+ {
+ return Boolean.parseBoolean( runtimeProperties.getProperty( ENABLE_NAMING_KEY, Boolean.FALSE.toString() ) );
+ }
+
+ private void installLogger( String loggerName )
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
+ InvocationTargetException
+ {
+ if ( "slf4j".equals( loggerName ) )
+ {
+
+ try
+ {
+ // Check class is available
+
+ //final Class<?> clazz = Class.forName( "org.slf4j.bridge.SLF4JBridgeHandler" );
+ final Class<?> clazz =
+ Thread.currentThread().getContextClassLoader().loadClass( "org.slf4j.bridge.SLF4JBridgeHandler" );
+
+ // Remove all JUL handlers
+ java.util.logging.LogManager.getLogManager().reset();
+
+ // Install slf4j bridge handler
+ final Method method = clazz.getMethod( "install", null );
+ method.invoke( null );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ System.out.println( "WARNING: issue configuring slf4j jul bridge, skip it" );
+ }
+ }
+ else
+ {
+ System.out.println( "WARNING: loggerName " + loggerName + " not supported, skip it" );
+ }
+ }
+
+ private Properties loadProperties( File file )
+ throws FileNotFoundException, IOException
+ {
+ Properties properties = new Properties();
+ if ( file.exists() )
+ {
+
+ FileInputStream fileInputStream = new FileInputStream( file );
+ try
+ {
+ properties.load( fileInputStream );
+ }
+ finally
+ {
+ fileInputStream.close();
+ }
+
+ }
+ return properties;
+ }
+
+ private void saveProperties( Properties properties, File file )
+ throws FileNotFoundException, IOException
+ {
+ FileOutputStream fileOutputStream = new FileOutputStream( file );
+ try
+ {
+ properties.store( fileOutputStream, "Timestamp file for executable war/jar" );
+ }
+ finally
+ {
+ fileOutputStream.close();
+ }
+ }
+}
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8RunnerCli.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8RunnerCli.java?rev=1617630&view=auto
==============================================================================
--- tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8RunnerCli.java (added)
+++ tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8RunnerCli.java Wed Aug 13 00:17:06 2014
@@ -0,0 +1,238 @@
+package org.apache.tomcat.maven.runner;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * @author Olivier Lamy
+ * @since 2.0
+ */
+@SuppressWarnings("static-access")
+public class Tomcat8RunnerCli
+{
+
+ public static final String STAND_ALONE_PROPERTIES_FILENAME = "tomcat.standalone.properties";
+
+ static Option httpPort =
+ OptionBuilder.withArgName( "httpPort" ).hasArg().withDescription( "http port to use" ).create( "httpPort" );
+
+ static Option httpsPort =
+ OptionBuilder.withArgName( "httpsPort" ).hasArg().withDescription( "https port to use" ).create( "httpsPort" );
+
+ static Option maxPostSize =
+ OptionBuilder.withArgName( "maxPostSize" ).hasArg().withDescription( "max post size to use" ).create(
+ "maxPostSize" );
+
+ static Option ajpPort =
+ OptionBuilder.withArgName( "ajpPort" ).hasArg().withDescription( "ajp port to use" ).create( "ajpPort" );
+
+ static Option serverXmlPath =
+ OptionBuilder.withArgName( "serverXmlPath" ).hasArg().withDescription( "server.xml to use, optional" ).create(
+ "serverXmlPath" );
+
+ static Option resetExtract =
+ OptionBuilder.withArgName( "resetExtract" ).withDescription( "clean previous extract directory" ).create(
+ "resetExtract" );
+
+ static Option help = OptionBuilder.withLongOpt( "help" ).withDescription( "help" ).create( 'h' );
+
+ static Option debug = OptionBuilder.withLongOpt( "debug" ).withDescription( "debug" ).create( 'X' );
+
+ static Option sysProps = OptionBuilder.withDescription( "use value for given property" ).hasArgs().withDescription(
+ "key=value" ).withValueSeparator().create( 'D' );
+
+ static Option clientAuth =
+ OptionBuilder.withArgName( "clientAuth" ).withDescription( "enable client authentication for https" ).create(
+ "clientAuth" );
+
+ static Option keyAlias =
+ OptionBuilder.withArgName( "keyAlias" ).hasArgs().withDescription( "alias from keystore for ssl" ).create(
+ "keyAlias" );
+
+ static Option obfuscate =
+ OptionBuilder.withArgName( "password" ).hasArgs().withDescription( "obfuscate the password and exit" ).create(
+ "obfuscate" );
+
+ static Option httpProtocol = OptionBuilder.withArgName( "httpProtocol" ).hasArg().withDescription(
+ "http protocol to use: HTTP/1.1 or org.apache.coyote.http11.Http11NioProtocol" ).create( "httpProtocol" );
+
+ static Option extractDirectory = OptionBuilder.withArgName( "extractDirectory" ).hasArg().withDescription(
+ "path to extract war content, default value: .extract" ).create( "extractDirectory" );
+
+ static Option loggerName = OptionBuilder.withArgName( "loggerName" ).hasArg().withDescription(
+ "logger to use: slf4j to use slf4j bridge on top of jul" ).create( "loggerName" );
+
+ static Option uriEncoding = OptionBuilder.withArgName( "uriEncoding" ).hasArg().withDescription(
+ "connector uriEncoding default ISO-8859-1" ).create( "uriEncoding" );
+
+ static Options options = new Options();
+
+ static
+ {
+ options.addOption( httpPort ).addOption( httpsPort ).addOption( ajpPort ).addOption( serverXmlPath ).addOption(
+ resetExtract ).addOption( help ).addOption( debug ).addOption( sysProps ).addOption(
+ httpProtocol ).addOption( clientAuth ).addOption( keyAlias ).addOption( obfuscate ).addOption(
+ extractDirectory ).addOption( loggerName ).addOption( uriEncoding ).addOption( maxPostSize );
+ }
+
+
+ public static void main( String[] args )
+ throws Exception
+ {
+ CommandLineParser parser = new GnuParser();
+ CommandLine line = null;
+ try
+ {
+ line = parser.parse( Tomcat8RunnerCli.options, args );
+ }
+ catch ( ParseException e )
+ {
+ System.err.println( "Parsing failed. Reason: " + e.getMessage() );
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp( getCmdLineSyntax(), Tomcat8RunnerCli.options );
+ System.exit( 1 );
+ }
+
+ if ( line.hasOption( help.getOpt() ) )
+ {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp( getCmdLineSyntax(), Tomcat8RunnerCli.options );
+ System.exit( 0 );
+ }
+
+ if ( line.hasOption( obfuscate.getOpt() ) )
+ {
+ System.out.println( PasswordUtil.obfuscate( line.getOptionValue( obfuscate.getOpt() ) ) );
+ System.exit( 0 );
+ }
+ Tomcat8Runner tomcat8Runner = new Tomcat8Runner();
+
+ tomcat8Runner.runtimeProperties = buildStandaloneProperties();
+
+ if ( line.hasOption( serverXmlPath.getOpt() ) )
+ {
+ tomcat8Runner.serverXmlPath = line.getOptionValue( serverXmlPath.getOpt() );
+ }
+
+ String port = tomcat8Runner.runtimeProperties.getProperty( Tomcat8Runner.HTTP_PORT_KEY );
+ if ( port != null )
+ {
+ tomcat8Runner.httpPort = Integer.parseInt( port );
+ }
+
+ // cli win for the port
+ if ( line.hasOption( httpPort.getOpt() ) )
+ {
+ tomcat8Runner.httpPort = Integer.parseInt( line.getOptionValue( httpPort.getOpt() ) );
+ }
+
+ if ( line.hasOption( maxPostSize.getOpt() ) )
+ {
+ tomcat8Runner.maxPostSize = Integer.parseInt( line.getOptionValue( maxPostSize.getOpt() ) );
+ }
+
+ if ( line.hasOption( httpsPort.getOpt() ) )
+ {
+ tomcat8Runner.httpsPort = Integer.parseInt( line.getOptionValue( httpsPort.getOpt() ) );
+ }
+ if ( line.hasOption( ajpPort.getOpt() ) )
+ {
+ tomcat8Runner.ajpPort = Integer.parseInt( line.getOptionValue( ajpPort.getOpt() ) );
+ }
+ if ( line.hasOption( resetExtract.getOpt() ) )
+ {
+ tomcat8Runner.resetExtract = true;
+ }
+ if ( line.hasOption( debug.getOpt() ) )
+ {
+ tomcat8Runner.debug = true;
+ }
+
+ if ( line.hasOption( httpProtocol.getOpt() ) )
+ {
+ tomcat8Runner.httpProtocol = line.getOptionValue( httpProtocol.getOpt() );
+ }
+
+ if ( line.hasOption( sysProps.getOpt() ) )
+ {
+ Properties systemProperties = line.getOptionProperties( sysProps.getOpt() );
+ if ( systemProperties != null && !systemProperties.isEmpty() )
+ {
+ for ( Map.Entry<Object, Object> sysProp : systemProperties.entrySet() )
+ {
+ System.setProperty( (String) sysProp.getKey(), (String) sysProp.getValue() );
+ }
+ }
+ }
+ if ( line.hasOption( clientAuth.getOpt() ) )
+ {
+ tomcat8Runner.clientAuth = clientAuth.getOpt();
+ }
+ if ( line.hasOption( keyAlias.getOpt() ) )
+ {
+ tomcat8Runner.keyAlias = line.getOptionValue( keyAlias.getOpt() );
+ }
+
+ if ( line.hasOption( extractDirectory.getOpt() ) )
+ {
+ tomcat8Runner.extractDirectory = line.getOptionValue( extractDirectory.getOpt() );
+ }
+
+ if ( line.hasOption( loggerName.getOpt() ) )
+ {
+ tomcat8Runner.loggerName = line.getOptionValue( loggerName.getOpt() );
+ }
+
+ if ( line.hasOption( uriEncoding.getOpt() ) )
+ {
+ tomcat8Runner.uriEncoding = line.getOptionValue( uriEncoding.getOpt() );
+ }
+
+ // here we go
+ tomcat8Runner.run();
+ }
+
+ private static Properties buildStandaloneProperties()
+ throws IOException
+ {
+ InputStream is =
+ Thread.currentThread().getContextClassLoader().getResourceAsStream( STAND_ALONE_PROPERTIES_FILENAME );
+ Properties properties = new Properties();
+ properties.load( is );
+ return properties;
+ }
+
+ public static String getCmdLineSyntax()
+ {
+ return "java -jar [path to your exec war jar]";
+ }
+}
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8RunnerCli.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/maven-plugin/branches/tc8.x/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8RunnerCli.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org