2011-02-03 3 views
3

Я хочу скопировать файл ресурсов из src/main/resources в CargoTomcat в/target/tomcat6x/container/webapps с использованием Maven.Как скопировать файл в папку tomcat webapp с помощью maven?

Я пробовал использовать 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> 

... но файл не копируя до начала сервера и приложение получает пингуется.

Кто-нибудь знает, как правильно его использовать?

ответ

2

Вы можете использовать Maven-antrun-плагин для этого и выполнить муравей задачу копирования:

<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. Claszen с тех пор, как он отправится с грузом maven, и если что-нибудь находится в каталоге maven-груза, он удаляет его. поэтому лучше использовать плагин для maven и указать фазу. но я не уверен, как это сделать. – Ikthiander

+0

привет, большое спасибо, в конце концов, я закончил тем, что использовал ваше решение, и, скорее, я копирую его на tempat 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> 
Смежные вопросы