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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:40:23+00:00 2026-05-21T03:40:23+00:00

I am working on an Ant build process for an application that uses a

  • 0

I am working on an Ant build process for an application that uses a versioning in the following format: major.minor.buildcount. So currently the application is around 2.1.52, where we are on version 2.1 and there have been 35 builds.

I am now adding in an ant target to ask the user if they would like to advance the major version and/or the minor version.

When I run my target from the command line I would like to follow the following:

@@ ant version
Versioning application...
Would you like to advance the major version to 3? (Y|n)
@@ n
Not Advancing major version
Would you like to advance the minor version to 2? (y|N)
@@ y
Advancing minor version

The lines prepended with @@ is the user input that I would like to take. My major and minor versions are stored in a build.properties file.

Here is my code so far

<?xml version="1.0"?>
<project name="StudentMS" default="zip" basedir=".">
    <propertyfile file="./.ant/build.properties">
        <entry key="version.buildnumber" type="int" default="0" operation="+" pattern="00" />
    </propertyfile>

    <property file="./.ant/build.properties" />
    <property name="sourceDir" location="/Users/dave/Workspace/ColdFusion/StudentMs" />
    <property name="buildDir" location="${sourceDir}/builds" />

    <target name="version" description="Adds a major and minor version to the build.">
        <input message="Advance major version? ${version.major}" addproperty="updatemajor" validargs="y,n" defaultvalue="n" />
        <propertyfile file="./.ant/build.properties">
            <entry key="version.major" type="int" default="0" operation="+" pattern="00" />
        </propertyfile>

        <input message="Advance minor version? ${version.minor}" addproperty="updateminor" validargs="y,n" defaultvalue="y" />
        <propertyfile file="./.ant/build.properties">
            <entry key="version.minor" type="int" default="0" operation="+" pattern="00" />
        </propertyfile>
    </target>
</project>

And my build.properties

#Tue, 29 Mar 2011 11:46:30 -0400
version.buildnumber=35
version.major=2
version.minor=1

I am still very new to Ant so I am sorry that I can’t post more advanced code. So the first thing I need to do is add some kind of conditional around my property file edits.

  • 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-21T03:40:24+00:00Added an answer on May 21, 2026 at 3:40 am

    what you want can be achieved by combining the condition and antcall task and by adding a couple of extra targets.

    I think something like this should work:

    <property file="./.ant/build.properties" />
    <property name="sourceDir" location="/Users/dave/Workspace/ColdFusion/StudentMs" />
    <property name="buildDir" location="${sourceDir}/builds" />
    
    <target name="version" description="Adds a major and minor version to the build.">
        <input message="Advance major version? ${version.major}" addproperty="updatemajor" validargs="y,n" defaultvalue="n" />
    
         <condition property="executeMajor">
            <and>
               <isset property="updatemajor" />
               <equals arg1="${updatemajor}" arg2="y" />
            </and>
         </condition>
    
        <antcall target="update_major" />
    
        <input message="Advance minor version? ${version.minor}" addproperty="updateminor" validargs="y,n" defaultvalue="y" />
    
         <condition property="executeMinor">
            <and>
               <isset property="updateminor" />
               <equals arg1="${updateminor}" arg2="y" />
            </and>
         </condition>
    
       <antcall target="update_minor" />
    
    </target>
    
    <target name="update_major" if="executeMajor">
        <!-- Code to update major here -->
    </target>
    
    <target name="update_minor" if="executeMinor">
        <!-- Code to update minor here -->
    </target>
    

    Basically, what it does is set the executeMajor and executeMinor properties just in the case that the updatemajor/updateminor are set to “y”. Then, ant will run the update targets just if the executeMajor/Minor variables are set, and it will skip them otherwise.

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

Sidebar

Related Questions

I'm currently working with some developers who like to set up Ant tasks that
I'm working with a Java program that has multiple components (with Eclipse & Ant
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project that parses a log of events, and then updates a
Later this year I want to release a PHP framework that I've been working
I've written an Ant build.xml file which obtains a number of source files via
I'm working on a mainly Java based project, that also has a couple of
I'm working on a blackberry project using eclipse and bb-ant tools. I've created a
I have a project which I can build and deploy correctly using Ant I
I had a project working in Eclipse completely, but after compiling it with ant

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.