Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:04:06+00:00 2026-06-01T17:04:06+00:00

I am using an Ant task from Jar Jar Links to embed classes from

  • 0

I am using an Ant task from Jar Jar Links to embed classes from a 3rd-party jar file (objenesis) in my distributable jar file (example.jar). Jar Jar will translate classes from the original package (org.objenesis) to one of my choosing.

It works but it leaves empty directories in the distributable jar.

Here is a simplified build.xml:

<target name="jar" depends="compile">
    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
        classpath="lib/jarjar-1.1.jar"/>

    <jarjar jarfile="dist/example.jar" excludes="org.objenesis.**">
        <fileset dir="build/classes/main"/>
        <zipfileset src="lib/objenesis-1.2.jar"/>
        <rule pattern="org.objenesis.**" result="org.thirdparty.@1"/>
    </jarjar>
</target>   

A sample of contents of the example.jar includes (as expected):

org/thirdparty/Objenesis.class
org/thirdparty/ObjenesisBase.class

but also these empty directories (undesirable):

org/objenesis/
org/objenesis/instantiator/
org/objenesis/instantiator/basic/

My question: how to I exclude these empty directories?

I tried the “zap” option (listed in the doc), but that didn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:04:07+00:00Added an answer on June 1, 2026 at 5:04 pm

    This appears to be a known issue in Jar Jar, listed in their issue tracker: http://code.google.com/p/jarjar/issues/detail?q=empty&id=32

    Given that this was raised almost three years ago and doesn’t appear to have got any traction, I suppose your options are to contribute a fix, or to work around it.

    An example Ant target to work around it, taking advantage of Ant’s support for removing empty directories on copy, would be:

    <target name="unpolluted-jarjar" description="JarJars without empty directories">
        <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${location.lib}/build/jarjar-1.2.jar"/>
        <jarjar basedir="${location.classes}" destfile="${location.dist.binaries}/my-app.jar">
            <zipfileset src="${location.lib}/shipped/dependency.jar"/>
            <rule pattern="com.example.dependency.**" result="com.example.my-app.jarjar.com.example.dependency.@1"/>
        </jarjar>
        <mkdir dir="${location.dist.binaries}/exploded"/>
        <unzip src="${location.dist.binaries}/my-app.jar" dest="${location.dist.binaries}/exploded/my-app.jar"/>
        <copy includeemptydirs="false" todir="${location.dist.binaries}/unpolluted/my-app.jar">
            <fileset dir="${location.dist.binaries}/exploded/my-app.jar"/>
        </copy>
        <jar destfile="${location.dist.binaries}/my-app-unpolluted.jar">
            <fileset dir="${location.dist.binaries}/unpolluted/my-app.jar"/>
        </jar>
    </target>
    

    It’s a bit grungy, but it achieves what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a java classes from the xsd using xjc ant task.
I am using Ant's get task to save a file to disk. I am
I am using the jar task in ant and wish to exclude a certain
The original title was How to generate enum from properties file using ant? I
We're generating Java files from WSDL descripitons using the axis-wsdl2java ant task. <axis-wsdl2java url=${src.dir.etc}/wsdl/BLAH.wsdl
My teams ant task pulls in developer specific info from a build.properties file by
I am trying to run an Ant task from within IBM RSA IDE using
I've got an Ant task (using the maven task) set up to automatically download
I'm trying to copy a directory using the Ant copy task. I am a
I have an Ant script that performs a copy operation using the 'copy' task

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.