1 package org.codehaus.mojo.properties;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Enumeration;
23 import java.util.Properties;
24
25 import org.apache.maven.plugin.AbstractMojo;
26 import org.apache.maven.plugin.MojoExecutionException;
27 import org.apache.maven.plugin.MojoFailureException;
28
29
30
31
32
33
34
35
36
37 public class SetSystemPropertiesMojo
38 extends AbstractMojo
39 {
40
41
42
43
44
45
46
47
48 private Properties properties;
49
50
51
52
53
54
55 public void execute()
56 throws MojoExecutionException, MojoFailureException
57 {
58 if ( properties.isEmpty() )
59 {
60 getLog().debug( "No system properties found" );
61
62 return;
63 }
64
65 getLog().debug( "Setting system properties:" );
66
67 for ( Enumeration propertyNames = properties.propertyNames(); propertyNames.hasMoreElements(); )
68 {
69 String propertyName = propertyNames.nextElement().toString();
70 String propertyValue = properties.getProperty( propertyName );
71
72 getLog().debug( "- " + propertyName + " = " + propertyValue );
73
74 System.setProperty( propertyName, propertyValue );
75 }
76
77 int count = properties.size();
78
79 getLog().info( "Set " + count + " system " + ( count > 1 ? "properties" : "property" ) );
80 }
81 }