1 package org.codehaus.mojo.truezip;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Iterator;
23
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.codehaus.plexus.util.StringUtils;
27
28 import de.schlichtherle.truezip.file.TFile;
29
30
31
32
33
34
35
36
37 public class MoveMojo
38 extends AbstractManipulateArchiveMojo
39 {
40
41
42
43
44
45
46 private String from;
47
48
49
50
51
52
53
54 private String to;
55
56 public void execute()
57 throws MojoExecutionException, MojoFailureException
58 {
59
60 if ( skip )
61 {
62 this.getLog().info( "Skip this execution" );
63 return;
64 }
65
66 super.execute();
67
68 intitializeArchiveDectector();
69
70 if ( !StringUtils.isBlank( from ) )
71 {
72 TFile file = new TFile( this.resolveRelativePath( from ) );
73
74 if ( StringUtils.isBlank( from ) )
75 {
76 throw new MojoExecutionException(
77 "You have specified 'from' configuration to perform the move, but 'to' configuration is not available. " );
78 }
79
80 TFile tofile = new TFile( this.resolveRelativePath( to ) );
81
82 try
83 {
84 this.truezip.moveFile( file, tofile );
85 }
86 catch ( Exception e )
87 {
88 throw new MojoExecutionException( "Move file fails", e );
89 }
90 }
91
92 if ( this.fileset != null )
93 {
94 this.filesets.add( this.fileset );
95 this.fileset = null;
96 }
97
98 for ( Iterator<Fileset> it = filesets.iterator(); it.hasNext(); )
99 {
100 Fileset oneFileSet = (Fileset) it.next();
101
102 try
103 {
104 this.resolveRelativePath( oneFileSet );
105 this.truezip.move( oneFileSet );
106 }
107 catch ( Exception e )
108 {
109 throw new MojoExecutionException( "Move fileset fails", e );
110 }
111
112 }
113
114 this.tryImmediateUpdate();
115
116 }
117 }