2012-03-28 51 views
3

特定の場所から.propertiesファイルをWEB-INF/classes/com/infinitiフォルダ(WARファイル内)にコピーしたいとします。Antを使用してファイルとフォルダをコピーする

私は.propertiesファイルは、/クラス/なくWEB-INF /クラス/ COM /インフィニティ

コードIにWEB-INFにファイルをコピーすることができた使用して、このリンクHow to get Ant to copy properties file to classes directory 通過しました使用しています:

<war destfile="${deploy}/acc.war" webxml="${warSrc}/web/WEB-INF/web.xml"> 
      <lib dir="${lib}"> 
....... 
....... 
....... 
      <classes dir="${configHome}/config/com/infiniti"> 
       <include name="accredit.properties" /> 
      </classes> 

... 
.... 
....... 
</war> 

はまた、私は WEB-INF /クラスに$ {configHome} /リソース/ COM /インフィニティ/エラーコードフォルダをコピーする必要がありますes/com/infiniti

これはAntを使用して可能ですか?

答えて

8

はい、あなたは私がコピーを試みたが、コピーのように思えるこの

<war destfile="${deploy}/acc.war" webxml="${warSrc}/web/WEB-INF/web.xml"> 
... 
    <zipfileset dir="${configHome}/config/com/infiniti" includes="**/*.properties" prefix="WEB-INF/classes/com/infiniti"/> 
+0

Micheleさん、ありがとうございます。毎日2時間の仕事を保存しました。私の質問の2番目の部分(フォルダをコピーするため)...私はこの antnewbee

+0

うれしい! :) –

0

はい、antを使用することは可能です。ただ、コピーや同期があなたのファイルを移動するためにコマンドを使用します。

<copy todir="${distribution}/location" file="${local.path}/data/file.txt"> 
</copy> 

あなたはルールでもコピーすることができます:

Syncを使用して
<copy includeemptydirs="false" todir="${combined.bin}"> 
    <fileset dir="${buildbin}"/> 
    <fileset dir="${output2buildbin}"/> 
    <fileset dir="${output3buildbin}"/> 
</copy> 

<sync includeemptydirs="false" todir="${distres}"> 
    <fileset dir="${buildres}"> 
    <include name="logging/**" /> 
    </fileset> 
</sync> 

タスクは、そのドキュメントサイトに記載されています:

http://ant.apache.org/manual/Tasks/copy.html

同じ「ファイルセット」宣言型は、戦争のタスクに適用されます。

Examples 

Assume the following structure in the project's base directory: 

thirdparty/libs/jdbc1.jar 
thirdparty/libs/jdbc2.jar 
build/main/com/myco/myapp/Servlet.class 
src/metadata/myapp.xml 
src/html/myapp/index.html 
src/jsp/myapp/front.jsp 
src/graphics/images/gifs/small/logo.gif 
src/graphics/images/gifs/large/logo.gif 

then the war file myapp.war created with 

<war destfile="myapp.war" webxml="src/metadata/myapp.xml"> 
    <fileset dir="src/html/myapp"/> 
    <fileset dir="src/jsp/myapp"/> 
    <lib dir="thirdparty/libs"> 
    <exclude name="jdbc1.jar"/> 
    </lib> 
    <classes dir="build/main"/> 
    <zipfileset dir="src/graphics/images/gifs" 
       prefix="images"/> 
</war> 

will consist of 

WEB-INF/web.xml 
WEB-INF/lib/jdbc2.jar 
WEB-INF/classes/com/myco/myapp/Servlet.class 
META-INF/MANIFEST.MF 
index.html 
front.jsp 
images/small/logo.gif 
images/large/logo.gif 

http://ant.apache.org/manual/Tasks/war.html

+0

のようにインスタンスZipFileSetのために使用することができますwarタグの下ではサポートされていません....私はこのエラーを返しました。 'warはネストされた "コピー"要素 " – antnewbee

+0

をサポートしていません。ドキュメントの例を見てください。 –

+0

ありがとうJason ....ファイルセットタグ(同期タグの下にあるファイルセットタグ)を確認します – antnewbee

関連する問題