What are the steps to create a distribution library that contains all the:
- Report images
- Internationalized resource bundles
- Class files (for custom functionality)
- Report templates
2 Answers:
Posted on May 5, 2016 at 10:42am
This answer makes the following assumptions:
- The class files and resource bundles are located in the "build" directory (should created by default when writing custom Java classes).
- The distribution directory for the Java archive will be named "dist".
- The images used by the reports are in an "images" directory and in SVG format.
- The report templates have been compiled and are in the main project folder.
Now:
- In the project folder create a file named "build_dist.xml"
- Copy the following content into build_dist.xml:
<?xml version="1.0"?>
<project name="DistributionLibrary" default="dist" basedir=".">
<description>Archives templates, bundles, class files.</description>
<property name="build" location="build" />
<property name="dist" location="dist" />
<target name="dist" description="Build distribution archive.">
<mkdir dir="${dist}" />
<jar destfile="${dist}/templates.jar">
<fileset dir="${build}" includes="**/*" />
<fileset dir="." includes="images/*.svg" />
<fileset dir="." includes="**/*.jasper"/>
</jar>
</target>
</project>
- Right-click on the project name.
- Select Properties.
- Select Builders.
- Click New.
- Select Ant Builder.
- Click OK to display the Edit Configuration dialog.
- Set Buildfile to: ${project_loc}/build_dist.xml
- Set Base Directory to: ${project_loc}
- Click the Targets tab.
- Click Set Targets beside "After a 'Clean'".
- Uncheck dist, if it is checked.
- Click OK.
- Click Set Targets beside "Manual Build".
- Check dist, if it is unchecked.
- Click OK.
- Click OK to close the Edit Configuration dialog.
- Click OK to close the Project properties dialog.
The archive is now bulit automatically after each successful project build. Try it as follows:
- Select Project >> Clean.
- Click OK.
In the Console panel you should see BUILD SUCCESSFUL.
Once the build is successful, the dist directory will contain a file called templates.jar that contains an archive that can be used as a resource for reports (in a Java application).