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

  • SEARCH
  • Home
  • 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 7576003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:49:05+00:00 2026-05-30T16:49:05+00:00

I’m trying to create 2 zip files as part of an ant task. Both

  • 0

I’m trying to create 2 zip files as part of an ant task. Both are similar, but one includes some extra data. So to reduce code I’d like to define a fileset and reference it. The only problem is that produces an error.

Task:

<target name="create-zips" depends="cleanup, compile, package-jar">

    <zipfileset id="zipfiles">
        <zipfileset dir="${ant.project.name}-dist" includes="${jarname}.jar" prefix="${title}"/>
        <zipfileset dir="${scripts.dir}" includes="myprogram" filemode="755" prefix="${title}"/>
        <zipfileset dir="${scripts.dir}" includes="myprogram_gui" filemode="755" prefix="${title}"/>
        <zipfileset dir="${scripts.dir}" includes="myprogram_gui.command" filemode="755" prefix="${title}"/>
        <zipfileset dir="${scripts.dir}" includes="myprogram.bat" filemode="755" prefix="${title}"/>
        <zipfileset dir="${scripts.dir}" includes="myprogram_gui.bat" filemode="755" prefix="${title}"/>
        <zipfileset dir="${docs.dir}" includes="myprogram_readme.txt" prefix="${title}"/>
    </zipfileset>

    <zip destfile="${deploy.dir}/myprogram_${version}.zip" whenempty="fail" defaultexcludes="true">
         <zipfileset refid="zipfiles"/>
        <zipfileset dir="${otherdata.dir}" includes="other/*.*" prefix="${title}"/>
    </zip>
    <zip destfile="${deploy.dir}/myprogram_noother_${version}.zip" whenempty="fail" defaultexcludes="true">
        <zipfileset refid="zipfiles"/>
    </zip>
</target>

When task is run:

    create-zips:

BUILD FAILED
/path/to/my/buildfile/build-tools.xml:119: Problem opening /path/to/my/data/docs/myprogram_readme.txt

I’ve verified that the file exists. Removing the readme include just makes the error happen on a different file. Also, if I just copy and paste the zipfileset into 2 separate tags everything works fine. But I’d rather not do that.

edit: Apache Ant(TM) version 1.8.2 compiled on October 14 2011, Mac OS X 10.7. Haven’t tried on any other platform.

  • 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-05-30T16:49:07+00:00Added an answer on May 30, 2026 at 4:49 pm

    I was trying once to do the same, to no avail. A fileset does not accept nested fileset. When you try to cheat and use zipfileset as the outer set, ant considers its content as zip files. When ant tries to unzip your files, you get opening error.

    A fileset must have dir attribute. This dir must be parent to all fileset components. Sad but true.

    I ended up in workaround. Create X filesets. Those filesets may be specified as nested elements of a zip task. If in a given case you need less than X, then make a default for all X filesets, and zip always all X.

    <!-- define X empty filesets -->
    <fileset dir="c:\temp\1" includes="asdfasdf.neverhappens" id="nullfileset" />
    <fileset id="zipfileset2" refid="nullfileset" />
    <fileset id="zipfileset3" refid="nullfileset" />
    
    <!-- here go real sets -->
    <zipfileset dir="${scripts.dir}" includes="myprogram" />
    

    Be careful about ant filesets. They are mutable. I wrote once a “question” about it, but someone deleted it. Well done quiet job, stack folks, “thanks” for that.

    EDIT1: On Linux one could try dir="/" and use selectors nested inside a fileset. I was on Windows with my problem, so I couldn’t do that. There’s no “/” on Windows and I was gathering files from different drives.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

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.