Skip to content

Commit c7ee88c

Browse files
committed
added initial ant ask
1 parent 8fb9517 commit c7ee88c

File tree

4 files changed

+85
-16
lines changed

4 files changed

+85
-16
lines changed

build.xml

+19
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
destdir="build/classes"
1818
>
1919
</javac>
20+
<copy todir='build/classes'>
21+
<fileset dir='src'>
22+
<include name='**/*.plist'/>
23+
<include name='**/JavaApplicationStub'/>
24+
<include name='**/*.txt'/>
25+
</fileset>
26+
</copy>
2027
</target>
2128

2229
<target name="clean">
@@ -50,6 +57,18 @@
5057
</java>
5158
</target>
5259

60+
<target name='test-anttask' depends='build, build-testapp'>
61+
<taskdef name='appbundler'
62+
classname='com.joshondesign.appbundler.BundlerTask'
63+
classpath='build/classes;lib/XMLLib.jar'/>
64+
65+
<appbundler
66+
bundle="test/bundle.xml"
67+
target="mac"
68+
destdir="dist"
69+
libdir="build/jars;lib"
70+
/>
71+
</target>
5372

5473
</project>
5574

src/com/joshondesign/appbundler/Bundler.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,21 @@ public static void main(String ... args) throws Exception {
5656
p("using target " + target);
5757
p("using dest_dir = " + DEST_DIR);
5858
p("using descriptor = " + DESCRIPTOR);
59+
File descriptor = new File(DESCRIPTOR);
60+
if(!descriptor.exists()) throw new Error("Descriptor file: " + DESCRIPTOR + " does not exist");
61+
62+
runit(descriptor,jardirs, target, DEST_DIR, null);
63+
64+
}
65+
66+
public static void runit(File descriptor, List<String> jardirs,
67+
String target,
68+
String DEST_DIR,
69+
String codebase) throws Exception {
5970

6071
//File keystore = new File("testkeystore");
6172
//load xml
62-
AppDescription app = parseDescriptor(DESCRIPTOR);
73+
AppDescription app = parseDescriptor(descriptor);
6374
//check xml
6475
verifyApp(app);
6576
//check support dirs
@@ -98,7 +109,6 @@ public static void main(String ... args) throws Exception {
98109
}
99110

100111
p("ERROR: unrecognized target: " + target);
101-
102112
}
103113

104114
private static void p(String[] args) {
@@ -107,9 +117,7 @@ private static void p(String[] args) {
107117
}
108118
}
109119

110-
private static AppDescription parseDescriptor(String DESCRIPTOR) throws Exception {
111-
File descriptor = new File(DESCRIPTOR);
112-
if(!descriptor.exists()) throw new Error("Descriptor file: " + DESCRIPTOR + " does not exist");
120+
private static AppDescription parseDescriptor(File descriptor) throws Exception {
113121

114122
AppDescription app = new AppDescription();
115123
Doc doc = XMLParser.parse(descriptor);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.joshondesign.appbundler;
2+
3+
import org.apache.tools.ant.*;
4+
import java.io.*;
5+
import java.util.List;
6+
import java.util.ArrayList;
7+
8+
public class BundlerTask extends Task {
9+
String target = null;
10+
File bundlefile = null;
11+
File destdir = null;
12+
String libdir = null;
13+
List<String> jardirs = new ArrayList<String>();
14+
15+
public void setBundle(File bundlefile) {
16+
this.bundlefile = bundlefile;
17+
}
18+
19+
public void setTarget(String target) {
20+
this.target = target;
21+
}
22+
23+
public void setDestdir(File destdir) {
24+
this.destdir = destdir;
25+
}
26+
public void setLibdir(String libdir) {
27+
String[] dirs = libdir.split(";");
28+
for(String d : dirs) {
29+
this.jardirs.add(d);
30+
}
31+
}
32+
33+
public void execute() {
34+
if(bundlefile == null) {
35+
throw new BuildException("bundle xml file not set");
36+
}
37+
38+
String message = getProject().getProperty("ant.project.name");
39+
40+
log("bundle file = " + bundlefile.getAbsolutePath());
41+
log("dest dir = " + destdir.getAbsolutePath());
42+
log("generating target " + target);
43+
44+
try {
45+
Bundler.runit(bundlefile,jardirs,target, destdir.getAbsolutePath(),null);
46+
} catch (Exception ex) {
47+
ex.printStackTrace();
48+
throw new BuildException(ex);
49+
}
50+
}
51+
}

test/bundle.xml

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<app name="SimpleTest">
3-
<jar name="simpletest.jar" main-class="com.joshondesign.appbundler.simpletest.Main"/>
3+
<jar name="simpletest.jar"
4+
main-class="com.joshondesign.appbundler.simpletest.Main"/>
45
<jar name="XMLLib.jar"/>
5-
<!--
6-
<jar name="commons-codec-1.4.jar"/>
7-
<jar name="apache-mime4j-0.6.jar"/>
8-
<jar name="commons-logging-1.1.1.jar"/>
9-
<jar name="httpclient-4.0.1.jar"/>
10-
<jar name="httpcore-4.0.1.jar"/>
11-
<jar name="httpcore-nio-4.0.1.jar"/>
12-
<jar name="httpmime-4.0.1.jar"/>
13-
<jar name="parboiled-0.9.7.3.jar"/>
14-
-->
156
</app>

0 commit comments

Comments
 (0)