2017-11-21 18 views
0

私はantビルドファイルを初めて使用しています。 は現在、私はとビルドのファイルのリストを取得:Antビルドのコピータスクの前にファイルの名前を変更

a.cls 
b.cls 
c.cls 

が、私の地元では、私は同じディレクトリに、ファイル上に構築を実行する必要があります。

a-meta.cls 
b-meta.cls 
c-meta.cls 

ここmetaキーワードは一貫したままになります。私は次のbuild.xmlファイルを使用しています。実際にファイルをコピーする前に、ファイル名をどのように変更するのかよく分かりません。私はreplacemapperと他のantlibタスクを試しました。しかし、役に立たない。

<project name="test" default="compile"> 
    <taskdef resource="net/sf/antcontrib/antlib.xml"> 
     <classpath> 
      <pathelement location="lib/ant-contrib-1.0b3.jar"/> 
     </classpath> 
    </taskdef> 

    <loadfile property="file" srcfile="filesToMove.txt"/> <!-- these are the list of files, i mentioned earlier --> 
    <target name="compile"> 
     <echo>${file}</echo> <!-- here i have to rename file name to include -meta --> 
     <copy file="./classes/${file}" tofile="./src/classes/${file}" overwrite="true"/> 
    </target> 
</project> 

ファイルを移動する前に名前を変更する方法。

+0

ファイルを移動するのではなくコピーしているようです。元の名前のソースから新しい名前の(メタが付いた)宛先へのコピーが要件を満たしていますか? –

+0

これを解決しました...答えとして更新されます –

答えて

0

.clsの代わりに名前のみを検索し、-meta.htmlを追加しました。以下のように(質問の前のバージョンと比較して一部が変更されています)

<project name="test" default="compile"> 
    <taskdef resource="net/sf/antcontrib/antlib.xml"> 
     <classpath> 
      <pathelement location="lib/ant-contrib-1.0b3.jar"/> 
     </classpath> 
    </taskdef> 

    <loadfile property="file" srcfile="filesToMove.txt"/> <!-- these are the list of files, i mentioned earlier --> 
    <target name="compile"> 
     <echo>${file}</echo> <!-- here i have to rename file name to include -meta --> 
     <copy file="./classes/${file}" tofile="./src/classes/${file}" overwrite="true"/> 
     <for param="file"> 
      <path> 
       <fileset dir="./" includes="*.cls"/> 
      </path> 
      <sequential> 
       <basename file="@{file}" property="@{file}" suffix=".md"/> 
       <echo message=" ${@{file}}"/> 
       <copy file="${@{file}}-meta.cls" toDir="test"/> 
      </sequential> 
     </for> 
    </target> 
</project> 
関連する問題