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
This commit is contained in:
John Dennis Casey 2008-01-16 23:37:38 +00:00
parent 0c61152546
commit a0827ce0b6
1 changed files with 28 additions and 3 deletions

View File

@ -19,21 +19,25 @@ package org.apache.maven.profiles.activation;
* under the License. * under the License.
*/ */
import java.io.IOException;
import org.apache.maven.model.Activation; import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationFile; import org.apache.maven.model.ActivationFile;
import org.apache.maven.model.Profile; 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.FileUtils;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.util.interpolation.EnvarBasedValueSource;
import org.codehaus.plexus.util.interpolation.MapBasedValueSource; import org.codehaus.plexus.util.interpolation.MapBasedValueSource;
import org.codehaus.plexus.util.interpolation.RegexBasedInterpolator; import org.codehaus.plexus.util.interpolation.RegexBasedInterpolator;
import java.io.IOException;
public class FileProfileActivator public class FileProfileActivator
implements ProfileActivator implements ProfileActivator, LogEnabled
{ {
private Logger logger;
public boolean canDetermineActivation( Profile profile, ProfileActivationContext context ) public boolean canDetermineActivation( Profile profile, ProfileActivationContext context )
{ {
return ( profile.getActivation() != null ) && ( profile.getActivation().getFile() != null ); return ( profile.getActivation() != null ) && ( profile.getActivation().getFile() != null );
@ -64,6 +68,12 @@ public class FileProfileActivator
if ( StringUtils.isNotEmpty( fileString ) ) if ( StringUtils.isNotEmpty( fileString ) )
{ {
fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" );
if ( logger != null )
{
logger.info( "FileProfileActivator: Checking file existence for: " + fileString );
}
return FileUtils.fileExists( fileString ); return FileUtils.fileExists( fileString );
} }
@ -73,10 +83,25 @@ public class FileProfileActivator
if ( StringUtils.isNotEmpty( fileString ) ) if ( StringUtils.isNotEmpty( fileString ) )
{ {
fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" );
if ( logger != null )
{
logger.info( "FileProfileActivator: Checking file is missing for: " + fileString );
}
return !FileUtils.fileExists( fileString ); return !FileUtils.fileExists( fileString );
} }
} }
else if ( logger != null )
{
logger.info( "FileProfileActivator: no file specified. Skipping activation." );
}
return false; return false;
} }
public void enableLogging( Logger logger )
{
this.logger = logger;
}
} }