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.Properties;
29
30
31
32
33
34
35 public class ParameterImplementationMojo
36 extends AbstractMojo
37 {
38
39
40
41
42
43
44 private File outputFile;
45
46
47
48
49
50
51 private AnInterface theParameter;
52
53 public void execute()
54 throws MojoExecutionException
55 {
56 Properties props = new Properties();
57
58 if ( theParameter != null )
59 {
60 getLog().info( "[MAVEN-CORE-IT-LOG] theParameter = " + theParameter );
61
62 props.setProperty( "theParameter.class", theParameter.getClass().getName() );
63 props.setProperty( "theParameter.string", theParameter.toString() );
64 }
65
66 getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + outputFile );
67
68 try
69 {
70 outputFile.getParentFile().mkdirs();
71
72 try ( FileOutputStream os = new FileOutputStream( outputFile ) )
73 {
74 props.store( os, "[MAVEN-CORE-IT-LOG]" );
75 }
76 }
77 catch ( IOException e )
78 {
79 throw new MojoExecutionException( "Failed to create output file " + outputFile + ": " + e.getMessage(), e );
80 }
81
82 getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + outputFile );
83 }
84
85 }