开发者

Ant problem in including specific files

I am not sure about how to configure my ANT Task here. I have this directory structure. Inside my java folder are my properties file. I wanted to include them when I call my 'war' ant target

-src
    -java
        -com
            -test
                -MyClass.java
                -messages.properties
                -messages_en_US.properties
-web
    -WEB-INF
    -index.xhtml

Here's my war ant target

<project name="myApp" basedir=".">
    <property name="build.dir" value="${basedir}/build" />
    <property name="src.dir" value="${basedir}/src" />
    <property name="dist.dir" value="${basedir}/dist" />
    <property name="web.folder" value="web" />
    <property file="env.properties" />

    <target name="war" depends="compile">
        <war destfile="dist/${ant.project.name}.war" webxml="${web.folder}/WEB-INF/web.xml">
            <fileset dir="${web.folder}">
            </fileset>
            <classes dir="build/classes"/>
        </war>
    </target>
</project>

But when I take a look at the war file, it doesnt have the *.properties file

-WEB-INF
    -classes
        -com
            -test
                -MyClass.class

I tried using the include tag but still no progress.

<fileset dir="${web.folder}">
    <include name="**" />
</fileset>

Anything that I miss开发者_C百科? Thanks


Did you try the following to get the properties files?:

<fileset dir="${src.dir}" includes="**/*.properties"/>

I guess it's more or less the same as what Harry Joy wrote in the commet. :)


in general, if you have .properties files in your java source directory, they should probably be copied to the target/classes directory in the compile phase

<javac ... />
<copy todir="target/classes">
  <fileset dir="src/java" includes="**/*.properties,**/*.xml" />
</copy>

Note that in some cases, people separate these out into a separate folder (which is the default approach in maven) to keep things cleaner. Something like src/resources (maven uses src/main/resources).

You'd still have to do the above copy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