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.plugin.MojoFailureException;
25
26 import java.io.File;
27 import java.io.FileOutputStream;
28 import java.io.IOException;
29 import java.io.OutputStream;
30 import java.util.List;
31 import java.util.Properties;
32
33
34
35
36
37
38
39
40
41
42
43 public class ListMojo
44 extends AbstractMojo
45 {
46
47
48
49
50
51
52
53
54 private File reportsFile;
55
56
57
58
59
60
61
62
63 private List reports;
64
65
66
67
68
69
70 public void execute()
71 throws MojoExecutionException, MojoFailureException
72 {
73 Properties reportProperties = new Properties();
74
75 reportProperties.setProperty( "reports", "" + reports.size() );
76
77 for ( int i = 0; i < reports.size(); i++ )
78 {
79 Object report = reports.get( i );
80 getLog().info( "[MAVEN-CORE-IT-LOG] Listing report " + report );
81 reportProperties.setProperty( "reports." + i, report.getClass().getName() );
82 }
83
84 getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + reportsFile );
85
86 OutputStream out = null;
87 try
88 {
89 reportsFile.getParentFile().mkdirs();
90 out = new FileOutputStream( reportsFile );
91 reportProperties.store( out, "MAVEN-CORE-IT-LOG" );
92 }
93 catch ( IOException e )
94 {
95 throw new MojoExecutionException( "Output file could not be created: " + reportsFile, e );
96 }
97 finally
98 {
99 if ( out != null )
100 {
101 try
102 {
103 out.close();
104 }
105 catch ( IOException e )
106 {
107
108 }
109 }
110 }
111
112 getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + reportsFile );
113 }
114
115 }