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 public class SettingsReadItMojo
38 extends AbstractMojo
39 {
40
41
42
43
44
45 private Settings settings;
46
47
48
49
50
51 private File dumpFile;
52
53 public void execute()
54 throws MojoExecutionException
55 {
56 if ( dumpFile.exists() )
57 {
58 dumpFile.delete();
59 }
60 dumpFile.getParentFile().mkdirs();
61 FileWriter fw = null;
62 try
63 {
64 fw = new FileWriter( dumpFile );
65 SettingsXpp3Writer writer = new SettingsXpp3Writer();
66 writer.write( fw, settings );
67 }
68 catch ( IOException e )
69 {
70 throw new MojoExecutionException( e.getMessage(), e );
71 }
72 finally
73 {
74 IOUtil.close( fw );
75 }
76 }
77
78
79 }