• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

basic question: abt properties file and build xml

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have to create a folder (named XYZ) in a servlet but i need to pass on the name when I build the web app . I want to give the folder-name in a properties file, and replace the folder-name in the servlet when am building the app through build.xml

Question:
What to do in build.xml ?
What to do in the servlet ?
How to access the properties file from the build.xml?

Any help will be deeply appreciated.

Thanks
Kawa
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


What to do in build.xml ?


put something like this in your build.xml

<target name="replace-tokens">
<replace dir="<<path of the properties file>>"
replacefilterfile="<<name of the properties file>>"/>
</target>


What to do in the servlet ?



In your servlet put the name of the folder as "@replacename@"


And in your .properties file say

@replacename@ = webapps // webapps will be the folder name which gets replaced with @replacename@ while building.

Hope this helps you.

Anna.
 
Gerome Kawa
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks anna !
 
Gerome Kawa
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having some problems as follows:

When am trying to execute the command
c:\hubtransmission>build all

am getting the following error

C:\hubtransmission>build all
-------------Hubtransmission 1.0 Build System-------------
Using Ant at c:\hubtransmission\buildtools\ant1.6.1

Buildfile: build.xml

init:

replace-tokens:

BUILD FAILED
C:\hubtransmission\build.xml:38: Either the file or the dir attribute must be specified


It seems the ant.properties cannot be identitfied but I cannot make out why ?
Anyone spot the mistake ?
**************************************************************
folder structure
**************************************************************
hubtransmission
--build(build.xml, ant.properties, build.bat)
----deploymentdescriptors
----ear
----src
----war
--buildtools
----ant1.6.1
--lib
--src
----descriptors
----java
----web
**************************************************************
build.xml
**************************************************************
<project name="Hubtransmission Emulator" default="all" basedir=".">

<target name="init">

<!--
<property file="ant.properties"/>
-->
<property name="fs" value="${file.separator}"/>
<property environment="env"/>

<property name="dirs.base" value="${basedir}"/>
<property name="classdir" value="${dirs.base}/build/src"/>
<property name="src" value="${dirs.base}/src"/>
<property name="web" value="${dirs.base}/web"/>
<property name="deploymentdescription" value="${dirs.base}/build/deploymentdescriptors"/>

<property name="ant.properties" value="ant.properties" />

<property name="warFile" value="hubtransmission.war"/>
<property name="earFile" value="hubtransmission.ear"/>


<property name="earDir" value="${dirs.base}/build/ear"/>
<property name="warDir" value="${dirs.base}/build/war"/>


<!-- Create Web-inf and classes directories -->
<mkdir dir="${warDir}/WEB-INF"/>
<mkdir dir="${warDir}/WEB-INF/classes"/>

<!-- Create Meta-inf and classes directories -->
<mkdir dir="${earDir}/META-INF"/>

</target>

<!-- Replace tokens-->
<target name="replace-tokens">
<replace replacefilterfile="ant.properties"/>
</target>

<!-- Main target -->
<target name="all" depends="init,replace-tokens,build,buildWar,buildEar"/>


<!-- Compile Java Files and store in /build/src directory -->
<target name="build" >
<javac srcdir="${src}" destdir="${classdir}" debug="true" includes="**/*.java" />
</target>

<!-- Create the War File -->
<target name="buildWar" depends="init">

<copy todir="${warDir}/WEB-INF/classes">
<fileset dir="${classdir}" includes="**/*.class" />
</copy>

<copy todir="${warDir}/WEB-INF">
<fileset dir="${deploymentdescription}" includes="web.xml" />
</copy>

<copy todir="${warDir}">
<fileset dir="${web}" includes="**/*.*" />
</copy>

<!-- Create war file and place in ear directory -->
<jar jarfile="${earDir}/${warFile}" basedir="${warDir}" />

</target>


<!-- Create the War File -->
<target name="buildEar" depends="init">
<copy todir="${earDir}/META-INF">
<fileset dir="${deploymentdescription}" includes="application.xml" />
</copy>

<!-- Create ear file and place in ear directory -->
<jar jarfile="${dirs.base}/${earFile}" basedir="${earDir}" />
</target>
</project>

**************************************************************
 
anna pillutla
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be you can try by specifying "dir" attribute of replace tag, which takes the path of the properties file.

I mean..

<target name="replace-tokens">
<replace dir="<<path>>" replacefilterfile="ant.properties"/>
</target>

Hope this helps.

Anna.
 
Gerome Kawa
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anna
The ant.properties file is in the same folder as build.xml so what do i put in the dir attribute ?

Thanks
Kawa
 
anna pillutla
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kawa,

If ant.properties file is in ${dirs.base} you can give this as value for dir attribute.

Basically, what I mean to say is to give full path till parent directory of ant.properties file. Like if ant.properties file is in c:\AntTest. Then dir will have value something like this:

<target name="replace-tokens">
<replace dir="c:\AntTest" replacefilterfile="ant.properties"/>
</target>

Hope this helps.

Anna.
reply
    Bookmark Topic Watch Topic
  • New Topic