You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2014/03/29 14:36:56 UTC
git commit: MNG-5608: warn if file-based profile activation uses
${project.basedir} since only ${basedir} is supported
Repository: maven
Updated Branches:
refs/heads/master a74893f24 -> 06a7d6dd8
MNG-5608: warn if file-based profile activation uses ${project.basedir} since only ${basedir} is supported
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/06a7d6dd
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/06a7d6dd
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/06a7d6dd
Branch: refs/heads/master
Commit: 06a7d6dd8b0d50bc1d13e4e2918c567a70ed2f6f
Parents: a74893f
Author: Robert Scholte <rf...@codehaus.org>
Authored: Sat Mar 29 14:36:14 2014 +0100
Committer: Robert Scholte <rf...@codehaus.org>
Committed: Sat Mar 29 14:36:14 2014 +0100
----------------------------------------------------------------------
.../activation/FileProfileActivator.java | 9 +---
.../model/validation/DefaultModelValidator.java | 56 ++++++++++++++++++++
2 files changed, 57 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/06a7d6dd/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java
index 2c4eb27..c6d873a 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java
@@ -47,6 +47,7 @@ import org.codehaus.plexus.util.StringUtils;
*
* @author Benjamin Bentmann
* @see ActivationFile
+ * @see org.apache.maven.model.validation.DefaultModelValidator#validateRawModel(org.apache.maven.model.Model, org.apache.maven.model.building.ModelBuildingRequest, ModelProblemCollector)
*/
@Component( role = ProfileActivator.class, hint = "file" )
public class FileProfileActivator
@@ -117,14 +118,6 @@ public class FileProfileActivator
return null;
}
} );
-
- if ( path.contains( "${project.basedir}" ) )
- {
- problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.BASE )
- .setMessage( "Failed to interpolate file location " + path + " for profile " + profile.getId() + ": ${project.basedir} expression not supported during profile activation, use ${basedir} instead" )
- .setLocation( file.getLocation( missing ? "missing" : "exists" ) ) );
- }
-
}
else if ( path.contains( "${basedir}" ) )
{
http://git-wip-us.apache.org/repos/asf/maven/blob/06a7d6dd/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
index beb3ec2..c5560f9 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
@@ -28,6 +28,8 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
+import org.apache.maven.model.Activation;
+import org.apache.maven.model.ActivationFile;
import org.apache.maven.model.Build;
import org.apache.maven.model.BuildBase;
import org.apache.maven.model.Dependency;
@@ -154,6 +156,8 @@ public class DefaultModelValidator
"must be unique but found duplicate profile with id " + profile.getId(), profile );
}
+ validate30RawProfileActivation( problems, profile.getActivation(), profile.getId(), prefix + ".activation", request );
+
validate20RawDependencies( problems, profile.getDependencies(), prefix + ".dependencies.dependency",
request );
@@ -185,6 +189,53 @@ public class DefaultModelValidator
}
}
+ private void validate30RawProfileActivation( ModelProblemCollector problems, Activation activation,
+ String sourceHint, String prefix, ModelBuildingRequest request )
+ {
+ if ( activation == null )
+ {
+ return;
+ }
+
+ ActivationFile file = activation.getFile();
+
+ if ( file != null )
+ {
+ String path;
+ boolean missing;
+
+ if ( StringUtils.isNotEmpty( file.getExists() ) )
+ {
+ path = file.getExists();
+ missing = false;
+ }
+ else if ( StringUtils.isNotEmpty( file.getMissing() ) )
+ {
+ path = file.getMissing();
+ missing = true;
+ }
+ else
+ {
+ return;
+ }
+
+ if ( hasProjectExpression( path ) )
+ {
+ addViolation( problems,
+ Severity.WARNING,
+ Version.V30,
+ prefix + ( missing ? ".file.missing" : ".file.exists" ),
+ null,
+ "Failed to interpolate file location "
+ + path
+ + " for profile "
+ + sourceHint
+ + ": ${project.basedir} expression not supported during profile activation, use ${basedir} instead",
+ file.getLocation( missing ? "missing" : "exists" ) );
+ }
+ }
+ }
+
private void validate20RawPlugins( ModelProblemCollector problems, List<Plugin> plugins, String prefix,
ModelBuildingRequest request )
{
@@ -718,6 +769,11 @@ public class DefaultModelValidator
return value != null && value.contains( "${" );
}
+ private boolean hasProjectExpression( String value )
+ {
+ return value != null && value.contains( "${project." );
+ }
+
private boolean validateStringNotEmpty( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
String string, InputLocationTracker tracker )
{