1 package org.apache.maven.plugin.coreit;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.apache.maven.plugin.AbstractMojo;
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.project.MavenProject;
27
28
29
30
31
32
33 public class PluginParamInterpolationMojo
34 extends AbstractMojo
35 {
36
37 private String myDirectory;
38
39
40 private MavenProject project;
41
42 public void execute()
43 throws MojoExecutionException
44 {
45 myDirectory = normalize( myDirectory );
46 String value = normalize( new File( project.getBuild().getDirectory(), "foo" ).getAbsolutePath() );
47
48 if ( !myDirectory.equals( value ) )
49 {
50 throw new MojoExecutionException( "Directory supplied: " + myDirectory + " is not the same as the project build directory: " + project.getBuild().getDirectory() + " + '/foo'" );
51 }
52 }
53
54 private String normalize( String src )
55 {
56 return src.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
57 }
58 }