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 PropertyInterpolationMojo
34 extends AbstractMojo
35 {
36
37
38 private MavenProject project;
39
40 public void execute()
41 throws MojoExecutionException
42 {
43 String value = normalize( project.getProperties().getProperty( "myDirectory" ) );
44 String targetValue = normalize( new File( project.getBuild().getDirectory(), "foo" ).getAbsolutePath() );
45
46 if ( !value.equals( targetValue ) )
47 {
48 throw new MojoExecutionException( "Property value of 'myDirectory': " + value + " should equal the 'foo' subpath of the project build directory: " + targetValue );
49 }
50 }
51
52 private String normalize( String src )
53 {
54 return src.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
55 }
56 }