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 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 import org.apache.maven.shared.model.fileset.FileSet;
27 import org.codehaus.mojo.truezip.internal.DefaultTrueZip;
28 import org.codehaus.mojo.truezip.internal.DefaultTrueZipArchiveDetector;
29
30 import de.schlichtherle.truezip.file.TFile;
31 import de.schlichtherle.truezip.fs.FsSyncException;
32
33 public abstract class AbstractArchiveMojo
34 extends AbstractMojo
35 {
36
37
38
39
40
41
42
43
44 protected MavenProject project;
45
46
47
48
49 protected TrueZip truezip = new DefaultTrueZip();
50
51
52
53
54
55
56
57
58
59 protected boolean immediateUpdate;
60
61
62
63
64
65
66
67 protected boolean skip;
68
69 protected String resolveRelativePath( String path )
70 {
71 if ( path != null && !new TFile( path ).isAbsolute() )
72 {
73 path = new TFile( this.project.getBasedir(), path ).getAbsolutePath();
74 }
75
76 return path;
77 }
78
79 protected void resolveRelativePath( FileSet fileSet )
80 {
81 fileSet.setDirectory( resolveRelativePath( fileSet.getDirectory() ) );
82 fileSet.setOutputDirectory( resolveRelativePath( fileSet.getOutputDirectory() ) );
83 }
84
85 protected void resolveRelativePath( FileItem fileItem )
86 {
87 fileItem.setOutputDirectory( resolveRelativePath( fileItem.getOutputDirectory() ) );
88 fileItem.setSource( resolveRelativePath( fileItem.getSource() ) );
89 }
90
91 protected void tryImmediateUpdate()
92 throws MojoExecutionException
93 {
94
95 if ( immediateUpdate )
96 {
97 try
98 {
99 truezip.sync();
100 }
101 catch ( FsSyncException e )
102 {
103 throw new MojoExecutionException( "Immediate file update failed!", e );
104 }
105 }
106 }
107
108 protected void intitializeArchiveDectector()
109 {
110 DefaultTrueZipArchiveDetector archiveDetector = new DefaultTrueZipArchiveDetector();
111 archiveDetector.init();
112 }
113
114 public void execute()
115 throws MojoExecutionException, MojoFailureException
116 {
117
118
119 }
120 }