Grokbase Groups Ant user June 2015
FAQ
Hello,

I am working on a project where i am not able to delete certain files using
ant 1.7. I saw some bug with ant 1.7 where the suggestion was to use ant
1.8 version. My project is built out in 1.7 and it will be a big change to
built it out in 1.8. For a test i tried to use ant 1.8 to delete a file but
it is saying " Unable to delete a file.......". When i did -verbose it
fails on ant.taskdef.delete......method in ant. Any work around. The file
name i am trying to delete is aspectj1.6 specifically. Any thoughts.

Thanks
Aaok
On Thu, Jun 11, 2015 at 8:51 PM, wrote:

Hi! This is the ezmlm program. I'm managing the
user@ant.apache.org mailing list.

I'm working for my owner, who can be reached
at user-owner@ant.apache.org.

Acknowledgment: I have added the address

aaloksinghvi@gmail.com

to the user mailing list.

Welcome to user@ant.apache.org!

Please save this message so that you know the address you are
subscribed under, in case you later want to unsubscribe or change your
subscription address.


--- Administrative commands for the user list ---

I can handle administrative requests automatically. Please
do not send them to the list address! Instead, send
your message to the correct command address:

To subscribe to the list, send a message to:
<user-subscribe@ant.apache.org>

To remove your address from the list, send a message to:
<user-unsubscribe@ant.apache.org>

Send mail to the following for info and FAQ for this list:
<user-info@ant.apache.org>
<user-faq@ant.apache.org>

Similar addresses exist for the digest list:
<user-digest-subscribe@ant.apache.org>
<user-digest-unsubscribe@ant.apache.org>

To get messages 123 through 145 (a maximum of 100 per request), mail:
<user-get.123_145@ant.apache.org>

To get an index with subject and author for messages 123-456 , mail:
<user-index.123_456@ant.apache.org>

They are always returned as sets of 100, max 2000 per request,
so you'll actually get 100-499.

To receive all messages with the same subject as message 12345,
send a short message to:
<user-thread.12345@ant.apache.org>

The messages should contain one line or word of text to avoid being
treated as sp@m, but I will ignore their content.
Only the ADDRESS you send to is important.

You can start a subscription for an alternate address,
for example "john@host.domain", just add a hyphen and your
address (with '=' instead of '@') after the command word:
<user-subscribe-john=host.domain@ant.apache.org>

To stop subscription for this address, mail:
<user-unsubscribe-john=host.domain@ant.apache.org>

In both cases, I'll send a confirmation message to that address. When
you receive it, simply reply to it to complete your subscription.

If despite following these instructions, you do not get the
desired results, please contact my owner at
user-owner@ant.apache.org. Please be patient, my owner is a
lot slower than I am ;-)

--- Enclosed is a copy of the request I received.

Return-Path: <aaloksinghvi@gmail.com>
Received: (qmail 3119 invoked by uid 99); 12 Jun 2015 00:51:58 -0000
Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Jun 2015 00:51:58
+0000
Received: from localhost (localhost [127.0.0.1])
by spamd1-us-west.apache.org (ASF Mail Server at
spamd1-us-west.apache.org) with ESMTP id 3F2FACD54B
for <user-sc.1434061204.nkplmhpdhpmeedmamepa-aaloksinghvi=
gmail.com@ant.apache.org>; Fri, 12 Jun 2015 00:51:58 +0000 (UTC)
X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org
X-Spam-Flag: NO
X-Spam-Score: 2.879
X-Spam-Level: **
X-Spam-Status: No, score=2.879 tagged_above=-999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,
SPF_PASS=-0.001] autolearn=disabled
Authentication-Results: spamd1-us-west.apache.org (amavisd-new);
dkim=pass (2048-bit key) header.d=gmail.com
Received: from mx1-eu-west.apache.org ([10.40.0.8])
by localhost (spamd1-us-west.apache.org [10.40.0.7])
(amavisd-new, port 10024)
with ESMTP id wnUVMh4qEVkW
for <user-sc.1434061204.nkplmhpdhpmeedmamepa-aaloksinghvi=
gmail.com@ant.apache.org>;
Fri, 12 Jun 2015 00:51:56 +0000 (UTC)
Received: from mail-ig0-f173.google.com (mail-ig0-f173.google.com
[209.85.213.173])
by mx1-eu-west.apache.org (ASF Mail Server at
mx1-eu-west.apache.org) with ESMTPS id D0C5924C28
for <user-sc.1434061204.nkplmhpdhpmeedmamepa-aaloksinghvi=
gmail.com@ant.apache.org>; Fri, 12 Jun 2015 00:51:55 +0000 (UTC)
Received: by igbpi8 with SMTP id pi8so1777406igb.1
for <user-sc.1434061204.nkplmhpdhpmeedmamepa-aaloksinghvi=
gmail.com@ant.apache.org>; Thu, 11 Jun 2015 17:51:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;

