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