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 import org.apache.maven.project.MavenProject;
26
27 import java.io.File;
28 import java.io.IOException;
29
30
31
32
33
34
35
36
37
38
39 public class JarMojo
40 extends AbstractMojo
41 {
42
43
44
45
46
47
48
49
50 private MavenProject project;
51
52
53
54
55
56
57 private String pathname = "target/javadoc-jar.txt";
58
59
60
61
62
63
64
65 public void execute()
66 throws MojoExecutionException, MojoFailureException
67 {
68 getLog().info( "[MAVEN-CORE-IT-LOG] Using output file path: " + pathname );
69
70 if ( pathname == null || pathname.length() <= 0 )
71 {
72 throw new MojoFailureException( "Path name for output file has not been specified" );
73 }
74
75 File outputFile = new File( pathname );
76 if ( !outputFile.isAbsolute() )
77 {
78 outputFile = new File( project.getBasedir(), pathname ).getAbsoluteFile();
79 }
80
81 getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile );
82
83 try
84 {
85 outputFile.getParentFile().mkdirs();
86 outputFile.createNewFile();
87 }
88 catch ( IOException e )
89 {
90 throw new MojoExecutionException( "Output file could not be created: " + pathname, e );
91 }
92
93 getLog().info( "[MAVEN-CORE-IT-LOG] Created output file: " + outputFile );
94 }
95
96 }