Design the jar Task
What are the requirements for a task that creates JARs? A good place to start is to the command-line tool, jar. At a minimum, our task should replicate the JAR-creating features of the tool (as opposed to all of the tool's features). This distinction is important. We're not reimplementing the jar tool, we're creating an operation for our build, satisfying only our build's requirements. The command-line tool only facilitates reaching that goal. Our build requires that we create JARs, so our task design should focus on JAR creation, nothing more. Should we later define a need, for example, to unpackage JARs, we would need an implementation of those features. The command-line tool creates a zip-compatible archive with a special directory called META-INF. It places a special file called MANIFEST.MF into this directory. Without going into too much detail, we describe JARs as smart zip files: archives capable of not only packaging a set of files into one file, but also having a type of package-descriptor (the manifest). At a minimum, our task should create JARs and allow the specification of a userwritten manifest file, if one exists. From a build perspective, our design should allow us to create JARs using large sets of files from multiple directories and file types. Since a JAR maintains the directory structure of the classfile locations, we may need to modify how certain groups of files are stored within the JAR file. Experienced Ant users will identify this with file sets and file patterns. (After this chapter, you'll be able to identify this too!) Cursory research across existing tasks reveals some with similar file set designs, such as copy and zip.
Các file đính kèm theo tài liệu này:
- Design the jar Task.pdf