You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Paul Arzul <pa...@exinet.co.za> on 2000/09/11 11:11:36 UTC

how do you update a jar

i have tonnes of stuff to jar up - thankfully most of it is
static, so...

i've created a static custom jar file which i'd like to
update with the build files.

normally it's something like: jar -uf static.jar .

ant ignores my jar task when i specify an already existing
jar to add files too.

help.

- p


RE: Dynamic binding of properties

Posted by Michael Stanley <ms...@twcny.rr.com>.
> > One thought is to associate a priority value with
> > each property and only allow it to be changed at the same or higher
> > priority. That introduces mutability with precedence.
> Personally I think it
> > is the way to go.

This is a good idea but is it the best idea?  Its apparent that Ant is
slowly evolving into its own little programming language with global
variables, methods, etc.  Maybe a better idea would be the introduction of
target / project scope.  Final, static, instance vars, and even parameters.
It just seems like this method (although more difficult) will lead itself to
easier and more fluent evolution of Ant in the long run.

My 2 Cents,
Mike


RE: Dynamic binding of properties

Posted by Jeff Turner <je...@socialchange.net.au>.

On Thu, 5 Oct 2000, Conor MacNeill wrote:

> Jeff,
> 
> Properties are still immutable but can be bound in a target rather than at
> parse time. So we are vaguely dynamic.
> 
> Mutability is easy to introduce but then prevents a build's property values
> from being set externally.

Oh I see.. the build.xml property definition would always overwrite
the external definition.

> One thought is to associate a priority value with
> each property and only allow it to be changed at the same or higher
> priority. That introduces mutability with precedence. Personally I think it
> is the way to go.

I like it.. I was just about to propose an extra property attribute:

<property name=".." value=".." overrides="true"/>

when I realised that "overrides" is just binary priority.

One thing; you said "at the same or higher priority". If the default
priority is 0, then for backwards compatibility, properties should only be
overridden by -higher- priorities.

--Jeff

> 
> Conor
> 
> 
> --
> Conor MacNeill
> conor@cortexebusiness.com.au
> Cortex eBusiness
> http://www.cortexebusiness.com.au
> 
> > -----Original Message-----
> > From: Jeff Turner [mailto:jeff@socialchange.net.au]
> > Sent: Thursday, 5 October 2000 16:55
> > To: ant-user@jakarta.apache.org
> > Cc: Scott M Stark
> > Subject: Re: Dynamic binding of properties
> >
> >
> >
> >
> > On Thu, 5 Oct 2000, Peter James Donald wrote:
> >
> > > On Wed, 4 Oct 2000, Scott M Stark wrote:
> > > > I tried to write an ant script that would go through an
> > object serialization compatibility
> > > > testing suite. It is using BSF/JavaScript to try to simplify
> > the writing of a common set
> > > > of steps shown below as the runV target. The script below
> > does not work because
> > > > properties are bound as the xml document is parsed. Now I
> > have looked at how
> > > > properties are handled by Ant and at first glance it does not
> > seem that it would be
> > > > all that difficult to introduce dynamic properties, but it
> > would require a complete
> > > > change in how properties and attributes are represented. Is
> > this something that
> > > > could show up on a future todo list or are there
> > ramifications that would make this
> > > > unlikely?
> > >
> > > It is in progress now and will eventually go to fully
> > > dynamic evaluation I believe. It is doing partial dynamic
> > > evaluation now so you may want to download latest CVS as
> > > that *may* solve your problem (don't know haven't updated
> > > from CVS since it was added)
> >
> > I don't think it's got very far. Using the latest CVS, the following:
> >
> > <property name="base" value="."/>
> > <echo message="base is ${base}"/>
> > <property name="base" value="foo"/>
> > <echo message="base is ${base}"/>
> >
> > Just prints:
> >
> > main:
> > base is .
> > base is .
> >
> > --Jeff
> >
> > >
> > > Cheers,
> > >
> > > Pete
> > >
> > > *--------------------------------------------------*
> > > | Latrobe University,     | Does the name 'Pavlov' |
> > > | Bundoora, Australia     |    ring a bell ?       |
> > > *--------------------------------------------------*
> > >
> > >
> >
> >
> 
> 


RE: Dynamic binding of properties

Posted by Conor MacNeill <co...@ebinteractive.com.au>.
Jeff,

