You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Chassande-Barrioz Sebastien <Se...@inrialpes.fr> on 2001/09/21 13:21:29 UTC

short file name of the current build xml file

Hi

I would like to know how it's possible to find the file name of the current 
build file. I found in the documentation that there is a file.ant property, 
but this field gives the absolute path. And I would like set in a property 
the short name of the file: the name without the path and without the .xml 
extension. 
Does ant provide tools to format string ?

Can you help please ?

Best regards,
Seb
-- 
Chassande-Barrioz Sebastien
INRIALPES - SIRAC/SARDES Team - ObjectWeb initiative
Mail job : sebastien.chassande@inrialpes.fr
Phone : 04.76.61.55.16

Re: short file name of the current build xml file

Posted by Chassande-Barrioz Sebastien <Se...@inrialpes.fr>.
Le Vendredi 21 Septembre 2001 18:25, Diane Holt a écrit :
> --- Chassande-Barrioz Sebastien <Se...@inrialpes.fr> wrote:
> > I would like to know how it's possible to find the file name of the
> > current build file. I found in the documentation that there is a
> > file.ant property,
> 
> Actually, it's "ant.file".
> 
> > but this field gives the absolute path. And I would like set in a
> > property the short name of the file: the name without the path and
> > without the .xml extension. Does ant provide tools to format string ?
> 
> There's some string manipulation available in certain tasks, but it's not
> generally available outside of those tasks. 

In fact I would like to build a jar file and make a directory with the base 
name of the xml file. I didn't find solution in both target.

>   <target name="getBasename">
>     <script language="javascript"> <![CDATA[
>       importClass(java.io.File);
>       file = new File(projname.getProperty("ant.file"));
>       basename = file.getName();
>       if (basename.endsWith(".xml")) {
>         pos = basename.indexOf('.');
>         basename = basename.substring(0, pos);
>       }
>       projname.setProperty("basename", basename) ;
>       ]]>
>     </script>
>   </target>

thanks for the script, I will try to use this solution. 

Seb
-- 
Chassande-Barrioz Sebastien
INRIALPES - SIRAC/SARDES Team - ObjectWeb initiative
Mail job : sebastien.chassande@inrialpes.fr
Phone : 04.76.61.55.16

Problem setting up CVS for CruiseControl use?

Posted by Paul Michali <pc...@cisco.com>.
I'm trying to get going with using CruiseControl and I've done the
following:

Have Ant installed (1.4) and running. It builds and runs tests for my
Java program.

Setup CVS on my PC (local mode) and put all the files into CVS (1.11).

Downloaded and unzipped CruiseControl (1.2.1)

I'm running Windows NT 4.0 SP6.

Started modifying the Ant build.xml, following CruiseControl
instructions
to be able to have the build based on whether files were modified. Here
are the XML file changes:

<taskdef name="modificationset"
    classname="net.sourceforge.cruisecontrol.ModificationSet">
    <classpath>
        <pathelement location="../../cruisecontrol/cruisecontrol.jar" />
    </classpath>
</taskdef>

<target name="init" description="Initializes the build properties">
    <tstamp/>
    ...

<target name="cruise.check" depends="init" description="Checks CVS for
Cruise Control">
    <modificationset lastbuild="${lastGoodBuildTime}"
                     quietperiod="30"
                     dateformat="yyyy-MMM-dd HH:mm:ss">
        <cvselement localworkingcopy="${basedir}"/>
    </modificationset>
</target>

<target name="prepare" depends="cruise.check" description="Creates the
directories">
...

Below is the output of the build run. There are several problems. First,
I
don't understand what the complaint is about the date for
lastGoodBuildTime.
Second, it is complaining that it cannot write to the log file. Do I
have to
do something to set this us? Third, it looks like I get a null pointer
exception related to the logging. Finally, the build results with a
failure
saying that there is no need to build. I changed a source file.

I must be missing a bunch of things here. Can anyone provide some
suggestions?

Thanks in advance!


-------------------------------------------------------------------------

Buildfile: build.xml

init:

cruise.check:
[CVSElement] java.text.ParseException: Unparseable date:
"${lastGoodBuildTime}"
[CVSElement]    at java.text.DateFormat.parse(DateFormat.java:324)
[CVSElement]    at
net.sourceforge.cruisecontrol.ModificationSet.setLastBuild(Mo
dificationSet.java:91)
[CVSElement]    at java.lang.reflect.Method.invoke(Native Method)
[CVSElement]    at
org.apache.tools.ant.IntrospectionHelper$5.set(IntrospectionH
elper.java:436)
[CVSElement]    at
org.apache.tools.ant.IntrospectionHelper.setAttribute(Introsp
ectionHelper.java:276)
[CVSElement]    at
org.apache.tools.ant.ProjectHelper.configure(ProjectHelper.ja
va:658)
[CVSElement]    at
org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(Runti
meConfigurable.java:143)
[CVSElement]    at
org.apache.tools.ant.Task.maybeConfigure(Task.java:178)
[CVSElement]    at org.apache.tools.ant.Task.perform(Task.java:216)
[CVSElement]    at org.apache.tools.ant.Target.execute(Target.java:164)
[CVSElement]    at
org.apache.tools.ant.Target.performTasks(Target.java:182)
[CVSElement]    at
org.apache.tools.ant.Project.executeTarget(Project.java:601)
[CVSElement]    at
org.apache.tools.ant.Project.executeTargets(Project.java:560)

