From a0827ce0b63355f11f3fb1afc40420aa92d48d0d Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Wed, 16 Jan 2008 23:37:38 +0000 Subject: [PATCH] Adding logging for FileProfileActivator, to debug the build. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@612629 13f79535-47bb-0310-9956-ffa450edef68 --- .../activation/FileProfileActivator.java | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java b/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java index 7919185496..08bed00086 100644 --- a/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java +++ b/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java @@ -19,21 +19,25 @@ package org.apache.maven.profiles.activation; * under the License. */ -import java.io.IOException; - import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationFile; import org.apache.maven.model.Profile; +import org.codehaus.plexus.logging.LogEnabled; +import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.util.interpolation.MapBasedValueSource; import org.codehaus.plexus.util.interpolation.RegexBasedInterpolator; +import java.io.IOException; + public class FileProfileActivator - implements ProfileActivator + implements ProfileActivator, LogEnabled { + private Logger logger; + public boolean canDetermineActivation( Profile profile, ProfileActivationContext context ) { return ( profile.getActivation() != null ) && ( profile.getActivation().getFile() != null ); @@ -64,6 +68,12 @@ public class FileProfileActivator if ( StringUtils.isNotEmpty( fileString ) ) { fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); + + if ( logger != null ) + { + logger.info( "FileProfileActivator: Checking file existence for: " + fileString ); + } + return FileUtils.fileExists( fileString ); } @@ -73,10 +83,25 @@ public class FileProfileActivator if ( StringUtils.isNotEmpty( fileString ) ) { fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); + + if ( logger != null ) + { + logger.info( "FileProfileActivator: Checking file is missing for: " + fileString ); + } + return !FileUtils.fileExists( fileString ); } } + else if ( logger != null ) + { + logger.info( "FileProfileActivator: no file specified. Skipping activation." ); + } return false; } + + public void enableLogging( Logger logger ) + { + this.logger = logger; + } }