1 package org.apache.maven.plugin.resources;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.project.MavenProject;
23 import org.codehaus.plexus.util.StringUtils;
24 import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
25
26 import java.util.Properties;
27
28
29
30
31
32
33
34 public class ReflectionProperties
35 extends Properties
36 {
37
38 private MavenProject project;
39
40 private boolean escapedBackslashesInFilePath;
41
42 public ReflectionProperties( MavenProject aProject, boolean escapedBackslashesInFilePath )
43 {
44 super();
45
46 project = aProject;
47
48 this.escapedBackslashesInFilePath = escapedBackslashesInFilePath;
49 }
50
51 public Object get( Object key )
52 {
53 Object value = null;
54 try
55 {
56 value = ReflectionValueExtractor.evaluate( "" + key, project );
57
58 if ( escapedBackslashesInFilePath && ( value instanceof String ) )
59 {
60 String val = (String) value;
61
62
63 if ( val.indexOf( ":\\" ) == 1 )
64 {
65 value = StringUtils.replace( (String) value, "\\", "\\\\" );
66 value = StringUtils.replace( (String) value, ":", "\\:" );
67 }
68 }
69 }
70 catch ( Exception e )
71 {
72
73 }
74 return value;
75 }
76 }