Jump to content
Changes to the Jaspersoft community edition download ×

Create Java archive of report templates and dependencies


thangalin
Go to solution Solved by thangalin,

Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Solution

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:

  1. In the project folder create a file named "build_dist.xml"
  2. 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>
 
  1. Right-click on the project name.
  2. Select Properties.
  3. Select Builders.
  4. Click New.
  5. Select Ant Builder.
  6. Click OK to display the Edit Configuration dialog.
  7. Set Buildfile to: ${project_loc}/build_dist.xml
  8. Set Base Directory to: ${project_loc}
  9. Click the Targets tab.
  10. Click Set Targets beside "After a 'Clean'".
  11. Uncheck dist, if it is checked.
  12. Click OK.
  13. Click Set Targets beside "Manual Build".
  14. Check dist, if it is unchecked.
  15. Click OK.
  16. Click OK to close the Edit Configuration dialog.
  17. Click OK to close the Project properties dialog.

The archive is now bulit automatically after each successful project build. Try it as follows:

  1. Select Project >> Clean.
  2. 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).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...