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 org.apache.maven.plugin.AbstractMojo;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.settings.Settings;
25 import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
26 import org.codehaus.plexus.util.IOUtil;
27
28 import java.io.File;
29 import java.io.FileWriter;
30 import java.io.IOException;
31
32
33
34
35
36
37
38 public class SettingsReadItMojo
39 extends AbstractMojo
40 {
41
42
43
44
45
46 private Settings settings;
47
48
49
50
51
52 private File dumpFile;
53
54 public void execute()
55 throws MojoExecutionException
56 {
57 if ( dumpFile.exists() )
58 {
59 dumpFile.delete();
60 }
61 dumpFile.getParentFile().mkdirs();
62 FileWriter fw = null;
63 try
64 {
65 fw = new FileWriter( dumpFile );
66 SettingsXpp3Writer writer = new SettingsXpp3Writer();
67 writer.write( fw, settings );
68 }
69 catch ( IOException e )
70 {
71 throw new MojoExecutionException( e.getMessage(), e );
72 }
73 finally
74 {
75 IOUtil.close( fw );
76 }
77 }
78
79
80 }