Properties are still immutable but can be bound in a target rather than at
parse time. So we are vaguely dynamic.

Mutability is easy to introduce but then prevents a build's property values
from being set externally. One thought is to associate a priority value with
each property and only allow it to be changed at the same or higher
priority. That introduces mutability with precedence. Personally I think it
is the way to go.

Conor


--
Conor MacNeill
conor@cortexebusiness.com.au
Cortex eBusiness
http://www.cortexebusiness.com.au

> -----Original Message-----
> From: Jeff Turner [mailto:jeff@socialchange.net.au]
> Sent: Thursday, 5 October 2000 16:55
> To: ant-user@jakarta.apache.org
> Cc: Scott M Stark
> Subject: Re: Dynamic binding of properties
>
>
>
>
> On Thu, 5 Oct 2000, Peter James Donald wrote:
>
> > On Wed, 4 Oct 2000, Scott M Stark wrote:
> > > I tried to write an ant script that would go through an
> object serialization compatibility
> > > testing suite. It is using BSF/JavaScript to try to simplify
> the writing of a common set
> > > of steps shown below as the runV target. The script below
> does not work because
> > > properties are bound as the xml document is parsed. Now I
> have looked at how
> > > properties are handled by Ant and at first glance it does not
> seem that it would be
> > > all that difficult to introduce dynamic properties, but it
> would require a complete
> > > change in how properties and attributes are represented. Is
> this something that
> > > could show up on a future todo list or are there
> ramifications that would make this
> > > unlikely?
> >
> > It is in progress now and will eventually go to fully
> > dynamic evaluation I believe. It is doing partial dynamic
> > evaluation now so you may want to download latest CVS as
> > that *may* solve your problem (don't know haven't updated
> > from CVS since it was added)
>
> I don't think it's got very far. Using the latest CVS, the following:
>
> <property name="base" value="."/>
> <echo message="base is ${base}"/>
> <property name="base" value="foo"/>
> <echo message="base is ${base}"/>
>
> Just prints:
>
> main:
> base is .
> base is .
>
> --Jeff
>
> >
> > Cheers,
> >
> > Pete
> >
> > *--------------------------------------------------*
> > | Latrobe University,     | Does the name 'Pavlov' |
> > | Bundoora, Australia     |    ring a bell ?       |
> > *--------------------------------------------------*
> >
> >
>
>


Re: Dynamic binding of properties

Posted by Jeff Turner <je...@socialchange.net.au>.

On Thu, 5 Oct 2000, Peter James Donald wrote:

> On Wed, 4 Oct 2000, Scott M Stark wrote:
> > I tried to write an ant script that would go through an object serialization compatibility
> > testing suite. It is using BSF/JavaScript to try to simplify the writing of a common set
> > of steps shown below as the runV target. The script below does not work because
> > properties are bound as the xml document is parsed. Now I have looked at how
> > properties are handled by Ant and at first glance it does not seem that it would be
> > all that difficult to introduce dynamic properties, but it would require a complete
> > change in how properties and attributes are represented. Is this something that
> > could show up on a future todo list or are there ramifications that would make this
> > unlikely?
> 
> It is in progress now and will eventually go to fully
> dynamic evaluation I believe. It is doing partial dynamic
> evaluation now so you may want to download latest CVS as
> that *may* solve your problem (don't know haven't updated
> from CVS since it was added)

I don't think it's got very far. Using the latest CVS, the following:

<property name="base" value="."/>
<echo message="base is ${base}"/>
<property name="base" value="foo"/>
<echo message="base is ${base}"/>

Just prints:

main:
base is .
base is .

--Jeff

> 
> Cheers,
> 
> Pete
> 
> *--------------------------------------------------*
> | Latrobe University,     | Does the name 'Pavlov' |
> | Bundoora, Australia     |    ring a bell ?       |
> *--------------------------------------------------*
> 
> 


Re: Dynamic binding of properties

Posted by Peter James Donald <pj...@lx2.cs.latrobe.edu.au>.
On Wed, 4 Oct 2000, Scott M Stark wrote:
> I tried to write an ant script that would go through an object serialization compatibility
> testing suite. It is using BSF/JavaScript to try to simplify the writing of a common set
> of steps shown below as the runV target. The script below does not work because
> properties are bound as the xml document is parsed. Now I have looked at how
> properties are handled by Ant and at first glance it does not seem that it would be
> all that difficult to introduce dynamic properties, but it would require a complete
> change in how properties and attributes are represented. Is this something that
> could show up on a future todo list or are there ramifications that would make this
> unlikely?

