mirror of https://github.com/apache/maven.git
Improve normalization of file separators for checking values.
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@678938 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
704f78ac59
commit
7be3537e0f
|
@ -16,7 +16,8 @@ package org.apache.maven.plugin.coreit;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
@ -38,10 +39,17 @@ public class PluginParamInterpolationMojo
|
|||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
|
||||
if ( !myDirectory.equals( project.getBuild().getDirectory() + "/foo" ) )
|
||||
myDirectory = normalize( myDirectory );
|
||||
String value = normalize( new File( project.getBuild().getDirectory(), "foo" ).getAbsolutePath() );
|
||||
|
||||
if ( !myDirectory.equals( value ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Directory supplied: " + myDirectory + " is not the same as the project build directory: " + project.getBuild().getDirectory() + " + '/foo'" );
|
||||
}
|
||||
}
|
||||
|
||||
private String normalize( String src )
|
||||
{
|
||||
return src.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.maven.plugin.coreit;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
@ -32,25 +31,23 @@ public class PropertyInterpolationMojo
|
|||
extends AbstractMojo
|
||||
{
|
||||
|
||||
private static final char FS = File.separatorChar;
|
||||
|
||||
/** @parameter */
|
||||
private String myDirectory;
|
||||
|
||||
/** @parameter expression="${project}" */
|
||||
private MavenProject project;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
String value = project.getProperties().getProperty( "myDirectory" ).replace( '/', FS ).replace( '\\', FS );
|
||||
|
||||
String targetValue = project.getBuild().getDirectory() + FS + "foo";
|
||||
targetValue = targetValue.replace( '/', FS).replace( '\\', FS );
|
||||
String value = normalize( project.getProperties().getProperty( "myDirectory" ) );
|
||||
String targetValue = normalize( new File( project.getBuild().getDirectory(), "foo" ).getAbsolutePath() );
|
||||
|
||||
if ( !value.equals( targetValue ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Property value of 'myDirectory': " + value + " should equal the 'foo' subpath of the project build directory: " + targetValue );
|
||||
}
|
||||
}
|
||||
|
||||
private String normalize( String src )
|
||||
{
|
||||
return src.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package org.apache.maven.plugin.coreit;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* @goal verify-property
|
||||
|
@ -23,11 +20,6 @@ public class PropertyInterpolationVerifierMojo extends AbstractMojo {
|
|||
*/
|
||||
private MavenProject project;
|
||||
|
||||
/**
|
||||
* @parameter expression="${buildSourceDirectory}"
|
||||
*/
|
||||
private File buildSourceDirectory;
|
||||
|
||||
/**
|
||||
* @parameter expression="${properties}"
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue