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 import java.io.IOException;
24
25 import org.apache.maven.coreit.component.StatefulSingleton;
26 import org.apache.maven.plugin.AbstractMojo;
27 import org.apache.maven.plugin.MojoExecutionException;
28
29
30
31
32
33
34
35
36
37 public class UpdateSingletonMojo
38 extends AbstractMojo
39 {
40
41
42
43
44 private String key;
45
46
47
48
49 private String value;
50
51
52
53
54 private File propertiesFile;
55
56
57
58
59 private StatefulSingleton singleton;
60
61
62
63
64
65
66 public void execute()
67 throws MojoExecutionException
68 {
69 getLog().info( "[MAVEN-CORE-IT-LOG] Singleton Instance: " + System.identityHashCode( singleton ) );
70 getLog().info( "[MAVEN-CORE-IT-LOG] Singleton Class Loader: " + singleton.getClass().getClassLoader() );
71
72 getLog().info( "[MAVEN-CORE-IT-LOG] Setting property " + key + " = " + value );
73
74 singleton.setProperty( key, value );
75
76 if ( propertiesFile != null )
77 {
78 getLog().info( "[MAVEN-CORE-IT-LOG] Saving properties to " + propertiesFile );
79
80 try
81 {
82 singleton.saveProperties( propertiesFile );
83 }
84 catch ( IOException e )
85 {
86 throw new MojoExecutionException( "Failed to save properties to " + propertiesFile, e );
87 }
88 }
89 }
90
91 }