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.project.MavenProject;
25
26 import java.io.File;
27 import java.io.FileInputStream;
28 import java.io.FileOutputStream;
29 import java.io.IOException;
30
31
32
33
34
35
36
37
38 public class CopyPomMojo
39 extends AbstractMojo
40 {
41
42
43
44 private File pomFile;
45
46
47
48
49
50 private String outputFile;
51
52 public void execute()
53 throws MojoExecutionException
54 {
55 try
56 {
57 File dest = new File( outputFile );
58 File dir = dest.getParentFile();
59
60 if ( !dir.exists() )
61 {
62 dir.mkdirs();
63 }
64
65 getLog().info( "Copying POM to file: " + dest.getAbsolutePath() );
66
67 FileInputStream in = new FileInputStream( pomFile );
68 FileOutputStream out = new FileOutputStream( dest );
69
70 int read = -1;
71 byte[] buf = new byte[4096];
72 while( ( read = in.read( buf ) ) > -1 )
73 {
74 out.write( buf, 0, read );
75 }
76
77 in.close();
78 out.close();
79 }
80 catch ( IOException e )
81 {
82 throw new MojoExecutionException( "Error copying POM", e );
83 }
84 }
85 }