It is in progress now and will eventually go to fully
dynamic evaluation I believe. It is doing partial dynamic
evaluation now so you may want to download latest CVS as
that *may* solve your problem (don't know haven't updated
from CVS since it was added)

Cheers,

Pete

*--------------------------------------------------*
| Latrobe University,     | Does the name 'Pavlov' |
| Bundoora, Australia     |    ring a bell ?       |
*--------------------------------------------------*


Dynamic binding of properties

Posted by Scott M Stark <Sc...@displayscape.com>.
I tried to write an ant script that would go through an object serialization compatibility
testing suite. It is using BSF/JavaScript to try to simplify the writing of a common set
of steps shown below as the runV target. The script below does not work because
properties are bound as the xml document is parsed. Now I have looked at how
properties are handled by Ant and at first glance it does not seem that it would be
all that difficult to introduce dynamic properties, but it would require a complete
change in how properties and attributes are represented. Is this something that
could show up on a future todo list or are there ramifications that would make this
unlikely?

<?xml version="1.0" encoding="UTF-8"?>
<project name="JavaSerializationTests" default="run">
 <property name="java.proj" value="/usr/local/src/scott_home_rips/packages" />
 <property name="build.dir" value="/tmp" />
 <property name="version" value="V0" />

...

 <target name="run0">
  <script language="javascript"> <![CDATA[
   JavaSerializationTests.setProperty("version", "V0");
   runV.execute();
  ]]></script>
 </target>

 <target name="run1">
  <script language="javascript"> <![CDATA[
   JavaSerializationTests.setProperty("version", "V1");
   runV.execute();
  ]]></script>
 </target>

 <target name="runV">
  <echo message="Version = ${version}" />
  <delete file="${java.proj}/test/standards/serialization/RCIndexDef.java" />
  <copyfile src="${java.proj}/test/standards/serialization/RCIndexDef${version}.java"
dest="${java.proj}/test/standards/serialization/RCIndexDef.java" />
  <javac srcdir="${java.proj}" destdir="${build.dir}">
   <include name="test/standards/serialization/tst${version}.java" />
   <include name="test/standards/serialization/RCIndexDef.java" />
  </javac>

  <echo message="tst${version}, reading V0 object..." />
  <java classname="com.bear.racs.test.standards.serialization.tst${version}"
   fork="true" failonerror="true"
  >
   <arg value="-r" />
   <arg value="RCIndexDef_V0.ser" />
   <classpath>
    <pathelement location="${build.dir}" />
   </classpath>
  </java>

  <echo message="tst${version}, reading V1 object..." />
  <java classname="com.bear.racs.test.standards.serialization.tst${version}"
   fork="true" failonerror="true"
  >
   <arg value="-r" />
   <arg value="RCIndexDef_V1.ser" />
   <classpath>
    <pathelement location="${build.dir}" />
   </classpath>
  </java>
 </target>

</project>



Re: how do you update a jar

Posted by Jesse Glick <Je...@netbeans.com>.
Paul Arzul wrote:
> 
> On 11 Sep 2000, Stefan Bodewig wrote:
> 
> : >>>>> "PA" == Paul Arzul <pa...@exinet.co.za> writes:
> :
> :  PA> ant ignores my jar task when i specify an already existing jar to
> :  PA> add files too.
> :
> : Because Ant only compares the timestamps of the JAR and the files you
> : specify. If all files you want to add are older than the JAR file
> : itself it figures there is nothing to do.
> 
> thanks for the logic. what ant can do appears sufficient. if
> i following your reasoning, then if i create the static.jar
> before doing the build, it should update the jar?
> 
> i've tried this, but it *overwrites* the existing
> static.jar.

If everything that should go into static.jar is present in the list of
files you specify to the <jar> task, then the easiest way to force it to
always pick them is simply <delete> the JAR before you run the <jar>
task.

But if you have other files in the static.jar, and you want to add to
them with files you specify in the task (leaving the extra files alone),
then you should use the jlink task I guess.

-Jesse

-- 
Jesse Glick   <ma...@netbeans.com>
NetBeans, Open APIs  <http://www.netbeans.org/>
tel (+4202) 3300-9161 Sun Micro x49161 Praha CR