h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:content-type;
bh=pWZAuGb5spcoMA0CCnNrERaHLtWDJXw/WbmnXnaDSTw=;

b=BLGdS2mRJy/dEu0V3f6HIU7SnDaric1onQmi2lVHLwsUL2fzrX13o0mqTrwH815ok2

FBUgr4l1cI8CtQ63rquH3kviIhe0pZJnKdbCe4WfSLo4gCUcpmEJyddmeZ704fxCOdna

zM8ip4bpGXVQ1mfa6zWCqox1JfM7tobKyCO7uV2EOsmP5usG+Z2/PWO5hNhvtVo/7CAW

2sv0ImfAvGb+V9h4FYBW1zE04NF814NnfG/H+T9VrPtP/Cm/AaRB52c9KHDHQzjQ+gEu

CP47GOXOKDa3QXLowXD5R4jljzrdwBZmeaoqKV97wXec45UXSFaNsAL6ywKy0Lf/2iD6
TZHw==
MIME-Version: 1.0
X-Received: by 10.50.79.202 with SMTP id l10mr1239998igx.7.1434070314614;
Thu,
11 Jun 2015 17:51:54 -0700 (PDT)
Received: by 10.36.49.133 with HTTP; Thu, 11 Jun 2015 17:51:54 -0700 (PDT)
In-Reply-To: <1434061204.71565.ezmlm@ant.apache.org>
References: <1434061204.71565.ezmlm@ant.apache.org>
Date: Thu, 11 Jun 2015 20:51:54 -0400
Message-ID: <
CAObRyaRdjOE_oYQbxacxK4rRoYAw4YQ56+2c0afhzm7vlmrufq@mail.gmail.com>
Subject: Re: confirm subscribe to user@ant.apache.org
From: aalok singhvi <aaloksinghvi@gmail.com>
To: user-sc.1434061204.nkplmhpdhpmeedmamepa-aaloksinghvi=
gmail.com@ant.apache.org
Content-Type: multipart/alternative; boundary=089e0122aaeeaf892e0518478314

--
Aalok Singhvi

