You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/12/02 18:05:13 UTC
svn commit: r722525 - in
/maven/core-integration-testing/trunk/core-it-support/core-it-plugins: ./
maven-it-plugin-log-file/ maven-it-plugin-log-file/src/
maven-it-plugin-log-file/src/main/ maven-it-plugin-log-file/src/main/java/
maven-it-plugin-log-fi...
Author: bentmann
Date: Tue Dec 2 09:05:12 2008
New Revision: 722525
URL: http://svn.apache.org/viewvc?rev=722525&view=rev
Log:
o Added new IT plugin to verify multi goal executions scenarios
Added:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/ (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/pom.xml (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogStringMojo.java (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/ResetMojo.java (with props)
Modified:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Dec 2 09:05:12 2008
@@ -0,0 +1,7 @@
+target
+*.iml
+.classpath
+.project
+.settings
+target-eclipse
+bin
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/pom.xml?rev=722525&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/pom.xml Tue Dec 2 09:05:12 2008
@@ -0,0 +1,52 @@
+<?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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>maven-it-plugins</artifactId>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <version>2.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-it-plugin-log-file</artifactId>
+ <packaging>maven-plugin</packaging>
+
+ <name>Maven Integration Test Plugin :: Log File</name>
+ <description>
+ A test plugin that appends lines to a UTF-8 encoded log file. Apparently, the order of log lines allows to check
+ the order in which the plugin's goals were executed.
+ </description>
+ <inceptionYear>2008</inceptionYear>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java?rev=722525&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java Tue Dec 2 09:05:12 2008
@@ -0,0 +1,153 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
+/**
+ * Provides common services for the mojos of this plugin.
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public abstract class AbstractLogMojo
+ extends AbstractMojo
+{
+
+ /**
+ * The project's base directory, used for manual path translation.
+ *
+ * @parameter default-value="${basedir}"
+ * @readonly
+ */
+ private File basedir;
+
+ /**
+ * The path to the output file, relative to the current working directory.
+ *
+ * @parameter expression="${log.logFile}" default-value="target/it.log" alias="outputFile"
+ */
+ private File logFile;
+
+ /**
+ * The character encoding of the log file.
+ */
+ private String encoding = "UTF-8";
+
+ /**
+ * Gets the absolute path to the log file.
+ *
+ * @return The absolute path to the log file, never <code>null</code>.
+ */
+ private File getLogFile()
+ {
+ /*
+ * NOTE: We don't want to test path translation here.
+ */
+ return logFile.isAbsolute() ? logFile : new File( basedir, logFile.getPath() );
+ }
+
+ /**
+ * Appends the string representation of the specified object to the log file. Logging <code>null</code> has no other
+ * effect than touching the file. For each value different from <code>null</code>, a line terminator will be
+ * appended to the value's string representation.
+ *
+ * @param value The object to log, may be <code>null</code>.
+ * @throws MojoExecutionException If the log file could not be updated.
+ */
+ protected void append( Object value )
+ throws MojoExecutionException
+ {
+ File file = getLogFile();
+ getLog().info( "[MAVEN-CORE-IT-LOG] Updating log file: " + file );
+ getLog().info( "[MAVEN-CORE-IT-LOG] " + value );
+ try
+ {
+ file.getParentFile().mkdirs();
+ OutputStream out = new FileOutputStream( file, true );
+ try
+ {
+ BufferedWriter writer = new BufferedWriter( new OutputStreamWriter( out, encoding ) );
+ if ( value != null )
+ {
+ writer.write( value.toString() );
+ writer.newLine();
+ writer.flush();
+ }
+ }
+ finally
+ {
+ try
+ {
+ out.close();
+ }
+ catch ( IOException e )
+ {
+ // just ignore, we tried our best to clean up
+ }
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Failed to update log file " + logFile, e );
+ }
+ }
+
+ /**
+ * Clears the contents of the log file by creating a new empty log file.
+ *
+ * @throws MojoExecutionException If the log file could not be reset.
+ */
+ protected void reset()
+ throws MojoExecutionException
+ {
+ File file = getLogFile();
+ getLog().info( "[MAVEN-CORE-IT-LOG] Resetting log file: " + file );
+ try
+ {
+ /*
+ * NOTE: Intentionally don't delete the file but create a new empty one to check the plugin was executed.
+ */
+ file.getParentFile().mkdirs();
+ OutputStream out = new FileOutputStream( file );
+ try
+ {
+ out.close();
+ }
+ catch ( IOException e )
+ {
+ // just ignore, we tried our best to clean up
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Failed to reset log file " + logFile, e );
+ }
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/AbstractLogMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java?rev=722525&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java Tue Dec 2 09:05:12 2008
@@ -0,0 +1,60 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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;
+
+/**
+ * Appends a separator line to the log file.
+ *
+ * @goal log-separator
+ * @phase initialize
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class LogSeparatorMojo
+ extends AbstractLogMojo
+{
+
+ /**
+ * The length of the separator line.
+ *
+ * @parameter expression="${log.length}" default-value="80"
+ */
+ private int length;
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoExecutionException If the output file could not be created.
+ */
+ public void execute()
+ throws MojoExecutionException
+ {
+ StringBuffer buffer = new StringBuffer( length );
+ for ( int i = 0; i < length; i++ )
+ {
+ buffer.append( '-' );
+ }
+ append( buffer.toString() );
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogStringMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogStringMojo.java?rev=722525&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogStringMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogStringMojo.java Tue Dec 2 09:05:12 2008
@@ -0,0 +1,55 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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;
+
+/**
+ * Appends a string to the log file.
+ *
+ * @goal log-string
+ * @phase initialize
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class LogStringMojo
+ extends AbstractLogMojo
+{
+
+ /**
+ * The string to append to the log file.
+ *
+ * @parameter expression="${log.string}"
+ */
+ private String string;
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoExecutionException If the output file could not be created.
+ */
+ public void execute()
+ throws MojoExecutionException
+ {
+ append( string );
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogStringMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogStringMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/ResetMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/ResetMojo.java?rev=722525&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/ResetMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/ResetMojo.java Tue Dec 2 09:05:12 2008
@@ -0,0 +1,48 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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;
+
+/**
+ * Appends a string to the log file.
+ *
+ * @goal reset
+ * @phase initialize
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class ResetMojo
+ extends AbstractLogMojo
+{
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoExecutionException If the output file could not be created.
+ */
+ public void execute()
+ throws MojoExecutionException
+ {
+ reset();
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/ResetMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/ResetMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml?rev=722525&r1=722524&r2=722525&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml Tue Dec 2 09:05:12 2008
@@ -44,6 +44,7 @@
<module>maven-it-plugin-expression</module>
<module>maven-it-plugin-file</module>
<module>maven-it-plugin-fork</module>
+ <module>maven-it-plugin-log-file</module>
<module>maven-it-plugin-no-project</module>
<module>maven-it-plugin-packaging</module>
<module>maven-it-plugin-parameter-implementation</module>