how to supply manifest information for a merged jar

Posted by Paul Arzul <pa...@exinet.co.za>.
On 11 Sep 2000, Stefan Bodewig wrote:

: >>>>> "PA" == Paul Arzul <pa...@exinet.co.za> writes:
: 
:  PA> if i following your reasoning, then if i create the static.jar
:  PA> before doing the build, it should update the jar?
: 
: Well, maybe this is what it should do, but it doesn't - as you've
: already seen.
: 
: The next version of Ant is going to have a <jlink> task (probably
: available from the next nightly build) that is supposed to be able to
: merge .jars (and add files to them).
: 
: Stefan


hi **,

from the ant 1.2 jlink documentation:

---8<---
jlink ignores META-INF directories in mergefiles.
Users should supply their own manifest information
for the output file. 
--->8---

how do i supply my manifest information for the
output file - seeing as jlink ignores meta-inf
directories in merge files, and the jar task
cannot update jar files.

do i have to use the exec task to access jar
update functionality?

(jar -umf manifest.txt merge.jar)

* * *

around 50% of my build time is spent jar-ing
static library files. i was hoping to speed things
up by merging a successful build jar with a once
off created mammoth static jar.

i get as far as creating and merging jar files,
but adding my manifest information to the merged
jar is proving troublesome.

the following example runs successfully, but my
understanding fails at the touch task.

1. the touch tasks does not appear to modifiy the
   date/timestamp on manifest.txt (i'm running
   winnt 4.0sp6)

2. as a result of 1., the jar task appears
   uninterested in adding my manifest

if i manually touch manifest.txt, and just run the
last jar task again, it says (i'm running with
-debug) that it's creating an empty jar archive.
that is correct according to the whenempty
attribute documentation, but it overwrites my
careful created merged jar file.

any suggestions or is it back to exec?

- p

Ant version 1.2 compiled on October 24 2000
---8<---
<?xml version="1.0"?>

<project name="Test" default="merge">
  <target name="merge">
    <jar jarfile="build.jar">
      <fileset dir="build" />
      <fileset dir="resource" />
    </jar>

    <jlink
      compress="yes"
      outfile="merge.jar">
      <mergefiles>
        <pathelement path="lib/static.jar" />
        <pathelement path="build.jar" />
      </mergefiles>
    </jlink>

    <touch file="manifest.txt" />

    <jar jarfile="merge.jar" manifest="manifest.txt" />
  </target>
</project>
--->8---

-- 
Please send email to me using plain text only. :)


Re: how do you update a jar

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "PA" == Paul Arzul <pa...@exinet.co.za> writes:

 PA> if i following your reasoning, then if i create the static.jar
 PA> before doing the build, it should update the jar?

Well, maybe this is what it should do, but it doesn't - as you've
already seen.

The next version of Ant is going to have a <jlink> task (probably
available from the next nightly build) that is supposed to be able to
merge .jars (and add files to them).

Stefan

Re: how do you update a jar

Posted by Paul Arzul <pa...@exinet.co.za>.
On 11 Sep 2000, Stefan Bodewig wrote:

: >>>>> "PA" == Paul Arzul <pa...@exinet.co.za> writes:
: 
:  PA> ant ignores my jar task when i specify an already existing jar to
:  PA> add files too.
: 
: Because Ant only compares the timestamps of the JAR and the files you
: specify. If all files you want to add are older than the JAR file
: itself it figures there is nothing to do.

thanks for the logic. what ant can do appears sufficient. if
i following your reasoning, then if i create the static.jar
before doing the build, it should update the jar?

i've tried this, but it *overwrites* the existing 
static.jar.

:(

- p


Re: how do you update a jar

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "PA" == Paul Arzul <pa...@exinet.co.za> writes:

 PA> ant ignores my jar task when i specify an already existing jar to
 PA> add files too.

Because Ant only compares the timestamps of the JAR and the files you
specify. If all files you want to add are older than the JAR file
itself it figures there is nothing to do.

This is sufficient most of the time. The alternative (compare all
files with the corresponding entries inside the JAR) would mean a large
performance hit and is therefore avoided.

There is no way around it (apart from making Ant jar your static files
as well). There has been someone volunteering to implement the
alternative approach - as an option, not as the default - though.

Stefan