使用cargo-maven2-plugin热门部署到GlassFish,如何配置?

时间:2010-07-28 11:11:10

标签: maven-2 glassfish maven-cargo

我是否理解this page来自Cargo Maven插件不支持对GlassFish 3.x进行热远程部署?如果我错了,我如何配置它以支持这种类型的操作?

也许我应该使用其他一些插件?我想通过HTTP以“热”模式部署到GlassFish远程安装。

2 个答案:

答案 0 :(得分:0)

这是我到目前为止所做的:

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.4</version>
  <executions>
    <execution>
      <phase>package</phase>
      <configuration>
        <tasks>
          <tempfile property="ant.temp-ear" deleteonexit="true" destdir="/tmp" />
          <copy
            file="${project.build.directory}/${project.build.finalName}.${project.packaging}" 
            tofile="${ant.temp-ear}" verbose="true" />
          <exec executable="${glassfish.home}/glassfish/bin/asadmin" 
            failonerror="true">
            <arg value="--user=${glassfish.username}"/>
            <arg value="--passwordfile=${glassfish.passwordfile}"/>
            <arg value="--interactive=false"/>
            <arg value="--host=${glassfish.host}"/>
            <arg value="--port=${glassfish.adminport}"/>
            <arg value="deploy"/>
            <arg value="--force"/>
            <arg value="--name=${project.artifactId}"/>
            <arg value="${ant.temp-ear}"/>
          </exec>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>

完美无缺,但asadmin(我认为整个GlassFish)必须安装在执行mvn的同一台机器上。

是否可以使用Cargo插件执行相同的任务?

答案 1 :(得分:0)

这会回答你的问题吗?

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <configuration>
                <container>
                    <containerId>glassfish3x</containerId>
                    <type>remote</type>
                </container>
                <configuration>
                    <type>runtime</type>
                    <properties>
                        <cargo.hostname>dev-server-01</cargo.hostname>
                        <cargo.servlet.port>8080</cargo.servlet.port>
                        <cargo.remote.username>user</cargo.remote.username>
                        <cargo.remote.password>pass</cargo.remote.password>
                        <cargo.glassfish.domain.name>domain-name</cargo.glassfish.domain.name>
                        <cargo.glassfish.adminPort>4848</cargo.glassfish.adminPort>
                    </properties>
                </configuration>
                <deployables>
                    <deployable>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>${project.artifactId}</artifactId>
                        <type>war</type>
                    </deployable>
                </deployables>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.glassfish.main.deployment</groupId>
                    <artifactId>deployment-client</artifactId>
                    <version>3.1.2.2</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>