2011-02-03 19 views
3

Mavenを使用して、src/main/resourcesから/ target/tomcat6x/container/webapps内のCargoTomcatにリソースファイルをコピーしたいとします。mavenを使用してtomcat webappフォルダにファイルをコピーするにはどうすればよいですか?

私はmaven-resources-pluginを使ってみましたが、何の成功もありません。

私はこれを試してみました:

<plugin> 
      <groupId>org.codehaus.cargo</groupId> 
      <artifactId>cargo-maven2-plugin</artifactId> 
      <version>1.0.5</version> 
      <configuration> 
       <wait>false</wait> 
       <container> 
        <containerId>tomcat6x</containerId> 
        <zipUrlInstaller> 
         <url> 
          http://mirrors.enquira.co.uk/apache/tomcat/tomcat-6/v6.0.30/bin/apache-tomcat-6.0.30.zip 
         </url> 
         <installDir>${installDir}</installDir> 
        </zipUrlInstaller> 
        <output> 
         ${project.build.directory}/tomcat6x.log 
        </output> 
        <log>${project.build.directory}/cargo.log</log> 
       </container> 
       <configuration> 
        <files> 
         <copy> 
          <file>src/main/resources/datasource.properties</file> 
          <!--tofile>${project.build.directory}/tomcat6x/container/webapps/datasource.properties</tofile--> 
          <todir>${project.build.directory}/tomcat6x/container/webapps</todir> 
         </copy> 
        </files> 
        <home> 
         ${project.build.directory}/tomcat6x/container 
        </home> 
        <properties> 
         <cargo.logging>high</cargo.logging> 
         <cargo.servlet.port>8081</cargo.servlet.port> 
        </properties> 
       </configuration> 
      </configuration> 


      <executions> 
       <execution> 
        <id>start-container</id> 
        <phase>pre-integration-test</phase> 
        <goals> 
         <goal>configure</goal> 
         <goal>start</goal> 
         <goal>deploy</goal> 
        </goals> 
        <configuration> 
         <deployer> 
          <deployables> 
           <deployable> 
            <groupId>${project.groupId}</groupId> 
            <artifactId>${project.artifactId}</artifactId> 
            <type>war</type> 
            <pingURL>http://localhost:8081/charmweb-0.0.1-SNAPSHOT/</pingURL> 
            <pingTimeout>180000</pingTimeout> 
            <properties> 
             <context>charmweb-0.0.1-SNAPSHOT</context> 
            </properties> 
           </deployable> 
          </deployables> 
         </deployer> 
        </configuration> 
       </execution> 

       <execution> 
        <id>stop-container</id> 
        <phase>post-integration-test</phase> 
        <goals> 
         <goal>stop</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

を...しかし、サーバが起動し、アプリケーションがpingされる前にファイルがコピーされていません。

誰でも使い方が分かりますか?

答えて

2

あなたは、このためのmaven-antrun-プラグインを使用してアリコピータスクを実行することができます:ここでOK

<plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.6</version> 
    <executions> 
     <execution> 
      <phase>package</phase> 
      <configuration> 
       <target> 
        <copy file="src/main/resources/fileToCopy" 
         tofile="${project.build.directory}/tomcat6x/container/webapps/fileToCopy" /> 
       </target> 
      </configuration> 
      <goals> 
       <goal>run</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 
+0

おかげ@Kです。クラウンはメイヴンの貨物と一緒に行くつもりで、メイヴェンの貨物のディレクトリに何かがあればそれを削除します。ので、メイヴンカーゴプラグインを使用して、フェーズに言及してください。しかし、どのようにするかわからない。 – Ikthiander

+0

こんにちは、多くの感謝、最後に、私はあなたのソリューションを使用して終了し、むしろ私は一時的な貨物のtomcat webappsにコピーしています。紛争はない。再度、感謝します。 – Ikthiander

2

を答え:

<plugin> 
      <groupId>org.codehaus.cargo</groupId> 
      <artifactId>cargo-maven2-plugin</artifactId> 
      <version>1.0.5</version> 
      <configuration> 
       <wait>false</wait> 
       <container> 
        <containerId>tomcat6x</containerId> 
        <zipUrlInstaller> 
         <url> 
          http://mirrors.enquira.co.uk/apache/tomcat/tomcat-6/v6.0.30/bin/apache-tomcat-6.0.30.zip 
         </url> 
         <installDir>${installDir}</installDir> 
        </zipUrlInstaller> 
        <output> 
         ${project.build.directory}/tomcat6x.log 
        </output> 
        <log>${project.build.directory}/cargo.log</log> 
       </container> 
       <configuration> 
        <home> 
         ${project.build.directory}/tomcat6x/container 
        </home> 
        <properties> 
         <cargo.logging>high</cargo.logging> 
         <cargo.servlet.port>8081</cargo.servlet.port> 
        </properties> 
        <files> 
         <copy> 
          <file>${project.basedir}/src/main/resources/datasource.properties</file> 
          <todir>webapps</todir> 
          <configfile>true</configfile> 
          <overwrite>true</overwrite> 
         </copy> 
        </files> 
       </configuration> 
      </configuration> 
関連する問題