Search Discussions

  • Stefan Bodewig at Jun 14, 2015 at 9:01 am

    On 2015-06-13, aalok singhvi wrote:

    I am working on a project where i am not able to delete certain files using
    ant 1.7. I saw some bug with ant 1.7 where the suggestion was to use ant
    1.8 version. My project is built out in 1.7 and it will be a big change to
    built it out in 1.8.
    We are pretty conservative about backwards incompatible changes so it is
    very likely your buildfiles for 1.7 (released more than eight years ago)
    will work with 1.8 (released more than five years ago) or the most
    recent version 1.9.5.
    For a test i tried to use ant 1.8 to delete a file but it is saying "
    Unable to delete a file.......". When i did -verbose it fails on
    ant.taskdef.delete......method in ant. Any work around.
    There are way too many reasons why deleting a file may fail. We first
    need more information in order to answer this.
    The file name i am trying to delete is aspectj1.6 specifically. Any
    thoughts.
    What OS are you on? Has this file been used during the build process,
    in particular is it a jar that may be part of the CLASSPATH or used in a
    <classpath> by Ant?

    Can you provide us with the full error message and ideally with the
    stacktrace you receive with -v?

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Stefan Bodewig at Jun 14, 2015 at 5:08 pm
    [please don't drop the user list from replies]
    On 2015-06-14, aalok singhvi wrote:

    When i use verbose to print errors.... its gives certain info as follows...
    It errors out on ant taskdef delete handle
    Delete.java line 720, 769 765 and 586.
    It owuld be better if you could paste the full stack trace - and even
    more important - tell us the exact version of Ant you are using (output
    of "ant -version")
    I am on Win7.
    On Windows files may be locked by processes that have opened it - which
    includes Ant itself, so this means you may run into trouble of you try
    to remove something that has been touched by Ant before.
    I am deleting this file before it is copied over to the project and used in
    classpath.
    If it was part of your CLASSPATH environment variable, Java would load
    it when starting Ant and there is no chance for Ant to remove it.

    I'm not sure how you copy the file after you've deleted it :-)

    If you copy the file (using Ant) before trying to delete it, the file
    may still be considered open by Windows. This is a known problem and
    Ant tries to work around it by registering the file as "deleteOnExit".
    Even with 1.7.0 you should see a message about "This attempts to delete
    the file when the Ant jvm has exited and might not succeed" in this
    case.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Aalok singhvi at Jun 14, 2015 at 5:31 pm
    at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:720)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:769)
    org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:765)
    org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:769)
    org.apache.tools.ant.UnkownElement.execute(UnkownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor6.invoke( Unknown Source)

    Apache ant 1.7.0

    As soon as build is done the main build file sets the classpath which
    includes certain jars.
    Know what I am trying to do is before even importing those jars i am trying
    to check if they were present in the project folder or not.
    If they were delete them and copy newer version from a FTP location and
    then set the classpath. I hope this makes sense.

    Can you suggest a work around.

    On Sun, Jun 14, 2015 at 1:08 PM, Stefan Bodewig wrote:

    [please don't drop the user list from replies]
    On 2015-06-14, aalok singhvi wrote:

    When i use verbose to print errors.... its gives certain info as
    follows...
    It errors out on ant taskdef delete handle
    Delete.java line 720, 769 765 and 586.
    It owuld be better if you could paste the full stack trace - and even
    more important - tell us the exact version of Ant you are using (output
    of "ant -version")
    I am on Win7.
    On Windows files may be locked by processes that have opened it - which
    includes Ant itself, so this means you may run into trouble of you try
    to remove something that has been touched by Ant before.
    I am deleting this file before it is copied over to the project and used in
    classpath.
    If it was part of your CLASSPATH environment variable, Java would load
    it when starting Ant and there is no chance for Ant to remove it.

    I'm not sure how you copy the file after you've deleted it :-)

    If you copy the file (using Ant) before trying to delete it, the file
    may still be considered open by Windows. This is a known problem and
    Ant tries to work around it by registering the file as "deleteOnExit".
    Even with 1.7.0 you should see a message about "This attempts to delete
    the file when the Ant jvm has exited and might not succeed" in this
    case.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Aalok Singhvi
  • Aalok singhvi at Jun 14, 2015 at 5:38 pm
    Cant a force delete a file....something like windows "del -F file name".


    On Sun, Jun 14, 2015 at 1:31 PM, aalok singhvi wrote:


    at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:720)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:769)
    org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:765)
    org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:769)
    org.apache.tools.ant.UnkownElement.execute(UnkownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor6.invoke( Unknown Source)

    Apache ant 1.7.0

    As soon as build is done the main build file sets the classpath which
    includes certain jars.
    Know what I am trying to do is before even importing those jars i am
    trying to check if they were present in the project folder or not.
    If they were delete them and copy newer version from a FTP location and
    then set the classpath. I hope this makes sense.

    Can you suggest a work around.

    On Sun, Jun 14, 2015 at 1:08 PM, Stefan Bodewig wrote:

    [please don't drop the user list from replies]
    On 2015-06-14, aalok singhvi wrote:

    When i use verbose to print errors.... its gives certain info as
    follows...
    It errors out on ant taskdef delete handle
    Delete.java line 720, 769 765 and 586.
    It owuld be better if you could paste the full stack trace - and even
    more important - tell us the exact version of Ant you are using (output
    of "ant -version")
    I am on Win7.
    On Windows files may be locked by processes that have opened it - which
    includes Ant itself, so this means you may run into trouble of you try
    to remove something that has been touched by Ant before.
    I am deleting this file before it is copied over to the project and used in
    classpath.
    If it was part of your CLASSPATH environment variable, Java would load
    it when starting Ant and there is no chance for Ant to remove it.

    I'm not sure how you copy the file after you've deleted it :-)

    If you copy the file (using Ant) before trying to delete it, the file
    may still be considered open by Windows. This is a known problem and
    Ant tries to work around it by registering the file as "deleteOnExit".
    Even with 1.7.0 you should see a message about "This attempts to delete
    the file when the Ant jvm has exited and might not succeed" in this
    case.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Aalok Singhvi


    --
    Aalok Singhvi
  • Stefan Bodewig at Jun 14, 2015 at 6:31 pm

    On 2015-06-14, aalok singhvi wrote:

    at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:720)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:769)
    org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:765)
    org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:769)
    org.apache.tools.ant.UnkownElement.execute(UnkownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor6.invoke( Unknown Source)
    Apache ant 1.7.0
    https://github.com/apache/ant/blob/ANT_170/src/main/org/apache/tools/ant/taskdefs/Delete.java#L720
    is inside the branch that deletes a directory, not a single file. And
    strangely there isn't even a line 769 in 1.7.0. And 769 is inside
    removeDir and execute at the same time? Strange.
    As soon as build is done the main build file sets the classpath which
    includes certain jars.
    Then this is a point where the jars may get locked - maybe there already
    is one before that.
    Know what I am trying to do is before even importing those jars i am trying
    to check if they were present in the project folder or not.
    If they were delete them and copy newer version from a FTP location and
    then set the classpath. I hope this makes sense.
    Yes, it does. If you want to do anything like that, then you must not
    build a classloader holding the jars before you try to relace them.
    Otherwise the JVM locks them and there is nothing Ant can do. And there
    is no way to force it, it is an OS level lock that Ant cannot lift.

    Is it possible you extract a small example build file that exhibits the
    problem and we can see whether we can improve it together so it works?
    Maybe open a Bugzilla issue for that since attaching files and trying
    patches back and force may be more convenient there.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Aalok singhvi at Jun 14, 2015 at 6:41 pm
    Hey Stephan,

    I tried using "deleteonexit" and it is know allowing me to delete something
    of the jars but not allowing me to delete 2 directories. It says the once
    Ant JVM is terminated it can be deleted.

    Can we terminate ant jvm and restart once this delete is completed. I know
    its a stupid question but just wanted to see if you have seen this before
    by any chance.

    Let me check if I can extract a small build. i will need to get approvals
    on that.

    I tried executing a batch commands also and it is now allowing me to delete
    some of the files when i execute it from ant. But when i execute as a
    separate batch file it allows me to delete files in that workspace.

    Thanks
    Aalok
    On Sun, Jun 14, 2015 at 2:31 PM, Stefan Bodewig wrote:
    On 2015-06-14, aalok singhvi wrote:

    at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:720)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:769)
    org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:765)
    org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:769)
    org.apache.tools.ant.UnkownElement.execute(UnkownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor6.invoke( Unknown Source)
    Apache ant 1.7.0

    https://github.com/apache/ant/blob/ANT_170/src/main/org/apache/tools/ant/taskdefs/Delete.java#L720
    is inside the branch that deletes a directory, not a single file. And
    strangely there isn't even a line 769 in 1.7.0. And 769 is inside
    removeDir and execute at the same time? Strange.
    As soon as build is done the main build file sets the classpath which
    includes certain jars.
    Then this is a point where the jars may get locked - maybe there already
    is one before that.
    Know what I am trying to do is before even importing those jars i am trying
    to check if they were present in the project folder or not.
    If they were delete them and copy newer version from a FTP location and
    then set the classpath. I hope this makes sense.
    Yes, it does. If you want to do anything like that, then you must not
    build a classloader holding the jars before you try to relace them.
    Otherwise the JVM locks them and there is nothing Ant can do. And there
    is no way to force it, it is an OS level lock that Ant cannot lift.

    Is it possible you extract a small example build file that exhibits the
    problem and we can see whether we can improve it together so it works?
    Maybe open a Bugzilla issue for that since attaching files and trying
    patches back and force may be more convenient there.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Aalok Singhvi
  • Stefan Bodewig at Jun 14, 2015 at 7:16 pm

    On 2015-06-14, aalok singhvi wrote:

    I tried using "deleteonexit" and it is know allowing me to delete something
    of the jars but not allowing me to delete 2 directories. It says the once
    Ant JVM is terminated it can be deleted.
    This is what I described. This happens if the JVM has opened the files
    and closed them again. For some reason the JVM on Windows and the OS
    disagree on whether the file is closed, there isn't anything you can do
    but either ensure the files are never opened in the first place or exit
    the VM.
    Can we terminate ant jvm and restart once this delete is completed. I know
    its a stupid question but just wanted to see if you have seen this before
    by any chance.
    This would mean you'd need two separate build steps with two separate
    invocations of Ant. Something like

    ,----
    ant update-jars
    ant do-what-I-really-wanted-to-do
    `----

    That would probably work. Maybe you don't need to check for updates all
    the time? An in-buildfile way would be to execute Ant from inside Ant
    using <java fork="true">, but that's not straight forward either.
    Let me check if I can extract a small build. i will need to get approvals
    on that.
    That would be good.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Christopher BROWN at Jun 14, 2015 at 7:28 pm
    Hello,

    Since Java SE 7, URLClassLoader defines a "close()" method which may be
    useful in the specific case mentioned:
    http://docs.oracle.com/javase/7/docs/api/java/net/URLClassLoader.html#close()

    As for the more general case of Windows locking files from Java, as I
    understand it, it's because the underlying file descriptor use to read from
    or write to files is only release when the associated stream is garbage
    collected (the logic is in the "finalize()" method). In my own code, I
    have a utility "delete(File)" method that tries to delete the file, and if
    it fails (on a Windows system) will loop with 10 millisecond sleep
    intervals, on the second and last iterations attempting System.gc() to
    force finalization, and it is seems to be a robust workaround in practice.

    Hope that might help.

    --
    Christopher

    On 14 June 2015 at 21:15, Stefan Bodewig wrote:
    On 2015-06-14, aalok singhvi wrote:

    I tried using "deleteonexit" and it is know allowing me to delete something
    of the jars but not allowing me to delete 2 directories. It says the once
    Ant JVM is terminated it can be deleted.
    This is what I described. This happens if the JVM has opened the files
    and closed them again. For some reason the JVM on Windows and the OS
    disagree on whether the file is closed, there isn't anything you can do
    but either ensure the files are never opened in the first place or exit
    the VM.
    Can we terminate ant jvm and restart once this delete is completed. I know
    its a stupid question but just wanted to see if you have seen this before
    by any chance.
    This would mean you'd need two separate build steps with two separate
    invocations of Ant. Something like

    ,----
    ant update-jars
    ant do-what-I-really-wanted-to-do
    `----

    That would probably work. Maybe you don't need to check for updates all
    the time? An in-buildfile way would be to execute Ant from inside Ant
    using <java fork="true">, but that's not straight forward either.
    Let me check if I can extract a small build. i will need to get approvals
    on that.
    That would be good.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Aalok singhvi at Jun 14, 2015 at 9:15 pm
    Chris..I am on java 6 and upgrading to 7 might be challenging.
    On Jun 14, 2015 3:28 PM, "Christopher BROWN" wrote:

    Hello,

    Since Java SE 7, URLClassLoader defines a "close()" method which may be
    useful in the specific case mentioned:

    http://docs.oracle.com/javase/7/docs/api/java/net/URLClassLoader.html#close()

    As for the more general case of Windows locking files from Java, as I
    understand it, it's because the underlying file descriptor use to read from
    or write to files is only release when the associated stream is garbage
    collected (the logic is in the "finalize()" method). In my own code, I
    have a utility "delete(File)" method that tries to delete the file, and if
    it fails (on a Windows system) will loop with 10 millisecond sleep
    intervals, on the second and last iterations attempting System.gc() to
    force finalization, and it is seems to be a robust workaround in practice.

    Hope that might help.

    --
    Christopher

    On 14 June 2015 at 21:15, Stefan Bodewig wrote:
    On 2015-06-14, aalok singhvi wrote:

    I tried using "deleteonexit" and it is know allowing me to delete something
    of the jars but not allowing me to delete 2 directories. It says the
    once
    Ant JVM is terminated it can be deleted.
    This is what I described. This happens if the JVM has opened the files
    and closed them again. For some reason the JVM on Windows and the OS
    disagree on whether the file is closed, there isn't anything you can do
    but either ensure the files are never opened in the first place or exit
    the VM.
    Can we terminate ant jvm and restart once this delete is completed. I know
    its a stupid question but just wanted to see if you have seen this
    before
    by any chance.
    This would mean you'd need two separate build steps with two separate
    invocations of Ant. Something like

    ,----
    ant update-jars
    ant do-what-I-really-wanted-to-do
    `----

    That would probably work. Maybe you don't need to check for updates all
    the time? An in-buildfile way would be to execute Ant from inside Ant
    using <java fork="true">, but that's not straight forward either.
    Let me check if I can extract a small build. i will need to get
    approvals
    on that.
    That would be good.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Stefan Bodewig at Jun 15, 2015 at 3:51 am

    On 2015-06-14, Christopher BROWN wrote:

    Since Java SE 7, URLClassLoader defines a "close()" method which may be
    useful in the specific case mentioned:
    http://docs.oracle.com/javase/7/docs/api/java/net/URLClassLoader.html#close()
    This won't help if the file in question is on the system classloader or
    the classloader is going to be used later.
    As for the more general case of Windows locking files from Java, as I
    understand it, it's because the underlying file descriptor use to read from
    or write to files is only release when the associated stream is garbage
    collected (the logic is in the "finalize()" method). In my own code, I
    have a utility "delete(File)" method that tries to delete the file, and if
    it fails (on a Windows system) will loop with 10 millisecond sleep
    intervals, on the second and last iterations attempting System.gc() to
    force finalization, and it is seems to be a robust workaround in practice.
    Ant has similar code. In 1.7.0 it was restricted to specific cases like
    the Delete task, nowadays it is a helper method (tryHardToDelete in
    FileUtils) that has been factored out and is used whenever a task wants
    to delete a file.

    Unfortunately it doesn't help for all cases (like files on the
    classloader) and that's when the deleteOnExit work around we've added
    comes into play.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Aalok singhvi at Jun 14, 2015 at 9:09 pm
    Stephen can you give me an example on update jars where I use ant within
    ant.
    On Jun 14, 2015 3:16 PM, "Stefan Bodewig" wrote:
    On 2015-06-14, aalok singhvi wrote:

    I tried using "deleteonexit" and it is know allowing me to delete something
    of the jars but not allowing me to delete 2 directories. It says the once
    Ant JVM is terminated it can be deleted.
    This is what I described. This happens if the JVM has opened the files
    and closed them again. For some reason the JVM on Windows and the OS
    disagree on whether the file is closed, there isn't anything you can do
    but either ensure the files are never opened in the first place or exit
    the VM.
    Can we terminate ant jvm and restart once this delete is completed. I know
    its a stupid question but just wanted to see if you have seen this before
    by any chance.
    This would mean you'd need two separate build steps with two separate
    invocations of Ant. Something like

    ,----
    ant update-jars
    ant do-what-I-really-wanted-to-do
    `----

    That would probably work. Maybe you don't need to check for updates all
    the time? An in-buildfile way would be to execute Ant from inside Ant
    using <java fork="true">, but that's not straight forward either.
    Let me check if I can extract a small build. i will need to get approvals
    on that.
    That would be good.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Aalok singhvi at Jun 14, 2015 at 9:36 pm
    Stephen....

    Are you suggesting on doing something like this....

    <target>
    <property name="name" value="pathtonewversion of ant jar"> // value takes
    in new ant.jar may be a newer ant version
    <java jar="name" fork="true"/>

    and then all delete
    </target>

    Thanks

    On Sun, Jun 14, 2015 at 5:09 PM, aalok singhvi wrote:

    Stephen can you give me an example on update jars where I use ant within
    ant.
    On Jun 14, 2015 3:16 PM, "Stefan Bodewig" wrote:
    On 2015-06-14, aalok singhvi wrote:

    I tried using "deleteonexit" and it is know allowing me to delete something
    of the jars but not allowing me to delete 2 directories. It says the once
    Ant JVM is terminated it can be deleted.
    This is what I described. This happens if the JVM has opened the files
    and closed them again. For some reason the JVM on Windows and the OS
    disagree on whether the file is closed, there isn't anything you can do
    but either ensure the files are never opened in the first place or exit
    the VM.
    Can we terminate ant jvm and restart once this delete is completed. I know
    its a stupid question but just wanted to see if you have seen this before
    by any chance.
    This would mean you'd need two separate build steps with two separate
    invocations of Ant. Something like

    ,----
    ant update-jars
    ant do-what-I-really-wanted-to-do
    `----

    That would probably work. Maybe you don't need to check for updates all
    the time? An in-buildfile way would be to execute Ant from inside Ant
    using <java fork="true">, but that's not straight forward either.
    Let me check if I can extract a small build. i will need to get approvals
    on that.
    That would be good.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Aalok Singhvi
  • Stefan Bodewig at Jun 15, 2015 at 3:57 am

    On 2015-06-14, aalok singhvi wrote:

    Stephen can you give me an example on update jars where I use ant within
    ant.
    <exec> invoking ant.bat is probably the easiest way for starting Ant
    from within a buildfile.

    Ant's main jar (ant-launcher.jar in 1.7.0 IIRC) doesn't contain a
    Main-Class entry in its manifest, when using <java> it would be
    something like (untested)

    <java fork="true" class="org.apache.tools.ant.Main">
       <classpath>
         <fileset dir="${ant.home}">
           <includes name="lib/*.jar"/>
         </fileset>
       </classpath>
    </java>

    But the exec approach may be superior as the batch file taskes care of
    several installation specific special cases.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Aalok singhvi at Jun 15, 2015 at 12:33 pm
    When I use execute something like..

    exec name=cmd
        Arg= /c
        Arg=ant path to the batch file under bin
        Arg=-p
    End exec

    Delete

    Both exec and delete are in same target. It delete all files except two
    saying that attempts to delete the file when ant jvm has exited and might
    not succeed.
    On Jun 14, 2015 11:57 PM, "Stefan Bodewig" wrote:
    On 2015-06-14, aalok singhvi wrote:

    Stephen can you give me an example on update jars where I use ant within
    ant.
    <exec> invoking ant.bat is probably the easiest way for starting Ant
    from within a buildfile.

    Ant's main jar (ant-launcher.jar in 1.7.0 IIRC) doesn't contain a
    Main-Class entry in its manifest, when using <java> it would be
    something like (untested)

    <java fork="true" class="org.apache.tools.ant.Main">
    <classpath>
    <fileset dir="${ant.home}">
    <includes name="lib/*.jar"/>
    </fileset>
    </classpath>
    </java>

    But the exec approach may be superior as the batch file taskes care of
    several installation specific special cases.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Stefan Bodewig at Jun 15, 2015 at 6:56 pm

    On 2015-06-15, aalok singhvi wrote:

    When I use execute something like..
    exec name=cmd
    Arg= /c
    Arg=ant path to the batch file under bin
    Arg=-p
    End exec
    Delete
    Both exec and delete are in same target. It delete all files except two
    saying that attempts to delete the file when ant jvm has exited and might
    not succeed.
    As long as the Ant process that locks the files is running, nothing ill
    be able to delete them - not a forked process and not anything else we
    can come up with.

    There really isn't any solution to this other than "don't make Ant lock
    your files until you are ready with your preparations". When I
    suggested forking Ant would be an option, I was thinking about doing the
    part that locks the files rather than the one that tries to delete them.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Aalok singhvi at Jun 16, 2015 at 11:01 am
    No worries. For now I am trying to see if i can overwrite the files that
    are not delete. I am getting the files from FTP. Lets see if that works or
    not.
    On Mon, Jun 15, 2015 at 2:55 PM, Stefan Bodewig wrote:
    On 2015-06-15, aalok singhvi wrote:

    When I use execute something like..
    exec name=cmd
    Arg= /c
    Arg=ant path to the batch file under bin
    Arg=-p
    End exec
    Delete
    Both exec and delete are in same target. It delete all files except two
    saying that attempts to delete the file when ant jvm has exited and might
    not succeed.
    As long as the Ant process that locks the files is running, nothing ill
    be able to delete them - not a forked process and not anything else we
    can come up with.

    There really isn't any solution to this other than "don't make Ant lock
    your files until you are ready with your preparations". When I
    suggested forking Ant would be an option, I was thinking about doing the
    part that locks the files rather than the one that tries to delete them.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Aalok Singhvi
  • Aalok singhvi at Jun 16, 2015 at 9:41 pm
    I have to copy a directory structure from a Linux Machine to windows. .
    Directory looks something like..

    Test directory - next level directory - low level directory with some jar.

    This should be copied as is. With ftp it only copies jar but not the
    directory structure.

    Can you please help ?
    On Jun 16, 2015 7:00 AM, "aalok singhvi" wrote:

    No worries. For now I am trying to see if i can overwrite the files that
    are not delete. I am getting the files from FTP. Lets see if that works or
    not.
    On Mon, Jun 15, 2015 at 2:55 PM, Stefan Bodewig wrote:
    On 2015-06-15, aalok singhvi wrote:

    When I use execute something like..
    exec name=cmd
    Arg= /c
    Arg=ant path to the batch file under bin
    Arg=-p
    End exec
    Delete
    Both exec and delete are in same target. It delete all files except two
    saying that attempts to delete the file when ant jvm has exited and might
    not succeed.
    As long as the Ant process that locks the files is running, nothing ill
    be able to delete them - not a forked process and not anything else we
    can come up with.

    There really isn't any solution to this other than "don't make Ant lock
    your files until you are ready with your preparations". When I
    suggested forking Ant would be an option, I was thinking about doing the
    part that locks the files rather than the one that tries to delete them.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Aalok Singhvi
  • Aalok singhvi at Jun 17, 2015 at 2:51 am
    With SCP i have tried...

    <scp todir="windowspath" File=username:pwd@host:/local/...path on unix"
    trust=true/>

    This als not works and I tried doing a tar on remote server which also not
    works.


    On Tue, Jun 16, 2015 at 5:41 PM, aalok singhvi wrote:

    I have to copy a directory structure from a Linux Machine to windows. .
    Directory looks something like..

    Test directory - next level directory - low level directory with some
    jar.

    This should be copied as is. With ftp it only copies jar but not the
    directory structure.

    Can you please help ?
    On Jun 16, 2015 7:00 AM, "aalok singhvi" wrote:

    No worries. For now I am trying to see if i can overwrite the files that
    are not delete. I am getting the files from FTP. Lets see if that works or
    not.

    On Mon, Jun 15, 2015 at 2:55 PM, Stefan Bodewig <bodewig@apache.org>
    wrote:
    On 2015-06-15, aalok singhvi wrote:

    When I use execute something like..
    exec name=cmd
    Arg= /c
    Arg=ant path to the batch file under bin
    Arg=-p
    End exec
    Delete
    Both exec and delete are in same target. It delete all files except two
    saying that attempts to delete the file when ant jvm has exited and might
    not succeed.
    As long as the Ant process that locks the files is running, nothing ill
    be able to delete them - not a forked process and not anything else we
    can come up with.

    There really isn't any solution to this other than "don't make Ant lock
    your files until you are ready with your preparations". When I
    suggested forking Ant would be an option, I was thinking about doing the
    part that locks the files rather than the one that tries to delete them.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Aalok Singhvi

    --
    Aalok Singhvi

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedJun 13, '15 at 4:29p
activeJun 17, '15 at 2:51a
posts19
users3
websiteant.apache.org

People

Translate

site design / logo © 2018 Grokbase