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 4f74d828fe..58960df001 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 @@ -69,13 +69,14 @@ public class FileProfileActivator { fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); - System.out.println( "FileProfileActivator: Checking file existence for: " + fileString + ". Result: " + FileUtils.fileExists( fileString ) ); + boolean result = FileUtils.fileExists( fileString ); + if ( logger != null ) { - logger.info( "FileProfileActivator: Checking file existence for: " + fileString ); + logger.debug( "FileProfileActivator: Checking file existence for: " + fileString + ". Result: " + result ); } - return FileUtils.fileExists( fileString ); + return result; } // check if the file is missing, if it is then the profile will be active @@ -85,21 +86,21 @@ public class FileProfileActivator { fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); - System.out.println( "FileProfileActivator: Checking file is missing for: " + fileString + ". Result: " + (!FileUtils.fileExists( fileString )) ); + boolean result = !FileUtils.fileExists( fileString ); + if ( logger != null ) { - logger.info( "FileProfileActivator: Checking file is missing for: " + fileString ); + logger.debug( "FileProfileActivator: Checking file is missing for: " + fileString + ". Result: " + result ); } - return !FileUtils.fileExists( fileString ); + return result; } } else { - System.out.println( "FileProfileActivator: no file specified. Skipping activation." ); if ( logger != null ) { - logger.info( "FileProfileActivator: no file specified. Skipping activation." ); + logger.debug( "FileProfileActivator: no file specified. Skipping activation." ); } } diff --git a/maven-project/src/test/java/org/apache/maven/profiles/activation/FileProfileActivatorTest.java b/maven-project/src/test/java/org/apache/maven/profiles/activation/FileProfileActivatorTest.java index d445fac1a8..08c5fdf6c8 100644 --- a/maven-project/src/test/java/org/apache/maven/profiles/activation/FileProfileActivatorTest.java +++ b/maven-project/src/test/java/org/apache/maven/profiles/activation/FileProfileActivatorTest.java @@ -19,13 +19,13 @@ package org.apache.maven.profiles.activation; * under the License. */ +import org.apache.maven.model.Activation; +import org.apache.maven.model.Profile; + import java.util.Properties; import junit.framework.TestCase; -import org.apache.maven.model.Activation; -import org.apache.maven.model.Profile; - /** * Test case for the {@link FileProfileActivator}. * @@ -41,8 +41,18 @@ public class FileProfileActivatorTest throws ProfileActivationException { org.apache.maven.model.ActivationFile activationFile = new org.apache.maven.model.ActivationFile(); + + // make an educated guess at the repository location... + String repoLocation = System.getProperty( "maven.repo.local", "${user.home}/.m2/repository" ); + + repoLocation = repoLocation.replace( '\\', '/' ); + if ( repoLocation.endsWith( "/" ) ) + { + repoLocation = repoLocation.substring( 0, repoLocation.length() - 1 ); + } + // Assume that junit exists - activationFile.setExists( "${user.home}/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar" ); + activationFile.setExists( repoLocation + "/junit/junit/3.8.1/junit-3.8.1.jar" ); Activation fileActivation = new Activation(); fileActivation.setFile( activationFile );