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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:45:10+00:00 2026-06-18T15:45:10+00:00

I have a scenario where I’m trying to reuse the same build.xml file across

  • 0

I have a scenario where I’m trying to reuse the same build.xml file across multiple projects. In each case, the finaly target is a dist that JARs everything up. The only difference is that some of the projects have a src/main/java/META-INF/* directory, and others don’t (and just have a src/main/java/* directory).

I want to use the Ant-Contrib <if/> task to optionally define a META-INF/ directory if the build sees a src/main/java/META-INF/* directory available. So something like this:

<jar jarfile="myapp.jar">
    <if>
        <available file="src/main/java/META-INF" />
        <then>
            <!--
                Copy everything from src/main/java/META-INF into
                the JAR's META-INF directory.

                But how?!?
            -->
            <echo message="I'm trying to copy META-INF!" />
        </then>
    </if>
</jar>

But I am choking on two things here:

  1. When I run this target, I get a build exception stating that I can’t nest an <if/> inside the <jar/> task; and
  2. I’m not sure how to configure the <jar/> task to create a META-INF directory at the root of the classpath, and copy all of the src/main/java/META-INF contents into it.

Any thoughts? Thanks in advance.

  • 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-18T15:45:11+00:00Added an answer on June 18, 2026 at 3:45 pm

    It sounds like you want to take advantage of a more modular build configuration. How about having two targets:

    <target name="jar">
        <!-- Normal JAR tasks like you currently have (sans the metainf stuff). -->
    </target>
    
    <target name="jar-with-metainf">
        <jar destfile="test.jar">
            <fileset dir="classes"/>
            <metainf dir="src/main/java/META-INF"/>
        </jar>
    </target>
    

    Then, when you want to build your META-INF/-containing projects, you just run jar-with-metainf.

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

Sidebar

Related Questions

I have scenario where I have to use the same XSD element for different
I have a scenario in which I have to run multiple commands one after
I have a scenario where combobox can have same string values. for exa combo
I have scenario where i need to transfer one or more file depending on
I have a scenario where I'm updating a blog post which has multiple tags
I have a scenario where there is an apartment and each apartment has flats
I have a scenario where I would like to update multiple fields in multiple
I have scenario like this Given /^initial data$/ do |table| @schedule_05 = Factory.build :schedule_05
I have a scenario where 1 Winform app is installed on multiple Citrix servers.
I have a scenario where Projects have Schedules, Schedules have many various names and

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.