You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mevitha <me...@gmail.com> on 2008/06/04 21:44:29 UTC

Re: Disable Static content

Thanks for this. I want to clarify few things.
So in clearcase, if I add to ibm-web-ext.xmi 
fileServingEnabled="${webapp.fileServingEnabled}" ,


<target name="fileServingEnabled">
<replace file="${web.deploy.dir}/WEB-INF/ibm-web-ext.xmi"
fileServingEnabled="${webapp.fileServingEnabled}" />
<echo message="Destination : ${manifest.dest.dir}"/>
    <mkdir dir="${manifest.dest.dir}"/>
    <copy file="${temp.dir}/MANIFEST.MF" todir="${manifest.dest.dir}"/>
    <delete file="${temp.dir}/MANIFEST.MF" failonerror="false"/>
</target>
 Our war build file looks like this:

<target name="waraftercompile">
    <fail unless="war.prefix" message="${missing.property} war.prefix">

        This property is used to name the war file. If the war.prefix
setting
        is set to myApp then the war target will output a myApp.war file.
    </fail>

    <fail unless="web.dir" message="${missing.property} web.dir">
        This directory should point to the root directory of the web
application.
    </fail>


    <fail unless="web.classes.includes" message="${missing.property}
web.classes.includes">

        This property is used to determine which files from the classes
directory
        should be copied into the web.dir/classes directory. Normally this
is
        empty, but it can be used to copy properties files and other files.
    </fail>

    <fail unless="web.classes.excludes" message="${missing.property}
web.classes.excludes">

        This property is used to determine which files from the classes
directory
        should NOT be copied into the web.dir/classes directory. Normally
this is
        empty, but it can be used to exclude properties files and classes
used
        for testing purposes.
    </fail>

    <fail unless="web.includes" message="${missing.property} web.includes">

        This property is used to determine which files from the web.dir
directory
        will be copied into the war file. Normally this will include files
such
        as *.jsp, *.properties, *.xml, *.xsl, etc...
    </fail>

    <fail unless="web.excludes" message="${missing.property} web.excludes">

        This property is used to determine which files from the web.dir
directory
        will NOT be copied into the war file. Normally this will include
files such
        such as *.keep, ~*~ and other temporary files. This target will copy
the
        deployment descriptors from the deploy directory into the WEB-INF
folder
        of the web application. If you would like to maintain the
descriptors in
        the WEB-INF folder than you must change the web.deploy.dir property
to
        point to your WEB-INF folder.
    </fail>

    <delete file="${build.dir}\${war.prefix}.war" failonerror="false"/>
    <delete dir="${web.dir}/WEB-INF/classes" failonerror="false"/>

    <copy todir="${web.dir}/WEB-INF/classes">
        <fileset dir="${classes.dir}" includes="${web.classes.includes}"
excludes="${web.classes.excludes}">
            <include name="com/**/*.class"/>
        </fileset>
    </copy>

    <fail unless="web.deploy.dir" message="${missing.property}
web.deploy.dir">

        This property identifies the location of the folder that contains
the WEB-INF
        directory. This folder will be used to extract the deployment
descriptors
        that will be packaged into the war file.
    </fail>

    <available file="${web.deploy.dir}/WEB-INF/web.xml"
property="web.xml.available"/>
    <fail unless="web.xml.available" message="${missing.file} web.xml">

        This file is a required deployment descriptor for a web application.
The
        war file cannot be deployed to the application server without this
file.
        It should be located in the web.deploy.dir/WEB-INF folder.
    </fail>

    <available file="${web.deploy.dir}/WEB-INF/ibm-web-bnd.xmi"
property="ibm-web-bnd.xmi.available"/>
    <fail unless="ibm-web-bnd.xmi.available" message="${missing.file}
ibm-web-bnd.xmi">

        This file is a required deployment descriptor for a web application
in
        WebSphere. The war file cannot be deployed in WebSphere without this
file.
        It should be located in the web.deploy.dir/WEB-INF folder.
    </fail>

    <available file="${web.deploy.dir}/WEB-INF/ibm-web-ext.xmi"
property="ibm-web-ext.xmi.available"/>
    <fail unless="ibm-web-ext.xmi.available" message="${missing.file}
ibm-web-ext.xmi">

        This file is a required deployment descriptor for a web application
in
        WebSphere. The war file cannot be deployed in WebSphere without this
file.
        It should be located in the web.deploy.dir/WEB-INF folder.
    </fail>

    <available file="${web.deploy.dir}/META-INF/MANIFEST.MF"
