You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2005/12/18 05:53:56 UTC
svn commit: r357432 - in /maven/shared/trunk: ./ maven-shared-io/
maven-shared-io/src/ maven-shared-io/src/main/
maven-shared-io/src/main/java/ maven-shared-io/src/main/java/org/
maven-shared-io/src/main/java/org/apache/ maven-shared-io/src/main/java/o...
Author: jdcasey
Date: Sat Dec 17 20:53:37 2005
New Revision: 357432
URL: http://svn.apache.org/viewcvs?rev=357432&view=rev
Log:
Adding shared utilities to scan for stale resources, and provide a common utility for File/URL/ClassLoader-resource conversions. Also adding a shared-domain monitor project, to handle logging without placing a dependency on the mojo apis.
Added:
maven/shared/trunk/maven-shared-io/
maven/shared/trunk/maven-shared-io/pom.xml (with props)
maven/shared/trunk/maven-shared-io/src/
maven/shared/trunk/maven-shared-io/src/main/
maven/shared/trunk/maven-shared-io/src/main/java/
maven/shared/trunk/maven-shared-io/src/main/java/org/
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/Locator.java (with props)
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java (with props)
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java (with props)
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java (with props)
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java (with props)
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java (with props)
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java (with props)
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java (with props)
maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java (with props)
maven/shared/trunk/maven-shared-io/src/test/
maven/shared/trunk/maven-shared-io/src/test/java/
maven/shared/trunk/maven-shared-io/src/test/java/org/
maven/shared/trunk/maven-shared-io/src/test/java/org/apache/
maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/
maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/
maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/
maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/scan/
maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/scan/mapping/
maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java (with props)
maven/shared/trunk/maven-shared-monitor/
maven/shared/trunk/maven-shared-monitor/pom.xml (with props)
maven/shared/trunk/maven-shared-monitor/src/
maven/shared/trunk/maven-shared-monitor/src/main/
maven/shared/trunk/maven-shared-monitor/src/main/java/
maven/shared/trunk/maven-shared-monitor/src/main/java/org/
maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/
maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/
maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/
maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/
maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/AbstractMonitor.java (with props)
maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/BasicMonitor.java (with props)
maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/MojoLogMonitorAdaptor.java (with props)
maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/Monitor.java (with props)
maven/shared/trunk/pom.xml (with props)
Added: maven/shared/trunk/maven-shared-io/pom.xml
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/pom.xml?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/pom.xml (added)
+++ maven/shared/trunk/maven-shared-io/pom.xml Sat Dec 17 20:53:37 2005
@@ -0,0 +1,38 @@
+<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"
+ xsi:noNamespaceSchemaLocation="http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>shared-components-parent</artifactId>
+ <version>1</version>
+ </parent>
+
+ <artifactId>maven-shared-io</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Maven Shared I/O API</name>
+ <description>Basic API for lightweight logging</description>
+
+ <contributors>
+ <contributor>
+ <name>Joakim Erdfelt</name>
+ <email>joakim@erdfelt.com</email>
+ </contributor>
+ </contributors>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-monitor</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/shared/trunk/maven-shared-io/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/Locator.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/Locator.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/Locator.java (added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/Locator.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,140 @@
+package org.apache.maven.shared.io;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.shared.monitor.BasicMonitor;
+import org.apache.maven.shared.monitor.Monitor;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * Performs Locator services for the <code>*Location</code> parameters in the
+ * Reports.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ */
+public class Locator
+{
+ private Monitor monitor;
+
+ /**
+ * Create a Locator object.
+ *
+ * @param logger the logger object to log with.
+ */
+ public Locator( Monitor logger )
+ {
+ this.monitor = logger;
+ }
+
+ /**
+ * Obtain a Log object.
+ *
+ * @return the Log object.
+ */
+ private Monitor getLog()
+ {
+ if ( this.monitor == null )
+ {
+ this.monitor = new BasicMonitor( System.out );
+ }
+ return this.monitor;
+ }
+
+ /**
+ * <p>
+ * Attempts to resolve a location parameter into a real file.
+ * </p>
+ *
+ * <p>
+ * Checks a location string to for a resource, URL, or File that matches.
+ * If a resource or URL is found, then a local file is created with that
+ * locations contents.
+ * </p>
+ *
+ * @param location the location string to match against.
+ * @param localfile the local file to use in case of resource or URL.
+ * @return the File of the resolved location.
+ * @throws IOException if file is unable to be found or copied into <code>localfile</code> destination.
+ */
+ public File resolveLocation( String location, String localfile )
+ throws IOException
+ {
+ getLog().debug( "resolveLocation(" + location + ", " + localfile + ")" );
+ if ( StringUtils.isEmpty( location ) )
+ {
+ return null;
+ }
+
+ File retFile = new File( localfile );
+
+ // Attempt a URL
+ if ( location.indexOf( "://" ) > 1 )
+ {
+ // Found a URL
+ URL url = new URL( location );
+ getLog().debug( "Potential URL: " + url.toExternalForm() );
+ FileUtils.copyURLToFile( url, retFile );
+ }
+ else
+ {
+ getLog().debug( "Location is not a URL." );
+ // Attempt a File.
+ File fileLocation = new File( location );
+ if ( fileLocation.exists() )
+ {
+ // Found a File.
+ getLog().debug( "Potential File: " + fileLocation.getAbsolutePath() );
+ FileUtils.copyFile( fileLocation, retFile );
+ }
+ else
+ {
+ getLog().debug( "Location is not a File." );
+ // Attempt a Resource.
+ URL url = this.getClass().getClassLoader().getResource( location );
+ if ( url != null )
+ {
+ // Found a Resource.
+ getLog().debug( "Potential Resource: " + url.toExternalForm() );
+ FileUtils.copyURLToFile( url, retFile );
+ }
+ else
+ {
+ getLog().debug( "Location is not a Resource." );
+ throw new IOException( "Unable to find location '" + location + "' as URL, File or Resource." );
+ }
+ }
+ }
+
+ if ( !retFile.exists() )
+ {
+ throw new FileNotFoundException( "Destination file does not exist." );
+ }
+
+ if ( retFile.length() <= 0 )
+ {
+ throw new IOException( "Destination file has no content." );
+ }
+
+ return retFile;
+ }
+}
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/Locator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/Locator.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java (added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,82 @@
+package org.apache.maven.shared.io.scan;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.shared.io.scan.mapping.SourceMapping;
+import org.codehaus.plexus.util.DirectoryScanner;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author jdcasey
+ * @version $Id$
+ */
+public abstract class AbstractResourceInclusionScanner
+ implements ResourceInclusionScanner
+{
+ private final List sourceMappings = new ArrayList();
+
+ public final void addSourceMapping( SourceMapping sourceMapping )
+ {
+ sourceMappings.add( sourceMapping );
+ }
+
+ protected final List getSourceMappings()
+ {
+ return Collections.unmodifiableList( sourceMappings );
+ }
+
+ protected String[] scanForSources( File sourceDir, Set sourceIncludes, Set sourceExcludes )
+ {
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setFollowSymlinks( true );
+ ds.setBasedir( sourceDir );
+
+ String[] includes;
+ if ( sourceIncludes.isEmpty() )
+ {
+ includes = new String[0];
+ }
+ else
+ {
+ includes = (String[]) sourceIncludes.toArray( new String[sourceIncludes.size()] );
+ }
+
+ ds.setIncludes( includes );
+
+ String[] excludes;
+ if ( sourceExcludes.isEmpty() )
+ {
+ excludes = new String[0];
+ }
+ else
+ {
+ excludes = (String[]) sourceExcludes.toArray( new String[sourceExcludes.size()] );
+ }
+
+ ds.setExcludes( excludes );
+ ds.addDefaultExcludes();
+
+ ds.scan();
+
+ return ds.getIncludedFiles();
+ }
+}
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java (added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,35 @@
+package org.apache.maven.shared.io.scan;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @author jdcasey
+ * @version $Id$
+ */
+public class InclusionScanException
+ extends Exception
+{
+ public InclusionScanException( String message )
+ {
+ super( message );
+ }
+
+ public InclusionScanException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java (added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,32 @@
+package org.apache.maven.shared.io.scan;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.shared.io.scan.mapping.SourceMapping;
+
+import java.io.File;
+import java.util.Set;
+
+/**
+ * @author jdcasey
+ * @version $Id$
+ */
+public interface ResourceInclusionScanner
+{
+ void addSourceMapping( SourceMapping sourceMapping );
+
+ Set getIncludedSources( File sourceDir, File targetDir )
+ throws InclusionScanException;
+}
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java (added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,52 @@
+package org.apache.maven.shared.io.scan;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.io.File;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
+ * @version $Id$
+ */
+public class SimpleResourceInclusionScanner
+ extends AbstractResourceInclusionScanner
+{
+ private Set sourceIncludes;
+
+ private Set sourceExcludes;
+
+ public SimpleResourceInclusionScanner( Set sourceIncludes, Set sourceExcludes )
+ {
+ this.sourceIncludes = sourceIncludes;
+
+ this.sourceExcludes = sourceExcludes;
+ }
+
+ public Set getIncludedSources( File sourceDir, File targetDir )
+ throws InclusionScanException
+ {
+ List srcMappings = getSourceMappings();
+
+ if ( srcMappings.isEmpty() )
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ return Collections.singleton( scanForSources( sourceDir, sourceIncludes, sourceExcludes ) );
+ }
+}
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java (added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,113 @@
+package org.apache.maven.shared.io.scan;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.shared.io.scan.mapping.SourceMapping;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author jdcasey
+ * @version $Id$
+ */
+public class StaleResourceScanner
+ extends AbstractResourceInclusionScanner
+{
+ private final long lastUpdatedWithinMsecs;
+
+ private final Set sourceIncludes;
+
+ private final Set sourceExcludes;
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ public StaleResourceScanner()
+ {
+ this( 0, Collections.singleton( "**/*" ), Collections.EMPTY_SET );
+ }
+
+ public StaleResourceScanner( long lastUpdatedWithinMsecs )
+ {
+ this( lastUpdatedWithinMsecs, Collections.singleton( "**/*" ), Collections.EMPTY_SET );
+ }
+
+ public StaleResourceScanner( long lastUpdatedWithinMsecs, Set sourceIncludes, Set sourceExcludes )
+ {
+ this.lastUpdatedWithinMsecs = lastUpdatedWithinMsecs;
+
+ this.sourceIncludes = sourceIncludes;
+
+ this.sourceExcludes = sourceExcludes;
+ }
+
+ // ----------------------------------------------------------------------
+ // SourceInclusionScanner Implementation
+ // ----------------------------------------------------------------------
+
+ public Set getIncludedSources( File sourceDir, File targetDir )
+ throws InclusionScanException
+ {
+ List srcMappings = getSourceMappings();
+
+ if ( srcMappings.isEmpty() )
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ String[] potentialIncludes = scanForSources( sourceDir, sourceIncludes, sourceExcludes );
+
+ Set matchingSources = new HashSet();
+
+ for ( int i = 0; i < potentialIncludes.length; i++ )
+ {
+ String path = potentialIncludes[i];
+
+ File sourceFile = new File( sourceDir, path );
+
+ staleSourceFileTesting: for ( Iterator patternIt = srcMappings.iterator(); patternIt.hasNext(); )
+ {
+ SourceMapping mapping = (SourceMapping) patternIt.next();
+
+ Set targetFiles = mapping.getTargetFiles( targetDir, path );
+
+ // never include files that don't have corresponding target mappings.
+ // the targets don't have to exist on the filesystem, but the
+ // mappers must tell us to look for them.
+ for ( Iterator targetIt = targetFiles.iterator(); targetIt.hasNext(); )
+ {
+ File targetFile = (File) targetIt.next();
+
+ if ( !targetFile.exists()
+ || ( targetFile.lastModified() + lastUpdatedWithinMsecs < sourceFile.lastModified() ) )
+ {
+ matchingSources.add( sourceFile );
+ break staleSourceFileTesting;
+ }
+ }
+ }
+ }
+
+ return matchingSources;
+ }
+}
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java (added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,53 @@
+package org.apache.maven.shared.io.scan.mapping;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.shared.io.scan.InclusionScanException;
+
+import java.util.Set;
+import java.util.Collections;
+import java.io.File;
+
+/**
+ * Maps a set of input files to a single output file.
+ *
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
+ * @version $Id$
+ */
+public class SingleTargetMapping
+ implements SourceMapping
+{
+ private String sourceSuffix;
+
+ private String outputFile;
+
+ public SingleTargetMapping( String sourceSuffix, String outputFile )
+ {
+ this.sourceSuffix = sourceSuffix;
+
+ this.outputFile = outputFile;
+ }
+
+ public Set getTargetFiles( File targetDir, String source )
+ throws InclusionScanException
+ {
+ if ( !source.endsWith( sourceSuffix ) )
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ return Collections.singleton( new File( targetDir, outputFile ) );
+ }
+}
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java (added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,32 @@
+package org.apache.maven.shared.io.scan.mapping;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.shared.io.scan.InclusionScanException;
+
+import java.io.File;
+import java.util.Set;
+
+/**
+ * @author jdcasey
+ * @version $Id$
+ */
+public interface SourceMapping
+{
+ Set getTargetFiles( File targetDir, String source )
+ throws InclusionScanException;
+}
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java (added)
+++ maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,68 @@
+package org.apache.maven.shared.io.scan.mapping;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.io.File;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author jdcasey
+ * @version $Id$
+ */
+public final class SuffixMapping
+ implements SourceMapping
+{
+ private final String sourceSuffix;
+
+ private final Set targetSuffixes;
+
+ public SuffixMapping( String sourceSuffix, String targetSuffix )
+ {
+ this.sourceSuffix = sourceSuffix;
+
+ this.targetSuffixes = Collections.singleton( targetSuffix );
+ }
+
+ public SuffixMapping( String sourceSuffix, Set targetSuffixes )
+ {
+ this.sourceSuffix = sourceSuffix;
+
+ this.targetSuffixes = Collections.unmodifiableSet( targetSuffixes );
+ }
+
+ public Set getTargetFiles( File targetDir, String source )
+ {
+ Set targetFiles = new HashSet();
+
+ if ( source.endsWith( sourceSuffix ) )
+ {
+ String base = source.substring( 0, source.length() - sourceSuffix.length() );
+
+ for ( Iterator it = targetSuffixes.iterator(); it.hasNext(); )
+ {
+ String suffix = (String) it.next();
+
+ targetFiles.add( new File( targetDir, base + suffix ) );
+ }
+ }
+
+ return targetFiles;
+ }
+}
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java (added)
+++ maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,119 @@
+package org.apache.maven.shared.io.scan.mapping;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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 junit.framework.TestCase;
+import org.apache.maven.shared.io.scan.InclusionScanException;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author jdcasey
+ */
+public class SuffixMappingTest
+ extends TestCase
+{
+ public void testShouldReturnSingleClassFileForSingleJavaFile()
+ throws InclusionScanException
+ {
+ String base = "path/to/file";
+
+ File basedir = new File( "." );
+
+ SuffixMapping mapping = new SuffixMapping( ".java", ".class" );
+
+ Set results = mapping.getTargetFiles( basedir, base + ".java" );
+
+ assertEquals( "Returned wrong number of target files.", 1, results.size() );
+
+ assertEquals( "Target file is wrong.", new File( basedir, base + ".class" ), results.iterator().next() );
+ }
+
+ public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix()
+ throws InclusionScanException
+ {
+ String base = "path/to/file";
+
+ File basedir = new File( "." );
+
+ SuffixMapping mapping = new SuffixMapping( ".java", ".class" );
+
+ Set results = mapping.getTargetFiles( basedir, base + ".xml" );
+
+ assertTrue( "Returned wrong number of target files.", results.isEmpty() );
+ }
+
+ public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile()
+ throws InclusionScanException
+ {
+ String base = "path/to/file";
+
+ File basedir = new File( "." );
+
+ Set targets = new HashSet();
+ targets.add( ".class" );
+ targets.add( ".xml" );
+
+ SuffixMapping mapping = new SuffixMapping( ".java", targets );
+
+ Set results = mapping.getTargetFiles( basedir, base + ".java" );
+
+ assertEquals( "Returned wrong number of target files.", 2, results.size() );
+
+ assertTrue( "Targets do not contain class target.", results.contains( new File( basedir, base + ".class" ) ) );
+
+ assertTrue( "Targets do not contain class target.", results.contains( new File( basedir, base + ".xml" ) ) );
+ }
+
+ public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix()
+ throws InclusionScanException
+ {
+ String base = "path/to/file";
+
+ File basedir = new File( "." );
+
+ Set targets = new HashSet();
+ targets.add( ".class" );
+ targets.add( ".xml" );
+
+ SuffixMapping mapping = new SuffixMapping( ".java", targets );
+
+ Set results = mapping.getTargetFiles( basedir, base + ".apt" );
+
+ assertTrue( "Returned wrong number of target files.", results.isEmpty() );
+ }
+
+ public void testSingleTargetMapper()
+ throws InclusionScanException
+ {
+ String base = "path/to/file";
+
+ File basedir = new File( "target/" );
+
+ SingleTargetMapping mapping = new SingleTargetMapping( ".cs", "/foo" );
+
+ Set results = mapping.getTargetFiles( basedir, base + ".apt" );
+
+ assertTrue( results.isEmpty() );
+
+ results = mapping.getTargetFiles( basedir, base + ".cs" );
+
+ assertEquals( 1, results.size() );
+ }
+}
Propchange: maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-io/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-monitor/pom.xml
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-monitor/pom.xml?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-monitor/pom.xml (added)
+++ maven/shared/trunk/maven-shared-monitor/pom.xml Sat Dec 17 20:53:37 2005
@@ -0,0 +1,26 @@
+<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"
+ xsi:noNamespaceSchemaLocation="http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>shared-components-parent</artifactId>
+ <version>1</version>
+ </parent>
+
+ <artifactId>maven-shared-monitor</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Maven Shared Monitor API</name>
+ <description>Basic API for lightweight logging</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/shared/trunk/maven-shared-monitor/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-monitor/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/AbstractMonitor.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/AbstractMonitor.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/AbstractMonitor.java (added)
+++ maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/AbstractMonitor.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,150 @@
+package org.apache.maven.shared.monitor;
+
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+public abstract class AbstractMonitor
+ implements Monitor
+{
+
+ private boolean[] levelsEnabled = new boolean[5];
+
+ protected AbstractMonitor()
+ {
+ levelsEnabled[ERROR_LEVEL] = true;
+ }
+
+ protected boolean isEnabled( int messageLevel )
+ {
+ return levelsEnabled[messageLevel];
+ }
+
+ public void setMessageLevel( int messageLevel )
+ {
+ // error level is always enabled
+ for ( int i = 0; i <= messageLevel; i++ )
+ {
+ levelsEnabled[i] = true;
+ }
+
+ for ( int i = messageLevel + 1; i < levelsEnabled.length; i++ )
+ {
+ levelsEnabled[i] = false;
+ }
+ }
+
+ public void setMessageLevelLabel( String messageLevel )
+ {
+ if ( messageLevel == null || messageLevel.trim().length() < 1 )
+ {
+ return;
+ }
+
+ for ( int i = 0; i < MESSAGE_LEVELS.length; i++ )
+ {
+ levelsEnabled[i] = true;
+
+ if ( messageLevel.trim().toLowerCase().equals( MESSAGE_LEVELS[i] ) )
+ {
+ break;
+ }
+ }
+ }
+
+ public int getMessageLevel()
+ {
+ for ( int i = 0; i < levelsEnabled.length; i++ )
+ {
+ if ( !levelsEnabled[i] )
+ {
+ return i - 1;
+ }
+ }
+
+ return 0;
+ }
+
+ public String getMessageLevelLabel()
+ {
+ for ( int i = 0; i < levelsEnabled.length; i++ )
+ {
+ if ( !levelsEnabled[i] )
+ {
+ if ( i == 0 )
+ {
+ return null;
+ }
+ else
+ {
+ return MESSAGE_LEVELS[i - 1];
+ }
+ }
+ }
+
+ return ERROR;
+ }
+
+ public boolean isVerboseEnabled()
+ {
+ return levelsEnabled[VERBOSE_LEVEL];
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return levelsEnabled[DEBUG_LEVEL];
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return levelsEnabled[INFO_LEVEL];
+ }
+
+ public boolean isWarnEnabled()
+ {
+ return levelsEnabled[WARN_LEVEL];
+ }
+
+ public boolean isErrorEnabled()
+ {
+ return levelsEnabled[ERROR_LEVEL];
+ }
+
+ public void setVerboseEnabled( boolean enabled )
+ {
+ this.levelsEnabled[VERBOSE_LEVEL] = enabled;
+ }
+
+ public void setDebugEnabled( boolean enabled )
+ {
+ this.levelsEnabled[DEBUG_LEVEL] = enabled;
+ }
+
+ public void setInfoEnabled( boolean enabled )
+ {
+ this.levelsEnabled[INFO_LEVEL] = enabled;
+ }
+
+ public void setWarnEnabled( boolean enabled )
+ {
+ this.levelsEnabled[WARN_LEVEL] = enabled;
+ }
+
+ public void setErrorEnabled( boolean enabled )
+ {
+ this.levelsEnabled[ERROR_LEVEL] = enabled;
+ }
+
+}
Propchange: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/AbstractMonitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/AbstractMonitor.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/BasicMonitor.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/BasicMonitor.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/BasicMonitor.java (added)
+++ maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/BasicMonitor.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,126 @@
+package org.apache.maven.shared.monitor;
+
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+public class BasicMonitor
+ extends AbstractMonitor
+{
+
+ private PrintStream stream;
+
+ private PrintWriter writer;
+
+ public BasicMonitor( PrintStream stream )
+ {
+ this.stream = stream;
+ }
+
+ public BasicMonitor( PrintWriter writer )
+ {
+ this.writer = writer;
+ }
+
+ private void output( CharSequence message, Throwable error, int messageLevel )
+ {
+ StringWriter sWriter = new StringWriter();
+ PrintWriter pWriter = new PrintWriter( sWriter );
+
+ pWriter.print( "[" );
+ pWriter.print( MESSAGE_LEVELS[messageLevel] );
+ pWriter.print( "] " );
+
+ if ( isEnabled( messageLevel ) )
+ {
+ pWriter.println( message );
+
+ if ( error != null )
+ {
+ error.printStackTrace( pWriter );
+ pWriter.println();
+ }
+ }
+
+ if ( stream != null )
+ {
+ stream.println( sWriter.toString() );
+ }
+ else if ( writer != null )
+ {
+ writer.println( sWriter.toString() );
+ }
+ else
+ {
+ throw new IllegalStateException(
+ "You must either provide a PrintStream or PrinteWriter instance in the constructor of this class." );
+ }
+ }
+
+ public void debug( CharSequence message )
+ {
+ output( message, null, DEBUG_LEVEL );
+ }
+
+ public void debug( CharSequence message, Throwable error )
+ {
+ output( message, error, DEBUG_LEVEL );
+ }
+
+ public void info( CharSequence message )
+ {
+ output( message, null, INFO_LEVEL );
+ }
+
+ public void info( CharSequence message, Throwable error )
+ {
+ output( message, error, INFO_LEVEL );
+ }
+
+ public void warn( CharSequence message )
+ {
+ output( message, null, WARN_LEVEL );
+ }
+
+ public void warn( CharSequence message, Throwable error )
+ {
+ output( message, error, WARN_LEVEL );
+ }
+
+ public void error( CharSequence message )
+ {
+ output( message, null, ERROR_LEVEL );
+ }
+
+ public void error( CharSequence message, Throwable error )
+ {
+ output( message, error, ERROR_LEVEL );
+ }
+
+ public void verbose( CharSequence message )
+ {
+ output( message, null, VERBOSE_LEVEL );
+ }
+
+ public void verbose( CharSequence message, Throwable error )
+ {
+ output( message, error, VERBOSE_LEVEL );
+ }
+
+}
Propchange: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/BasicMonitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/BasicMonitor.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/MojoLogMonitorAdaptor.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/MojoLogMonitorAdaptor.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/MojoLogMonitorAdaptor.java (added)
+++ maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/MojoLogMonitorAdaptor.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,86 @@
+package org.apache.maven.shared.monitor;
+
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.logging.Log;
+
+/**
+ * Adapter class to make a mojo Log instance look like an shared monitor.
+ * This adaptor class is tied to the optional dependency on maven-plugin-api.
+ */
+public class MojoLogMonitorAdaptor
+ extends AbstractMonitor
+{
+
+ private final Log mojoLog;
+
+ public MojoLogMonitorAdaptor( Log mojoLog )
+ {
+ this.mojoLog = mojoLog;
+ }
+
+ public void debug( CharSequence message, Throwable error )
+ {
+ mojoLog.debug( message, error );
+ }
+
+ public void debug( CharSequence message )
+ {
+ mojoLog.debug( message );
+ }
+
+ public void error( CharSequence message, Throwable error )
+ {
+ mojoLog.error( message, error );
+ }
+
+ public void error( CharSequence message )
+ {
+ mojoLog.error( message );
+ }
+
+ public void info( CharSequence message, Throwable error )
+ {
+ mojoLog.info( message, error );
+ }
+
+ public void info( CharSequence message )
+ {
+ mojoLog.info( message );
+ }
+
+ public void warn( CharSequence message, Throwable error )
+ {
+ mojoLog.warn( message, error );
+ }
+
+ public void warn( CharSequence message )
+ {
+ mojoLog.warn( message );
+ }
+
+ public void verbose( CharSequence message )
+ {
+ mojoLog.debug( message );
+ }
+
+ public void verbose( CharSequence message, Throwable error )
+ {
+ mojoLog.debug( message, error );
+ }
+
+}
Propchange: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/MojoLogMonitorAdaptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/MojoLogMonitorAdaptor.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/Monitor.java
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/Monitor.java?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/Monitor.java (added)
+++ maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/Monitor.java Sat Dec 17 20:53:37 2005
@@ -0,0 +1,78 @@
+package org.apache.maven.shared.monitor;
+
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Interface for logging within maven-antcall. CharSequence's are used to avoid the need
+ * to convert StringBuffers to Strings.
+ */
+public interface Monitor
+{
+
+ String VERBOSE = "verbose";
+
+ int VERBOSE_LEVEL = 4;
+
+ String DEBUG = "debug";
+
+ int DEBUG_LEVEL = 3;
+
+ String INFO = "info";
+
+ int INFO_LEVEL = 2;
+
+ String WARN = "warn";
+
+ int WARN_LEVEL = 1;
+
+ String ERROR = "error";
+
+ int ERROR_LEVEL = 0;
+
+ String[] MESSAGE_LEVELS = { ERROR, WARN, INFO, DEBUG, VERBOSE };
+
+ void verbose( CharSequence message );
+
+ void verbose( CharSequence message, Throwable error );
+
+ boolean isVerboseEnabled();
+
+ void debug( CharSequence message );
+
+ void debug( CharSequence message, Throwable error );
+
+ boolean isDebugEnabled();
+
+ void info( CharSequence message );
+
+ void info( CharSequence message, Throwable error );
+
+ boolean isInfoEnabled();
+
+ void warn( CharSequence message );
+
+ void warn( CharSequence message, Throwable error );
+
+ boolean isWarnEnabled();
+
+ void error( CharSequence message );
+
+ void error( CharSequence message, Throwable error );
+
+ boolean isErrorEnabled();
+
+}
Propchange: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/Monitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-shared-monitor/src/main/java/org/apache/maven/shared/monitor/Monitor.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/maven/shared/trunk/pom.xml?rev=357432&view=auto
==============================================================================
--- maven/shared/trunk/pom.xml (added)
+++ maven/shared/trunk/pom.xml Sat Dec 17 20:53:37 2005
@@ -0,0 +1,151 @@
+<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"
+ xsi:noNamespaceSchemaLocation="http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>shared-components-parent</artifactId>
+ <packaging>pom</packaging>
+ <version>1</version>
+ <name>Maven Shared APIs</name>
+ <description>Maven shared-API parent</description>
+ <url>http://maven.apache.org/maven2/shared/</url>
+ <issueManagement>
+ <system>jira</system>
+ <url>http://jira.codehaus.org/browse/MNG</url>
+ </issueManagement>
+ <ciManagement>
+ <system>continuum</system>
+ <notifiers>
+ <notifier>
+ <type>mail</type>
+ <configuration>
+ <address>commits@maven.apache.org</address>
+ </configuration>
+ </notifier>
+ </notifiers>
+ </ciManagement>
+ <developers>
+ <developer>
+ <id>jdcasey</id>
+ <name>John Casey</name>
+ <email>jdcasey@maven.org</email>
+ <organization>ASF</organization>
+ <roles>
+ <role>PMC Member</role>
+ </roles>
+ <timezone>-5</timezone>
+ </developer>
+ </developers>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-alpha-8</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <organization>
+ <name>Apache Software Foundation</name>
+ <url>http://www.apache.org/</url>
+ </organization>
+ <distributionManagement>
+ <snapshotRepository>
+ <id>snapshots</id>
+ <name>Maven Central Plugins Development Repository</name>
+ <url>scpexe://repo1.maven.org/home/projects/maven/repository-staging/snapshots/maven2</url>
+ </snapshotRepository>
+ <repository>
+ <id>repo1</id>
+ <name>Maven Central Plugins Repository</name>
+ <url>scpexe://repo1.maven.org/home/projects/maven/repository-staging/to-ibiblio/maven2</url>
+ </repository>
+ <site>
+ <id>website</id>
+ <url>scp://minotaur.apache.org/www/maven.apache.org/shared/</url>
+ </site>
+ </distributionManagement>
+ <repositories>
+ <repository>
+ <id>snapshots</id>
+ <name>Maven Central Development Repository</name>
+ <url>http://snapshots.maven.codehaus.org/maven2</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshots</id>
+ <name>Maven Central Plugins Development Repository</name>
+ <url>http://snapshots.maven.codehaus.org/maven2</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+ <modules>
+ <module>maven-shared-ant-caller</module>
+ <module>maven-shared-io</module>
+ <module>maven-shared-make-tools</module>
+ <module>maven-shared-monitor</module>
+ <module>maven-shared-rpm-tools</module>
+ </modules>
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/maven/shared/trunk/</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/shared/trunk/</developerConnection>
+ <url>http://svn.apache.org/viewcvs.cgi/maven/shared/trunk/</url>
+ </scm>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <tagBase>https://svn.apache.org/repos/asf/maven/shared/tags</tagBase>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-external</artifactId>
+ <version>1.0-alpha-5</version>
+ </extension>
+ </extensions>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
Propchange: maven/shared/trunk/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"