1 package net.sf.jpkgmk.ant;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 import net.sf.jpkgmk.FileHandler;
7 import net.sf.jpkgmk.PkgMk;
8
9 import org.apache.commons.logging.Log;
10 import org.apache.commons.logging.LogFactory;
11 import org.apache.tools.ant.BuildException;
12 import org.apache.tools.ant.Project;
13 import org.apache.tools.ant.Task;
14
15
16
17
18
19
20
21
22 public class JPkgMkTask extends Task {
23
24
25
26 private static final Log logger = LogFactory.getLog(JPkgMkTask.class);
27
28
29
30
31 private File sourceDir;
32
33
34
35
36 private File targetDir;
37
38
39 public File getSourceDir() {
40 return sourceDir;
41 }
42
43 public void setSourceDir(File sourceDir) {
44 this.sourceDir = sourceDir;
45 }
46
47 public File getTargetDir() {
48 return targetDir;
49 }
50
51 public void setTargetDir(File targetDir) {
52 this.targetDir = targetDir;
53 }
54
55
56
57
58 @Override
59 public void execute() throws BuildException
60 {
61 logger.debug("execute() - start");
62
63 try {
64 log("Creating package from directory " + this.sourceDir, Project.MSG_INFO);
65 PkgMk pkgMk = new PkgMk(this.sourceDir, this.targetDir);
66 pkgMk.create();
67 File tarGzFile = pkgMk.getGzipFile();
68 log("Created package: " + tarGzFile.getAbsolutePath(), Project.MSG_INFO);
69 } catch (IOException e) {
70 throw new BuildException("Exception during package creation", e);
71 }
72 }
73
74 }