Create java library with Ant -
I am trying to put some classes in a jar for use as a library.
In this exam, I am trying to have a class, I was thinking here that I was misusing the library, as I was getting the "Package Project.Api is not present" on the import line, but it means that the while getting me > It is intended to include the Java file, but not necessary. The relevant part of my build.xm The compile successfully compile Java and in bin / project / API. Sets the square file. In the jar file, the list of files under the directory specified in the To include the directory corresponding to the package, simply If only this package should be included (i.e. the other package should not be in jar), use the You can check the link from the Ant manual to use this function properly. apiInterface , and this package is in
project.api .
jar Tf project.jar should be produced
project / api / apiInterface.class
apiInterface.class apiInterface.java
& lt; Target name = "buildAPI" dependent = "" & gt; & Lt; Mkdir dir = "$ {Jar}" /> & Lt; Jar Destfile = "$ {Jar} / $ {ent. Project.name} -api.jar" & gt; & Lt; Fileset dir = "$ {bin} / $ {ant.project.name} / API" /> & Lt; Fileset dir = "$ {src} / $ {ent. Project.name} / API" /> & Lt; / Jar & gt; & Lt; / Target & gt;
fileset elements . Since you specify the directory as
$ {bin} / $ {ant.project.name} / api , the job will only search under this directory and include the class file in the jar, That is,
$ {Bin} / $ {ant.project.name} /api/apiInterface.class .
$ {bin} in this case to point to the
dir attribute root folder. Same for source files.
& lt; Jar destfile = "$ {jar} / $ {ant.project.name} -api.jar" & gt; & Lt; Fileset dir = "$ {bin}" / & gt; & Lt; Fileset dir = "$ {src}" / & gt; & Lt; / Jar & gt;
included attribute: < Pre>
& lt; Jar destfile = "$ {Jar} / $ {ant.project.name} -api.jar" & gt; & Lt; Fileset dir = "$ {bin}" includes = "$ {ant.project.name} / api / *. Class" /> & Lt; Fileset dir = "$ {src}" includes = "$ {ant.project.name} / api / * .java" /> & Lt; / Jar & gt;
Comments
Post a Comment