java - How to compile jsoup through Ant? -
i tried use ant compile jsoup source. can compile successfully, cannot pass test. here process:
jsoup version: 1.6.3 ; ant version: 1.8.2
the source of jsoup in directory
src/  i made build file
src/build.xml  this file contains
<project name="jsoup"> <target name="compile"> <mkdir dir="build/classes"/> <javac srcdir="src" destdir="build/classes" includeantruntime="false"/> </target> <target name="jar"> <mkdir dir="build/jar"/> <jar destfile="build/jar/jsoup.jar" basedir="build/classes"> <manifest> <attribute name="main-class" value="statetrace"/> </manifest> </jar> </target> <target name="run"> <!--<java jar="build/jar/jsoup.jar" input="htmls/index.html" fork="true"/>--> <exec executable="java"> <arg value="-jar"/> <arg value="build/jar/jsoup.jar"/> <arg value="htmls/index.html"/> </exec> </target> </project>  note: 1. statetrace.java own test program (as below); 2. htmls/index.html input statetrace.java.
string html; // contains content in htmls/index.html ... try{ document doc = jsoup.parse(html); }catch(ioexception e){e.printstacktrace();}  then compile , run ant:
> ant compile > ant jar > ant run  after this, got err like:
run: [exec] exception in thread "main" java.lang.exceptionininitializererror [exec] @ org.jsoup.nodes.entities$escapemode.<clinit>(unknown source) [exec] @ org.jsoup.nodes.document$outputsettings.<init>(unknown source) [exec] @ org.jsoup.nodes.document.<init>(unknown source) [exec] @ org.jsoup.parser.treebuilder.initialiseparse(unknown source) [exec] @ org.jsoup.parser.treebuilder.parse(unknown source) [exec] @ org.jsoup.parser.htmltreebuilder.parse(unknown source) [exec] @ org.jsoup.parser.parser.parse(unknown source) [exec] @ org.jsoup.jsoup.parse(unknown source) [exec] @ statetrace.main(unknown source) [exec] caused by: java.lang.nullpointerexception [exec] @ java.util.properties$linereader.readline(properties.java:418) [exec] @ java.util.properties.load0(properties.java:337) [exec] @ java.util.properties.load(properties.java:325) [exec] @ org.jsoup.nodes.entities.loadentities(unknown source) [exec] @ org.jsoup.nodes.entities.<clinit>(unknown source) [exec] ... 9 more [exec] result: 1 build successful total time: 0 seconds  however, if manually compiled java source, like
javac src/org/jsoup/*.java src/org/jsoup/parser/*.java src/org/jsoup/examples/*.java src/org/jsoup/nodes/*.java src/org/jsoup/safety/*.java src/org/jsoup/select/*.java src/org/jsoup/helper/*.java  i compile , pass test.
any clue? thanks!
this build.xml works ant 1.8.2:
<?xml version="1.0"?> <project name="jsoup"> <target name="compile"> <mkdir dir="build/classes"/> <javac srcdir="src" destdir="build/classes" includeantruntime="false"/> </target> <target name="jar"> <mkdir dir="build/jar"/> <jar destfile="build/jar/jsoup.jar" basedir="build/classes"> <manifest> <attribute name="main-class" value="org.jsoup.examples.htmltoplaintext"/> </manifest> </jar> </target> <target name="run"> <!--<java jar="build/jar/jsoup.jar" input="htmls/index.html" fork="true"/>--> <exec executable="java"> <arg value="-jar"/> <arg value="build/jar/jsoup.jar"/> <arg value="htmls/index.html"/> </exec> </target> </project>  ... waiting more information ... ... until turns up, guess there no file @ htmls/index.html
Comments
Post a Comment