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
25 import java.io.File;
26 import java.io.FileOutputStream;
27 import java.io.IOException;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.Properties;
31
32
33
34
35
36
37
38
39
40 public class ItMojo
41 extends AbstractMojo
42 {
43
44
45
46
47
48
49 private File outputFile;
50
51
52
53
54
55
56 private Component componentWithoutRoleHint;
57
58
59
60
61
62
63 private Component componentWithRoleHint;
64
65
66
67
68
69
70 private Map componentMap;
71
72
73
74
75
76
77 private List componentList;
78
79
80
81
82
83
84 public void execute()
85 throws MojoExecutionException
86 {
87 Component componentFromMap = (Component) componentMap.values().iterator().next();
88 Component componentFromList = (Component) componentList.iterator().next();
89
90 getLog().info( "[MAVEN-CORE-IT-LOG] Using component: " + componentWithoutRoleHint );
91 getLog().info( "[MAVEN-CORE-IT-LOG] Using component: " + componentWithRoleHint );
92 getLog().info( "[MAVEN-CORE-IT-LOG] Using component: " + componentFromMap );
93 getLog().info( "[MAVEN-CORE-IT-LOG] Using component: " + componentFromList );
94
95 Properties props = new Properties();
96 props.setProperty( "id.0", componentWithoutRoleHint.getId() );
97 props.setProperty( "id.1", componentWithRoleHint.getId() );
98 props.setProperty( "id.2", componentFromMap.getId() );
99 props.setProperty( "id.3", componentFromList.getId() );
100
101 getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile );
102
103 try
104 {
105 outputFile.getParentFile().mkdirs();
106 try ( FileOutputStream os = new FileOutputStream( outputFile ) )
107 {
108 props.store( os, "MAVEN-CORE-IT-LOG" );
109 }
110 }
111 catch ( IOException e )
112 {
113 throw new MojoExecutionException( "Output file could not be created: " + outputFile, e );
114 }
115
116 getLog().info( "[MAVEN-CORE-IT-LOG] Created output file: " + outputFile );
117 }
118
119 }