[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1468
  • Last Modified:

If...then else statement in Ant

I will like to use If....then...else statement in my ant scripts.
I have two targets firstTarget and SecondTarget. I will like to check that a property that is
set in the MANIFEST file and call the corresponding targets. For example I have in my MANIFEST file Eclipse-Bundle: jar or Eclipse-Bundle: dir.
If "Eclipse-Bundle: jar" then we call firstTarget and if "Eclipse-Bundle: dir" then we call the secondTarget.
Below is the way I did it but that seem not work for me. How is the best way to write this
Your help is much appreciated

<target name="myTarget">
    <condition property="bundletype">
      < eguals arg1="${Eclipse-Bundle}"  "arg2="jar"/>
    </condition>
    <antcall target="firstTarget"/>
    <antcall target="SecondTarget"/>
  </target>
0
blayfk
Asked:
blayfk
  • 5
  • 3
1 Solution
 
CEHJCommented:
So you're expecting Ant to somehow read the manifest in a jar?
0
 
CEHJCommented:
>> < eguals arg1="${Eclipse-Bundle}"  "arg2="jar"/>

There are typos there of course, It should be

 < equals arg1="${Eclipse-Bundle}"  arg2="jar"/>

Open in new window

0
 
blayfkAuthor Commented:
Thanks CEHJ for the typos correction. I am expecting that ant  could identify if we building a jar file or a dir(directory).
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
CEHJCommented:
First thing to do is check the following. Let me know what happens
<target name="myTarget">
    <echo message="The value of Eclipse-Bundle is ${Eclipse-Bundle}"/>
....

Open in new window

0
 
blayfkAuthor Commented:
we get these
"The value of Eclipse-Bundle is dir"  when Eclipse-Bundle: dir in the manifest file

"The value of Eclipse-Bundle is jar"  when Eclipse-Bundle: jar in the manifest file
0
 
CEHJCommented:
Good. Try something like the following:
    <target name="myTarget">
	<condition property="bundletype" value="do-jar">
	    <equals arg1="${Eclipse-Bundle}" arg2="jar"/>
	</condition>

	<condition property="bundletype" value="do-dir">
	    <equals arg1="${Eclipse-Bundle}" arg2="dir"/>
	</condition>
	<antcall target="${bundletype}"/>
    </target>

    <target name="do-dir">
	<echo message="Doing dir"/>
    </target>

    <target name="do-jar">
	<echo message="Doing jar"/>
    </target>

Open in new window

0
 
blayfkAuthor Commented:
Thanks CEHJ! this really did work for me
0
 
CEHJCommented:
:-)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now