property="war.manifest.available"/>
    <fail unless="war.manifest.available" message="${missing.file}
MANIFEST.MF">

        This file should contain the versioning information for the war
file.
        It should be located in the web.deploy.dir/META-INF folder.
    </fail>

    <antcall target="manifest">
        
        
    </antcall>

    <copy todir="${temp.dir}/war/WEB-INF/">
        <fileset dir="${web.deploy.dir}/WEB-INF">
            <include name="*.xmi"/>
            <include name="*.xml"/>
            <exclude name="*.mf"/>
        </fileset>
    </copy>

    <!-- if no list has been given for shared libraries, default to an empty
list -->
    <!-- this provides an alternative to those projects that aren't using
the filtering -->
    <property name="shared.libs" value=""/>

    <!-- combine the lists of files to exclude -->
    <property name="full.web.excludes" value="${web.excludes}
${shared.libs}"/>

    <war warfile="${build.dir}\${war.prefix}.war"
webxml="${temp.dir}/war/WEB-INF/web.xml"
manifest="${temp.dir}/war/META-INF/MANIFEST.MF" basedir="${web.dir}"
includes="${web.includes}" excludes="${full.web.excludes}">
        <fileset dir="${web.dir}">
            <include name="com/**/*.class"/>
        </fileset>
        <fileset dir="${temp.dir}/war">
            <include name="WEB-INF/*.xmi"/>
        </fileset>
    </war>


So if I set 
<replace file="${web.deploy.dir}/WEB-INF/ibm-web-ext.xmi"
fileServingEnabled="${webapp.fileServingEnabled}" />

after the copying of the .xmi files to the build snapshot view, will this
change work? The main catch is that the fileServingEnabled should be false
in the clearcase and should only change for the build,ie just before the
creation of war.

I am a newbie to ANT, so please correct me where I go wrong.

Thanks!!

==========================================================================

Steve Loughran wrote:
> 
> Mevi wrote:
>> Hi,
>> 
>> In our project we would like to disable file serving. Via RAD one can
>> edit
>> the Web Deployment Descriptor. Under the extensions tab there is a check
>> box
>> for "File serving enabled" . What happens under the covers is that the
>> ibm-web-ext.xmi file is modified. The attribute is for fileServingEnabled
>> is
>> set to false. This is only applicable when running on the servers and not
>> our development environment. Thus we want it to be set when we build.
>> However the catch we do not want this put into clear case. That is the
>> file
>> ibm-web-ext.xmi only gets modified for the artifact and not the source
>> code.
>> 
>> 
>> Is this doable? ie Can ANT change the ibm-web-ext.xmi file contents
>> during
>> the build in Anthill Pro?
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> 
>> <webappext:WebAppExtension xmi:version="2.0" xmlns:xmi="
>> http://www.omg.org/XMI" xmlns:webappext="webappext.xmi"
>> xmi:id="WebAppExtension_1186668401406" reloadInterval="3"
>> reloadingEnabled="true" additionalClassPath="" fileServingEnabled="false"
>> directoryBrowsingEnabled="false" serveServletsByClassnameEnabled="false">
>> 
>> <webApp href="WEB-INF/web.xml#WebApp_ID"/>
>> 
>> </webappext:WebAppExtension>
>> 
>> Thanks!
> 
> 
> 
> I would recommend you have a file with all the settings set from ant 
> properties
> 
> fileServingEnabled="${webapp.fileServingEnabled}"
> 
> Then you take the this template and <copy> it with property expansion
> 
> Here is a presetdef template
> 
>     <!--preset to copy with ant property expansion (and always
> overwrite)-->
>     <presetdef name="expandingcopy">
>       <copy overwrite="true">
>         <filterchain>
>           <expandproperties/>
>         </filterchain>
>       </copy>
>     </presetdef>
> 
> That you can use whenever you need to, such as when patching izpack xml 
> files or RPM .spec files:
> 
>     <expandingcopy todir="${build.dir}">
>        <fileset file="izpack/install.xml"/>
>      </expandingcopy>
> 
>     <expandingcopy todir="${rpm.SPECS}">
>        <fileset dir="${rpm.metadata.dir}" includes="**/*.spec"/>
>      </expandingcopy>
> 
> -steve
> -- 
> Steve Loughran                  http://www.1060.org/blogxter/publish/5
> Author: Ant in Action           http://antbook.org/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Disable-Static-content-tp15820352p17655017.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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