ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tan, Ming" <Ming....@westgroup.com>
Subject jar update
Date Tue, 18 Sep 2001 18:59:45 GMT
Hi, all:

I have ANT 1.4, which has the "update" attribute for the jar task. However,
it still doesn't work as I expected. After I ran it, it only updated the
manifest file. Please help.

Here's my code:

<!-- ======================================================= -->
<!-- 5. Create jar file for all classes                      -->
<!-- ======================================================= -->
  <target name="buildJar" depends="compile">
    <echo message="------------------" />
    <echo message="Building jar file in progress" />
    
    <jar jarfile="${Build_Location}/CreditCard.jar" 
 
includesfile="${Compile_Location}/com/westgroup/esolutions/TransactionLog.cl
ass"
    	 basedir="${Compile_Location}"
    	 update="true"
    />
  </target>

-Ming

-----Original Message-----
From: Pugh, Eric [mailto:EPugh@MuseumCompany.com]
Sent: Tuesday, September 18, 2001 12:55 PM
To: 'ant-user@jakarta.apache.org'
Subject: RE: Passing in parameters (IF statement question)


I think I must be doing things the hard way!   The reason I want to be able
to hand in parameters like ps and pl is as a shortcut to remembering what
the server path is for ps...  For instance, is ps  \\production\stage, or
has it been changed to \\production\newshare\stage.  Also, to just shorten
the typing required.  We have four enviroments, with two shares (stage and
live) on each.   

I also think I am pushing ant in a non normal direction.  Less as a "build"
tool, but more as a tool to deploy images and .asp files to our various
environments.  I am using ant to encapsulate the logic to move files, as
well as tie it into the BeyondCompare diff program.  

I think I solved my problem based on some of the feed back given by people
on the list.  I have definied in my build.xml the properties: 
	ps (production stage) 
	pl (production live)
	dl (development live)
	ds (development stage)  

I created a task called PropertyFromProperty.  

So when I call ant from a batch file called bc.cmd:
<begin bc.cmd>
@echo off
setlocal

call ant compare -Denvironment1=%1 -Denvironment2=%2
<end bc.cmd>
I pass in the two enviroment "shortcuts" i want.  So "bc.cmd pl dl" produces
the ant call:
 ant compare -Denvironment1=pl -Denvironment2=dl.


Then in my target compare I call the task PropertyFromProperty that creates
a property based on the name of another property with the value of that
other property:
<begin build.xml>
  <target name="compare">
    
      <propertyfromproperty name="bc.environment1" property="environment1"/>
      <propertyfromproperty name="bc.environment2" property="environment2"/>
        
      
      <exec executable="${bc.executable}" newenvironment="true"
failonerror="true">
        <arg line="${bc.environment1}"/>
        <arg line="${bc.environment2}"/>
        <arg line="/expandall"/>
        <arg line="/display=mismatches"/>
        <arg line="/rules=Quick"/>   
        <arg line="/configpath=c:\istore\build\"/>         
      </exec>  
  </target>

<end build.xml>


<begin PropertyFromProperty.java>

package com.museumcompany.build;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;


// syntax: <propertyupdater name="result" property="env"/>

public class PropertyFromProperty extends Task {
  private String name;
  private String property;


  // The method executing the task
  public void execute() throws BuildException {

    if (name == null || property == null) {
      throw new BuildException("You must specify name and property.");
    }

    if (project.getProperty(property) == null) {
      throw new BuildException("The property " + property + " doesn't
exist.");
    }

    if (project.getProperty(project.getProperty(property)) == null) {
      throw new BuildException("The property " +
project.getProperty(property) + " doesn't exist.");
    }


    System.out.println("project.getProperty(property):" +
project.getProperty(property));
    project.setProperty(name,
project.getProperty(project.getProperty(property)));


  }

  // The setter for the "name" attribute
    public void setName(String name) {
      this.name = name;
  }

  // The setter for the "property" attribute
    public void setProperty(String property) {
      this.property = property;
  }
}
<end PropertyFromProperty.java>


I now am thinking that I might have accomplished this same task using the
condition and equals task?  At any rate, if anyone wants this code they are
free to snag it!  It does let me, with a batch file, be able to pass
parameters into ant.

Eric



-----Original Message-----
From: Diane Holt [mailto:holtdl@yahoo.com]
Sent: Tuesday, September 18, 2001 1:01 PM
To: ant-user@jakarta.apache.org
Subject: RE: Passing in parameters (IF statement question)


Eric,

It's a little hard to advise you, since you haven't given much detail on
what your build-file does (eg., what effect setting your "environmentN"
properties has on the build). I'm not sure why you need the batch-file or
what your in-house task does, but if you want to keep going with what you
have so far, the question is: Why are you going through ${environment1} in
your batch-file instead of just transforming the command-line "ps" to
"\\production\stage" to begin with? (My suspicion is you might be going a
long way around to do something that could be done more easily.) In any
case, if you're using Ant 1.4, you can use the <condition> task to set the
value of your "ps", "pl", etc. properties by using the <equal> tag to test
what ${environment1} is set to (although, again, I suspect you may be
going down a more convoluted path than you need to).

Diane

--- "Pugh, Eric" <EPugh@MuseumCompany.com> wrote:
> I guess after reading and playing with some of the changes suggested, I
> am getting closer to defining what i want!
> 
> I took Erik's suggestion, and created a batch file wrapper.  I have a
> task called compare that invokes Beyond Compare to do a comparison of
> some file directories.  My batch file takes in a "short name" for each
> enviroment. In other workds pl means production live.  ps means
> production stage.  I have properties definied in my build.xml:
> 	${ps}  = \\production\stage
> 	${pl}  = \\production\live
> 
> These two parameters are passed into my ant compare task via the batch
> file. Excellent so far, I can call bc.cmd ps pl and ant will get called
> with two paramters set:  ant compare -Denviroment1=ps -Denviroment2=pl.
> Then in my ant task that exec's the BeyondCompare.exe I pass the two
> short names: ${enviroment1}.  However, what I am now discovering is that
> I am executing this command:  
> 	c:\beyondcompare.exe pl ps.  
> NOT
> 	c:\beyondcompare.exe \\production\live  \\production\stage
> 
> What I really want is to have some sort of IF statement that says
> 	IF ${enviroment1} = "ps" then
> 		${enviroment1} = ${ps}
> 	END if
> 
> This kind of scripting I know has been banned from ANT2, under the
> theory that there are plenty of scripting tools.  So what have people
> done to make this kind of functionality work?  Use the BSF stuff?
> 
> Eric


=====
(holtdl@yahoo.com)



__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/

Mime
View raw message