mirror of
https://github.com/apache/maven.git
synced 2025-02-08 19:15:12 +00:00
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 @@
|
|||||||
* limitations under the License.
|
* 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.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
@ -38,10 +39,17 @@ public class PluginParamInterpolationMojo
|
|||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
|
myDirectory = normalize( myDirectory );
|
||||||
if ( !myDirectory.equals( project.getBuild().getDirectory() + "/foo" ) )
|
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'" );
|
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 @@
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
@ -32,25 +31,23 @@ public class PropertyInterpolationMojo
|
|||||||
extends AbstractMojo
|
extends AbstractMojo
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final char FS = File.separatorChar;
|
|
||||||
|
|
||||||
/** @parameter */
|
|
||||||
private String myDirectory;
|
|
||||||
|
|
||||||
/** @parameter expression="${project}" */
|
/** @parameter expression="${project}" */
|
||||||
private MavenProject project;
|
private MavenProject project;
|
||||||
|
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
String value = project.getProperties().getProperty( "myDirectory" ).replace( '/', FS ).replace( '\\', FS );
|
String value = normalize( project.getProperties().getProperty( "myDirectory" ) );
|
||||||
|
String targetValue = normalize( new File( project.getBuild().getDirectory(), "foo" ).getAbsolutePath() );
|
||||||
String targetValue = project.getBuild().getDirectory() + FS + "foo";
|
|
||||||
targetValue = targetValue.replace( '/', FS).replace( '\\', FS );
|
|
||||||
|
|
||||||
if ( !value.equals( targetValue ) )
|
if ( !value.equals( targetValue ) )
|
||||||
{
|
{
|
||||||
throw new MojoExecutionException( "Property value of 'myDirectory': " + value + " should equal the 'foo' subpath of the project build directory: " + 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;
|
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.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.project.MavenProject;
|
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
|
* @goal verify-property
|
||||||
@ -23,11 +20,6 @@ public class PropertyInterpolationVerifierMojo extends AbstractMojo {
|
|||||||
*/
|
*/
|
||||||
private MavenProject project;
|
private MavenProject project;
|
||||||
|
|
||||||
/**
|
|
||||||
* @parameter expression="${buildSourceDirectory}"
|
|
||||||
*/
|
|
||||||
private File buildSourceDirectory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @parameter expression="${properties}"
|
* @parameter expression="${properties}"
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user