Pergunta

alguém sabe uma maneira de meta configure um Maven para implantar em um servidor tomcat após uma compilação é executado? Eu sei que isso é possível usando a maven-tomcat-plugin, mas parece que, pois isso só funciona para Maven 2 enquanto eu estou usando Maven 1.1

Atualmente estou tentando configurar Hudson assim que esta seria parte da minha fase intergration contínua que espero será executado como este:

  1. construir todos os componentes necessários
  2. guerra construir e implantar para o servidor (local)
  3. testes de selênio executar

Qualquer ajuda com isso seria muito apreciado.

Graças.

Foi útil?

Solução 3

I've figured out that best way to do this - its actually pretty easy to write a maven goal to transfer the war. The goal could be written as follows:

<goal name="deployWar" prereqs="buildWar">

    <echo message="+---------------------------------------------------+" />
    <echo message="installing war file to server" />
    <echo message="+---------------------------------------------------+" />

    <j:set var="deploy.dir" value="${server}/webapps" />

    <copy file="${maven.build.dir}/${pom.artifactId}.war"
        todir="${deploy.dir}" overwrite="true" />
</goal>

The server variable can be determined in your project.properties file. Also be sure to specify that a pre-requisite to build the WAR before you try to deploy it. Hope this helps someone!

Outras dicas

Honestamente, eu iria refatorar seu projeto para usar Maven 2, existem vários guias que a dor de migração pode ajudar a aliviar (Google maven 2 migração ), e há até mesmo o maven-um-plugin para converter seu project.xml ou empacotar seus plugins Maven 1 para Maven 2.

Se você não pode fazer isso, você pode usar a Maven 1 formiga plug-in para copiar a guerra para o diretório webapps do tomcat depois de ter sido embalado. Tomcat irá detectar a nova guerra e deve hot-implantá-lo.

I have to admit, I don't know much about the plugin for maven, but I do everything in a simple script that cleans the work directories as well (don't know if the maven plugin cleans the work directories).

CALL mvn clean install
CALL rm C:\apps\tomcat\webapps\Foo.war 
CALL rm -rdf C:\apps\tomcat\webapps\foo
CALL rm -rdf C:\apps\tomcat\work\Catalina
CALL copy C:\webapps\workspace\Foo\target\Foo.war C:\apps\tomcat\webapps\Foo.war /y

(I know, -1 for MS scripting)

The point is you generally want to clean the work directory and the webapps directory and the Maven 1 ant plugin does not do this (as far as I know if, and read from the link provided). Tomcat is "supposed" to recreate the class files in these directories when it explodes the war file, but anybody who has worked with it long enough knows: this isn't always the case.

Therefore, if the plugin does not clean these directories, it's useless as far as I am concerned. Write yourself a cheap little script like the one provided. It takes 2 minutes.

webappDirectory can be configured for maven-war-plugin to deploy exploded war. Nothing special is needed, just run maven install.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
    <webappDirectory>path/to/server/deploy/dir</webappDirectory>
</configuration>
</plugin>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top