[CVSElement]    at org.apache.tools.ant.Main.runBuild(Main.java:454)
[CVSElement]    at org.apache.tools.ant.Main.start(Main.java:153)
[CVSElement]    at org.apache.tools.ant.Main.main(Main.java:176)
[CVSElement] Log command failed to execute succesfully
[CVSElement] java.lang.NullPointerException
[CVSElement]    at java.util.Calendar.setTime(Calendar.java:882)
[CVSElement]    at
java.text.SimpleDateFormat.format(SimpleDateFormat.java:400)
[CVSElement]    at java.text.DateFormat.format(DateFormat.java:305)
[CVSElement]    at
net.sourceforge.cruisecontrol.element.CVSElement.formatCVSDat
e(CVSElement.java:563)
[CVSElement]    at
net.sourceforge.cruisecontrol.element.CVSElement.buildHistory
Command(CVSElement.java:281)
[CVSElement]    at
net.sourceforge.cruisecontrol.element.CVSElement.getHistory(C
VSElement.java:253)
[CVSElement]    at
net.sourceforge.cruisecontrol.element.CVSElement.getHistory(C
VSElement.java:238)
[CVSElement]    at
net.sourceforge.cruisecontrol.ModificationSet.processSourceCo
ntrolElements(ModificationSet.java:312)
[CVSElement]    at
net.sourceforge.cruisecontrol.ModificationSet.execute(Modific
ationSet.java:130)
[CVSElement]    at org.apache.tools.ant.Task.perform(Task.java:217)
[CVSElement]    at org.apache.tools.ant.Target.execute(Target.java:164)
[CVSElement]    at
org.apache.tools.ant.Target.performTasks(Target.java:182)
[CVSElement]    at
org.apache.tools.ant.Project.executeTarget(Project.java:601)
[CVSElement]    at
org.apache.tools.ant.Project.executeTargets(Project.java:560)

[CVSElement]    at org.apache.tools.ant.Main.runBuild(Main.java:454)
[CVSElement]    at org.apache.tools.ant.Main.start(Main.java:153)
[CVSElement]    at org.apache.tools.ant.Main.main(Main.java:176)
[CVSElement] [modificationset] Too much repository activity...sleeping
for: 30.0
 seconds.
[CVSElement] Log command failed to execute succesfully
[CVSElement] java.lang.NullPointerException
[CVSElement]    at java.util.Calendar.setTime(Calendar.java:882)
[CVSElement]    at
java.text.SimpleDateFormat.format(SimpleDateFormat.java:400)
[CVSElement]    at java.text.DateFormat.format(DateFormat.java:305)
[CVSElement]    at
net.sourceforge.cruisecontrol.element.CVSElement.formatCVSDat
e(CVSElement.java:563)
[CVSElement]    at
net.sourceforge.cruisecontrol.element.CVSElement.buildHistory
Command(CVSElement.java:281)
[CVSElement]    at
net.sourceforge.cruisecontrol.element.CVSElement.getHistory(C
VSElement.java:253)
[CVSElement]    at
net.sourceforge.cruisecontrol.element.CVSElement.getHistory(C
VSElement.java:238)
[CVSElement]    at
net.sourceforge.cruisecontrol.ModificationSet.processSourceCo
ntrolElements(ModificationSet.java:312)
[CVSElement]    at
net.sourceforge.cruisecontrol.ModificationSet.execute(Modific
ationSet.java:140)
[CVSElement]    at org.apache.tools.ant.Task.perform(Task.java:217)
[CVSElement]    at org.apache.tools.ant.Target.execute(Target.java:164)
[CVSElement]    at
org.apache.tools.ant.Target.performTasks(Target.java:182)
[CVSElement]    at
org.apache.tools.ant.Project.executeTarget(Project.java:601)
[CVSElement]    at
org.apache.tools.ant.Project.executeTargets(Project.java:560)

[CVSElement]    at org.apache.tools.ant.Main.runBuild(Main.java:454)
[CVSElement]    at org.apache.tools.ant.Main.start(Main.java:153)
[CVSElement]    at org.apache.tools.ant.Main.main(Main.java:176)

BUILD FAILED

E:\Java\Sources\PathFinder\build.xml:58: No Build Necessary

-------------------------------------------------------------------
PCM (Paul Michali)

Carrier Voice Gateway Business Unit (CVGBU)
Cisco Systems, Inc.
250 Apollo Drive
Chelmsford, MA 01824

Phone : (800) 572-6771 x 45817  (978) 244-5817 [direct]
Paging: (800) 365-4578 [voice]  pcm@epage.cisco.com [email page]

Re: short file name of the current build xml file

Posted by Diane Holt <ho...@yahoo.com>.
--- Chassande-Barrioz Sebastien <Se...@inrialpes.fr> wrote:
> I would like to know how it's possible to find the file name of the
> current build file. I found in the documentation that there is a
> file.ant property,

Actually, it's "ant.file".

> but this field gives the absolute path. And I would like set in a
> property the short name of the file: the name without the path and
> without the .xml extension. Does ant provide tools to format string ?

There's some string manipulation available in certain tasks, but it's not
generally available outside of those tasks. The only thing available to
you would be to either write a task or do it in a script. I felt like
writing a script :)  Here you go (change "projname" to the actual name of
your project)...

  <target name="getBasename">
    <script language="javascript"> <![CDATA[
      importClass(java.io.File);
      file = new File(projname.getProperty("ant.file"));
      basename = file.getName();
      if (basename.endsWith(".xml")) {
        pos = basename.indexOf('.');
        basename = basename.substring(0, pos);
      }
      projname.setProperty("basename", basename) ;
      ]]>
    </script>
  </target>

  <target name="setBasename" depends="getBasename">
    <echo message="basename = ${basename}"/>
  </target>

Diane

=====
(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/