ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Parimala" <parim...@medicomsoft.com>
Subject RE: problem with replace token
Date Fri, 21 Nov 2003 04:19:30 GMT
Thanking U all for the support to accomplish my task. 
I am very glad to be a part of this team.

Thanks Again,
Parimala

-----Original Message-----
From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
Sent: Thursday, November 20, 2003 5:07 PM
To: user@ant.apache.org
Subject: RE: problem with replace token


will you commit that, Peter?

Jan

> -----Original Message-----
> From: peter reilly [mailto:peter.reilly@corvil.com]
> Sent: Thursday, November 20, 2003 11:42 AM
> To: Ant Users List
> Subject: Re: problem with replace token
> 
> 
> FileUtils#rename() and FileUtils#copyFile()
> both are general purpose methods and should
> not have implicit requirements on the "to" file
> being an absolute path.
> 
> Peter
> 
> On Thursday 20 November 2003 07:58, Jan.Materne@rzf.fin-nrw.de wrote:
> > A deeper look ...
> > I get that too. (Apache Ant version 1.7alpha compiled on 
> November 18 2003)
> >
> > output:
> >    +Task: replace
> >   [replace] Replacing in file.txt: @SRC@ --> test
> > C:\temp\xx\build.xml:11: java.lang.NullPointerException
> >   ...
> > Caused by: java.lang.NullPointerException
> >         at 
> org.apache.tools.ant.util.FileUtils.rename(FileUtils.java:1386)
> >         at
> > org.apache.tools.ant.taskdefs.Replace.processFile(Replace.java:462)
> >         at 
> org.apache.tools.ant.taskdefs.Replace.execute(Replace.java:294)
> >
> >
> > Background:
> > - <replace> works on a temp file
> > - if there are modifications, the original file is deleted 
> and the temp
> > renamed
> > - if there arent any, the temp file is deleted
> >
> >   --> i tested setting token to @ANOTHER@ (no 
> modifications) and all works
> > fine
> >
> > - file renaming is done in FileUtil class. The 
> FU.rename(File from, File
> > to) (line 1379)
> > - a NullPointerException occurs in 1386
> >         if (!parent.exists() && !parent.mkdirs()) {
> >   so "parent" must be null
> > - parent is set in 1385
> >         File parent = getParentFile(to);
> > - so that method (line 1128) must return 'null'. This is the case if
> > "to.getParent()" returns
> >   null. But this is required behaviour, because "Emulation of
> > File.getParentFile for JDK 1.1".
> >
> >
> > ==> we have to ensure that the file we use has a parent !
> >
> > All relative files are resolved to 'basedir' - but only 
> when used by Ant.
> > In this case not Ant
> > is responsible for resolving but we are. So the simpliest is:
> >
> >     <script language="javascript"> <![CDATA[
> >         file = project.getProperty("file");
> >         //f = new java.io.File(file);
> >
> >         basedir = project.getBaseDir();         // get the basedir
> >         f = new java.io.File(basedir, file);    // create a 
> File with
> > parents
> >
> > And all works
> >
> >
> >
> > Jan
> >
> >
> >
> > TESTDATA
> > ========
> >
> >
> > build.xml
> > ---------
> > <project>
> >
> >     <property name="file" value="file.txt"/>
> >     <copy file="file-orig.txt" tofile="${file}" overwrite="true"/>
> >
> >     <echo> </echo>
> >     <echo>${file} before substitution</echo>
> >     <echo>----------------------------------------</echo>
> >     <concat><fileset dir="." includes="${file}"/></concat>
> >
> >     <script language="javascript"> <![CDATA[
> >         file = project.getProperty("file");
> >         replace = project.createTask("replace");
> >         f = new java.io.File(file);
> >         replace.setFile(f);
> >         replace.setToken("@SRC2@");
> >         replace.setValue("test");
> >         replace.perform();
> >     ]]></script>
> >
> >     <echo> </echo>
> >     <echo>${file} after substitution</echo>
> >     <echo>----------------------------------------</echo>
> >     <concat><fileset dir="." includes="${file}"/></concat>
> >
> > </project>
> >
> >
> >
> > file-orig.txt
> > -------------
> > this is text. That '@SRC@' (SRC) needs to be replaced.
> >
> > > -----Original Message-----
> > > From: Parimala [mailto:parimala@medicomsoft.com]
> > > Sent: Thursday, November 20, 2003 8:34 AM
> > > To: 'Ant Users List'
> > > Subject: RE: problem with replace token
> > >
> > >
> > > my property name is the same, neway i changed to @SRC@ still
> > > behaving the
> > > same...
> > >
> > > -----Original Message-----
> > > From: Jan.Materne@rzf.fin-nrw.de 
[mailto:Jan.Materne@rzf.fin-nrw.de]
> > Sent: Thursday, November 20, 2003 12:20 PM
> > To: user@ant.apache.org
> > Subject: RE: problem with replace token
> >
> > >      i  am trying to replace the token in the file the
> > > following is the code
> > > written for the same. This results in deletion of the file.
> > >
> > > replace = project.createTask("replace");
> > >
> > > f = new java.io.File(file) ;
> > >
> > > replace.setFile(f) ;
> > >
> > > replace.setToken("@SRC") ;
> >
> > you have forgotten the closing '@'
> >   replace.setToken("@SRC@");
> >
> >
> > Jan
> >
> > > replace.setValue("test") ;
> > >
> > > replace.perform() ;
> > >
> > >
> > >
> > > Where as this is working fine.
> > >
> > > <replace file="${file}" token="@SRC" value="test" />
> > >
> > >
> > >
> > > what cud be the possible reason for this??
> > >
> > >
> > >
> > > Parimala
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org


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


Mime
View raw message