Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/MavenWebappClassLoader.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/MavenWebappClassLoader.java?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/MavenWebappClassLoader.java (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/MavenWebappClassLoader.java Tue Aug 16 01:03:14 2016 @@ -0,0 +1,119 @@ +package org.apache.tomcat.maven.plugin.tomcat8.run; + +/* + * 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.loader.ResourceEntry; +import org.apache.catalina.loader.WebappClassLoader; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; + +/** + * @author Olivier Lamy + */ +public class MavenWebappClassLoader + extends WebappClassLoader +{ + + private ClassLoader classLoader; + + public MavenWebappClassLoader( ClassLoader parent ) + { + super( parent ); + this.classLoader = parent; + } + + @Override + public Class<?> findClass( String name ) + throws ClassNotFoundException + { + return super.findClass( name ); + } + + @Override + public URL findResource( String name ) + { + return super.findResource( name ); + } + + @Override + public Enumeration<URL> findResources( String name ) + throws IOException + { + return super.findResources( name ); + } + + @Override + public URL getResource( String name ) + { + return super.getResource( name ); + } + + @Override + public InputStream getResourceAsStream( String name ) + { + return super.getResourceAsStream( name ); + } + + @Override + public Class<?> loadClass( String name ) + throws ClassNotFoundException + { + try + { + return classLoader.loadClass( name ); + } + catch ( ClassNotFoundException e ) + { + // go to top + } + return super.loadClass( name ); + } + + @Override + public synchronized Class<?> loadClass( String name, boolean resolve ) + throws ClassNotFoundException + { + try + { + return classLoader.loadClass( name ); + } + catch ( ClassNotFoundException e ) + { + // go to top + } + return super.loadClass( name, resolve ); + } + + @Override + protected ResourceEntry findResourceInternal( String name, String path ) + { + return super.findResourceInternal( name, path ); + } + + @Override + protected Class<?> findClassInternal( String name ) + throws ClassNotFoundException + { + return super.findClassInternal( name ); + } +}
Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/MavenWebappClassLoader.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/MavenWebappClassLoader.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java Tue Aug 16 01:03:14 2016 @@ -0,0 +1,508 @@ +package org.apache.tomcat.maven.plugin.tomcat8.run; +/* + * 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.WebResource; +import org.apache.catalina.WebResourceSet; +import org.apache.catalina.loader.WebappLoader; +import org.apache.catalina.webresources.EmptyResource; +import org.apache.catalina.webresources.FileResource; +import org.apache.catalina.webresources.FileResourceSet; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Execute; +import org.apache.maven.plugins.annotations.LifecyclePhase; +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.MavenFileFilterRequest; +import org.apache.maven.shared.filtering.MavenFilteringException; +import org.apache.tomcat.maven.common.run.ClassLoaderEntriesCalculator; +import org.apache.tomcat.maven.common.run.ClassLoaderEntriesCalculatorRequest; +import org.apache.tomcat.maven.common.run.ClassLoaderEntriesCalculatorResult; +import org.apache.tomcat.maven.common.run.TomcatRunException; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.codehaus.plexus.util.xml.Xpp3DomBuilder; +import org.codehaus.plexus.util.xml.Xpp3DomWriter; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.jar.JarFile; + +/** + * Runs the current project as a dynamic web application using an embedded Tomcat server. + * + * @author Olivier Lamy + * @since 2.0 + */ +@Mojo(name = "run", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) +@Execute(phase = LifecyclePhase.PROCESS_CLASSES) +public class RunMojo + extends AbstractRunMojo +{ + // ---------------------------------------------------------------------- + // Mojo Parameters + // ---------------------------------------------------------------------- + + + /** + * The set of dependencies for the web application being run. + */ + @Parameter(defaultValue = "${project.artifacts}", required = true, readonly = true) + private Set<Artifact> dependencies; + + /** + * The web resources directory for the web application being run. + */ + @Parameter(defaultValue = "${basedir}/src/main/webapp", property = "tomcat.warSourceDirectory") + private File warSourceDirectory; + + + /** + * Set the "follow standard delegation model" flag used to configure our ClassLoader. + * + * @see http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/loader/WebappLoader.html#setDelegate(boolean) + * @since 1.0 + */ + @Parameter(property = "tomcat.delegate", defaultValue = "true") + private boolean delegate = true; + + /** + * @since 2.0 + */ + @Component + private ClassLoaderEntriesCalculator classLoaderEntriesCalculator; + + /** + * will add /WEB-INF/lib/*.jar and /WEB-INF/classes from war dependencies in the webappclassloader + * + * @since 2.0 + */ + @Parameter(property = "maven.tomcat.addWarDependenciesInClassloader", defaultValue = "true") + private boolean addWarDependenciesInClassloader; + + /** + * will use the test classpath rather than the compile one and will add test dependencies too + * + * @since 2.0 + */ + @Parameter(property = "maven.tomcat.useTestClasspath", defaultValue = "false") + private boolean useTestClasspath; + + /** + * Additional optional directories to add to the embedded tomcat classpath. + * + * @since 2.0 + */ + @Parameter(alias = "additionalClassesDirs") + private List<String> additionalClasspathDirs; + + + public final File getWarSourceDirectory() + { + return warSourceDirectory; + } + + /** + * {@inheritDoc} + */ + @Override + protected File getDocBase() + throws IOException + { + // https://issues.apache.org/jira/browse/MTOMCAT-239 + // when running a jar docBase doesn't exists so create a fake one + if ( !warSourceDirectory.exists() ) + { + // we create a temporary file in build.directory + final File tempDocBase = createTempDirectory( new File( project.getBuild().getDirectory() ) ); + Runtime.getRuntime().addShutdownHook( new Thread() + { + @Override + public void run() + { + try + { + FileUtils.deleteDirectory( tempDocBase ); + } + catch ( Exception e ) + { + // we can consider as safe to ignore as it's located in build directory + } + } + } ); + return tempDocBase; + } + 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} + */ + @Override + protected File getContextFile() + throws MojoExecutionException + { + File temporaryContextFile = null; + + //---------------------------------------------------------------------------- + // context attributes backgroundProcessorDelay reloadable cannot be modified at runtime. + // It looks only values from the file are used + // so here we create a temporary file with values modified + //---------------------------------------------------------------------------- + FileReader fr = null; + FileWriter fw = null; + StringWriter sw = new StringWriter(); + try + { + temporaryContextFile = File.createTempFile( "tomcat-maven-plugin", "temp-ctx-file" ); + temporaryContextFile.deleteOnExit(); + + // format to modify/create <Context backgroundProcessorDelay="5" reloadable="false"> + if ( contextFile != null && contextFile.exists() ) + { + MavenFileFilterRequest mavenFileFilterRequest = new MavenFileFilterRequest(); + mavenFileFilterRequest.setFrom( contextFile ); + mavenFileFilterRequest.setTo( temporaryContextFile ); + mavenFileFilterRequest.setMavenProject( project ); + mavenFileFilterRequest.setMavenSession( session ); + mavenFileFilterRequest.setFiltering( true ); + + mavenFileFilter.copyFile( mavenFileFilterRequest ); + + fr = new FileReader( temporaryContextFile ); + Xpp3Dom xpp3Dom = Xpp3DomBuilder.build( fr ); + xpp3Dom.setAttribute( "backgroundProcessorDelay", Integer.toString( backgroundProcessorDelay ) ); + xpp3Dom.setAttribute( "reloadable", Boolean.toString( isContextReloadable() ) ); + fw = new FileWriter( temporaryContextFile ); + Xpp3DomWriter.write( fw, xpp3Dom ); + Xpp3DomWriter.write( sw, xpp3Dom ); + getLog().debug( " generated context file " + sw.toString() ); + } + else + { + if ( contextReloadable ) + { + // don't care about using a complicated xml api to create one xml line :-) + StringBuilder sb = new StringBuilder( "<Context " ).append( "backgroundProcessorDelay=\"" ).append( + Integer.toString( backgroundProcessorDelay ) ).append( "\"" ).append( + " reloadable=\"" + Boolean.toString( isContextReloadable() ) + "\"/>" ); + + getLog().debug( " generated context file " + sb.toString() ); + fw = new FileWriter( temporaryContextFile ); + fw.write( sb.toString() ); + } + else + { + // no user context file and contextReloadable false so no need about creating a hack one + return null; + } + } + } + catch ( IOException e ) + { + getLog().error( "error creating fake context.xml : " + e.getMessage(), e ); + throw new MojoExecutionException( "error creating fake context.xml : " + e.getMessage(), e ); + } + catch ( XmlPullParserException e ) + { + getLog().error( "error creating fake context.xml : " + e.getMessage(), e ); + throw new MojoExecutionException( "error creating fake context.xml : " + e.getMessage(), e ); + } + catch ( MavenFilteringException e ) + { + getLog().error( "error filtering context.xml : " + e.getMessage(), e ); + throw new MojoExecutionException( "error filtering context.xml : " + e.getMessage(), e ); + } + finally + { + IOUtil.close( fw ); + IOUtil.close( fr ); + IOUtil.close( sw ); + } + + return temporaryContextFile; + } + + /** + * {@inheritDoc} + * + * @throws MojoExecutionException + */ + @Override + protected WebappLoader createWebappLoader() + throws IOException, MojoExecutionException + { + WebappLoader loader = super.createWebappLoader(); + + if ( useSeparateTomcatClassLoader ) + { + loader.setDelegate( delegate ); + } + + return loader; + } + + @Override + protected void enhanceContext( final Context context ) + throws MojoExecutionException + { + super.enhanceContext( context ); + + try + { + ClassLoaderEntriesCalculatorRequest request = new ClassLoaderEntriesCalculatorRequest() // + .setDependencies( dependencies ) // + .setLog( getLog() ) // + .setMavenProject( project ) // + .setAddWarDependenciesInClassloader( addWarDependenciesInClassloader ) // + .setUseTestClassPath( useTestClasspath ); + ClassLoaderEntriesCalculatorResult classLoaderEntriesCalculatorResult = + classLoaderEntriesCalculator.calculateClassPathEntries( request ); + final List<String> classLoaderEntries = classLoaderEntriesCalculatorResult.getClassPathEntries(); + final List<File> tmpDirectories = classLoaderEntriesCalculatorResult.getTmpDirectories(); + + final List<String> jarPaths = extractJars( classLoaderEntries ); + + Runtime.getRuntime().addShutdownHook( new Thread() + { + @Override + public void run() + { + for ( File tmpDir : tmpDirectories ) + { + try + { + FileUtils.deleteDirectory( tmpDir ); + } + catch ( IOException e ) + { + // ignore + } + } + } + } ); + + if ( classLoaderEntries != null ) + { + WebResourceSet webResourceSet = new FileResourceSet() + { + @Override + public WebResource getResource( String path ) + { + + if ( StringUtils.startsWithIgnoreCase( path, "/WEB-INF/LIB" ) ) + { + File file = new File( StringUtils.removeStartIgnoreCase( path, "/WEB-INF/LIB" ) ); + return new FileResource( context.getResources(), getPath(), file, true ); + } + if ( StringUtils.equalsIgnoreCase( path, "/WEB-INF/classes" ) ) + { + return new FileResource( context.getResources(), getPath(), + new File( project.getBuild().getOutputDirectory() ), true ); + } + + File file = new File( project.getBuild().getOutputDirectory(), path ); + if ( file.exists() ) + { + return new FileResource( context.getResources(), getPath(), file, true ); + } + + if ( StringUtils.endsWith( path, ".class" ) ) + { + // so we search the class file in the jars + for ( String jarPath : jarPaths ) + { + File jar = new File( jarPath ); + if ( !jar.exists() ) + { + continue; + } + + try + { + JarFile jarFile = new JarFile( jar ); + + if ( jarFile.getEntry( StringUtils.removeStart( path, "/" ) ) != null ) + { + return new FileResource( context.getResources(), getPath(), jar, true ); + } + } + catch ( IOException e ) + { + getLog().debug( "skip error building jar file: " + e.getMessage(), e ); + } + + } + } + + return new EmptyResource( null, path ); + } + + @Override + public String[] list( String path ) + { + if ( StringUtils.startsWithIgnoreCase( path, "/WEB-INF/LIB" ) ) + { + return jarPaths.toArray( new String[jarPaths.size()] ); + } + if ( StringUtils.equalsIgnoreCase( path, "/WEB-INF/classes" ) ) + { + return new String[]{ new File( project.getBuild().getOutputDirectory() ).getPath() }; + } + return super.list( path ); + } + + @Override + public Set<String> listWebAppPaths( String path ) + { + + if ( StringUtils.equalsIgnoreCase( "/WEB-INF/lib/", path ) ) + { + // adding outputDirectory as well? + return new HashSet<String>( jarPaths ); + } + + File filePath = new File( getWarSourceDirectory(), path ); + + if ( filePath.isDirectory() ) + { + Set<String> paths = new HashSet<String>(); + + String[] files = filePath.list(); + if ( files == null ) + { + return paths; + } + + for ( String file : files ) + { + paths.add( file ); + } + + return paths; + + } + else + { + return Collections.emptySet(); + } + } + + @Override + public boolean mkdir( String path ) + { + return super.mkdir( path ); + } + + @Override + public boolean write( String path, InputStream is, boolean overwrite ) + { + return super.write( path, is, overwrite ); + } + + @Override + protected void checkType( File file ) + { + //super.checkType( file ); + } + + + }; + + context.getResources().addJarResources( webResourceSet ); + } + + } + catch ( TomcatRunException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + + } + + + /** + * extract List of path which are files (removing directories from the initial list) + * + * @param classLoaderEntries + * @return + */ + private List<String> extractJars( List<String> classLoaderEntries ) + throws MojoExecutionException + { + + List<String> jarPaths = new ArrayList<String>(); + + try + { + for ( String classLoaderEntry : classLoaderEntries ) + { + URI uri = new URI( classLoaderEntry ); + File file = new File( uri ); + if ( !file.isDirectory() ) + { + jarPaths.add( file.getAbsolutePath() ); + } + } + } + catch ( URISyntaxException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + + return jarPaths; + + } +} Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarMojo.java?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarMojo.java (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarMojo.java Tue Aug 16 01:03:14 2016 @@ -0,0 +1,40 @@ +package org.apache.tomcat.maven.plugin.tomcat8.run; + +/* + * 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.maven.plugins.annotations.Execute; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Runs the current project as a packaged web application using an embedded Tomcat server. + * + * @author Mark Hobson <markhob...@gmail.com> + * @todo depend on war:exploded when MNG-1649 resolved + */ +@Mojo( name = "run-war", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) +@Execute( phase = LifecyclePhase.PACKAGE ) +public class RunWarMojo + extends AbstractRunWarMojo +{ + // no-op : only mojo metadata overriding +} Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarMojo.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarOnlyMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarOnlyMojo.java?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarOnlyMojo.java (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarOnlyMojo.java Tue Aug 16 01:03:14 2016 @@ -0,0 +1,36 @@ +package org.apache.tomcat.maven.plugin.tomcat8.run; + +/* + * 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.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Same as run-war goal without forking the package cycle. + * + * @author vlatombe + */ +@Mojo( name = "run-war-only", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) +public class RunWarOnlyMojo + extends AbstractRunWarMojo +{ + // no-op : only mojo metadata overriding +} Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarOnlyMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunWarOnlyMojo.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/ShutdownMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/ShutdownMojo.java?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/ShutdownMojo.java (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/ShutdownMojo.java Tue Aug 16 01:03:14 2016 @@ -0,0 +1,90 @@ +package org.apache.tomcat.maven.plugin.tomcat8.run; + +/* +* 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.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.tomcat.maven.common.run.EmbeddedRegistry; +import org.apache.tomcat.maven.plugin.tomcat8.AbstractTomcat7Mojo; + + +/** + * <p> + * Shuts down all possibly started embedded Tomcat servers. This will be automatically done + * through a shutdown hook or you may call this Mojo to shut them down explictly. + * </p> + * <p> + * By default the <code>shutdown</code> goal is not bound to any phase. For integration tests + * you might want to bind it to <code>post-integration-test</code>. + * </p> + * + * @author Mark Michaelis + * @since 2.0 + */ +@Mojo( name = "shutdown", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) +public class ShutdownMojo + extends AbstractTomcat7Mojo +{ + + /** + * Ignore error when shutdown + * + * @since 2.0 + */ + @Parameter( property = "maven.tomcat.skipErrorOnShutdown", defaultValue = "false" ) + protected boolean skipErrorOnShutdown; + + /** + * Skip execution + * + * @since 2.0 + */ + @Parameter( property = "maven.tomcat.skipShutdown", defaultValue = "false" ) + protected boolean skip; + + /** + * Shuts down all embedded tomcats which got started up to now. + * + * @throws org.apache.maven.plugin.MojoExecutionException + * if shutting down one or all servers failed + */ + public void execute() + throws MojoExecutionException + { + if ( skip ) + { + getLog().info( "skip execution" ); + return; + } + try + { + EmbeddedRegistry.getInstance().shutdownAll( getLog() ); + } + catch ( Exception e ) + { + if ( !skipErrorOnShutdown ) + { + throw new MojoExecutionException( messagesProvider.getMessage( "ShutdownMojo.shutdownError" ), e ); + } + } + } +} Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/ShutdownMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/ShutdownMojo.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarMojo.java?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarMojo.java (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarMojo.java Tue Aug 16 01:03:14 2016 @@ -0,0 +1,36 @@ +package org.apache.tomcat.maven.plugin.tomcat8.run; +/* + * 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.maven.plugins.annotations.Execute; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; + +/** + * This Mojo will create an executable war file with embedded Tomcat that is also capable of being deployed elsewhere. + * + * @since 2.1 + */ +@Mojo(name = "standalone-war", threadSafe = true) +@Execute(phase = LifecyclePhase.PACKAGE) +public class StandaloneWarMojo + extends AbstractStandaloneWarMojo +{ + // no op +} Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarMojo.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarOnlyMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarOnlyMojo.java?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarOnlyMojo.java (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarOnlyMojo.java Tue Aug 16 01:03:14 2016 @@ -0,0 +1,33 @@ +package org.apache.tomcat.maven.plugin.tomcat8.run; +/* + * 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.maven.plugins.annotations.Mojo; + +/** + * This Mojo will create an executable war file with embedded Tomcat that is also capable of being deployed elsewhere. + * + * @since 2.1 + */ +@Mojo(name = "standalone-war-only", threadSafe = true) +public class StandaloneWarOnlyMojo + extends AbstractStandaloneWarMojo +{ + // no op +} Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarOnlyMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/StandaloneWarOnlyMojo.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/WarRunDependency.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/WarRunDependency.java?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/WarRunDependency.java (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/WarRunDependency.java Tue Aug 16 01:03:14 2016 @@ -0,0 +1,43 @@ +package org.apache.tomcat.maven.plugin.tomcat8.run; +/* + * 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.maven.model.Dependency; + +import java.io.File; + +/** + * @author Olivier Lamy + * @since 2.0 + */ +public class WarRunDependency +{ + + public Dependency dependency; + + public String contextPath; + + public File contextXml; + + public WarRunDependency() + { + // no op + } + +} Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/WarRunDependency.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/WarRunDependency.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/Webapp.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/Webapp.java?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/Webapp.java (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/Webapp.java Tue Aug 16 01:03:14 2016 @@ -0,0 +1,44 @@ +package org.apache.tomcat.maven.plugin.tomcat8.run; + +/* + * 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.maven.artifact.Artifact; +import org.apache.tomcat.maven.common.config.AbstractWebapp; + +/** + * Webapp represents information specified in the plugin configuration section + * for each webapp. + * + * @since 2.0 + */ +public class Webapp + extends AbstractWebapp +{ + + public Webapp() + { + // default constructor + } + + public Webapp( Artifact artifact ) + { + super( artifact ); + } +} Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/Webapp.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/Webapp.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/logging.properties URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/logging.properties?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/logging.properties (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/logging.properties Tue Aug 16 01:03:14 2016 @@ -0,0 +1,64 @@ +# 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. + +handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler + +.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler + +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +############################################################ + +1catalina.org.apache.juli.FileHandler.level = FINE +1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +1catalina.org.apache.juli.FileHandler.prefix = catalina. + +2localhost.org.apache.juli.FileHandler.level = FINE +2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +2localhost.org.apache.juli.FileHandler.prefix = localhost. + +3manager.org.apache.juli.FileHandler.level = FINE +3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +3manager.org.apache.juli.FileHandler.prefix = manager. + +4host-manager.org.apache.juli.FileHandler.level = FINE +4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +4host-manager.org.apache.juli.FileHandler.prefix = host-manager. + +java.util.logging.ConsoleHandler.level = FINE +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + + +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler + +# For example, set the org.apache.catalina.util.LifecycleBase logger to log +# each component that extends LifecycleBase changing state: +#org.apache.catalina.util.LifecycleBase.level = FINE + +# To see debug messages in TldLocationsCache, uncomment the following line: +#org.apache.jasper.compiler.TldLocationsCache.level = FINE Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/logging.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/logging.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/tomcat-users.xml URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/tomcat-users.xml?rev=1756441&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/tomcat-users.xml (added) +++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/tomcat-users.xml Tue Aug 16 01:03:14 2016 @@ -0,0 +1,26 @@ +<?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. +--> +<tomcat-users> +<!-- + <role rolename="tomcat"/> + <role rolename="role1"/> + <user username="tomcat" password="tomcat" roles="tomcat"/> + <user username="both" password="tomcat" roles="tomcat,role1"/> + <user username="role1" password="tomcat" roles="role1"/> +--> +</tomcat-users> Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/tomcat-users.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/resources/conf/tomcat-users.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org