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 7187159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:47:03+00:00 2026-05-28T18:47:03+00:00

Today I wanted to perform this task, and I run across some issues in

  • 0

Today I wanted to perform this task, and I run across some issues in the way. So I present here my problem and the solution I found. Perhaps somebody knows a simpler solution!

The problem was this: I was trying to build a distribution package of a Java project which is built with Maven2. In a previous step, several zip files all containing a file named manifest.xml in the root were generated, and I wanted to modify this XML file in all this ZIP files. This is a scheme:

package-file-1.zip
|- contents(DIR)
\- manifest.xml

package-file-2.zip
|- contents(DIR)
\- manifest.xml
  • 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-28T18:47:04+00:00Added an answer on May 28, 2026 at 6:47 pm

    This example modifies the zip files in ${zip.sourcedir} replacing the string & with & in the file manifest.xml of all this zip files and places the modified zip files in the directory target.

    For that, it uses the maven-antrun-plugin including the for and var tasks from the antcontrib tasks(http://ant-contrib.sourceforge.net). This permits to unzip the contents of every zip file into a separate directory. Note also the use of the task basename to extract the name of the zip files out of their path.

    <build>
    <plugins>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.7</version>
    
      <executions>
        <execution>
          <id>copy-and-repair-zips</id>
          <phase>initialize</phase>
          <goals>
            <goal>run</goal>
          </goals>                          
          <configuration>                           
            <tasks>                               
              <taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="maven.plugin.classpath"/>
              <for param="filepath">
                <path>
                     <fileset dir="${zip.sourcedir}" includes="**/*.zip"/>
                </path>
                <sequential>
                        <var name="for.filename" unset="true" />
                        <basename property="for.filename" file="@{filepath}" />
    
                        <unzip src="@{filepath}" dest="target/repair-temp/${for.filename}" encoding="UTF8" />
    
                        <replace file="target/repair-temp/${for.filename}/manifest.xml" token="&amp;" value="&amp;amp;" encoding="UTF8" />
    
                        <zip basedir="target/repair-temp/${for.filename}" destfile="target/${for.filename}" encoding="UTF8" />
                </sequential>
              </for>
            </tasks>
          </configuration>
        </execution>
      </executions>
      <dependencies>
        <dependency>
          <groupId>ant-contrib</groupId>
          <artifactId>ant-contrib</artifactId>
          <version>1.0b3</version>
          <exclusions>
            <exclusion>
              <groupId>ant</groupId>
              <artifactId>ant</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
      </dependencies>
    </plugin>
    </plugins>
    </build>
    

    In order to write this solution, I got the needed knowledge from this URLs:

    • Modify a JAR(or ZIP) file using Ant: How do I modify a file in a jar file using ANT?

    • Unzip multiple files into separate directories: http://grokbase.com/t/ant.apache.org/user/2004/01/re-how-to-unzip-multiple-file-into-separate-directories/122a5ezxhh6eolf5enkrdfgryika

    • Use ant-contrib in Maven2: http://docs.codehaus.org/display/MAVENUSER/Antrun+Plugin

      • But be careful to use net/sf/antcontrib/antlib.xml instead of net/sf/antcontrib/antcontrib.properties to be able to use the for task
    • Use the ant-contrib var task: http://www.jguru.com/forums/view.jsp?EID=1374074

    Edit

    After posting the question, I was able to find a couple of questions related, that could help if one is having problems implementing a similar thing:

    • maven3 – maven-antrun-plugin – "failed to create task or type if"
    • Using antcontrib <if> task via maven-antrun-plugin
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today, I ran into this weird problem with a user using Mac OS X.
I ran into a peculiar problem today when I wanted to migrate the history
Today, reading Servlet 3.0 specification, I've come across a sentence: We emphasize that this
Here’s a really really super-basic question. Say I wanted to build – today –
So I came across an interesting problem today. We have a WCF web service
I came across an interesting problem today. I have a text email I'm sending
I saw this piece of code today and wanted to know is there a
Today I was digging with TPL and found a new class Task.Now I just
Today I wanted to create my first annotation interface following this documentation and I
I came across a thing I needed today where I wanted to progressively associate

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.