Jör*_*örg 11
根据http://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html,您可以将刚构建的工件复制到特定目录:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-installed</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
</artifactItem>
</artifactItems>
<outputDirectory>some-other-place</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
Run Code Online (Sandbox Code Playgroud)
如果要将文件复制到Web服务器(本地或远程),可以使用Maven上传插件:
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-upload-plugin</artifactId>
<version>1.1</version>
<configuration>
<resourceSrc>
${project.build.directory}/${project.build.finalName}.${project.packaging}
</resourceSrc>
<resourceDest>${jboss.deployDir}</resourceDest>
<serverId>${jboss.host}</serverId>
<url>${jboss.deployUrl}</url>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
要以智能方式配置参数,我使用maven配置文件:
<profiles>
<!-- local deployment -->
<profile>
<id>developpement</id>
<properties>
<jboss.host>localhost</jboss.host>
<jboss.deployDir>appli/jboss-4.0.4.GA/server/default/deploy/</jboss.deployDir>
<jboss.deployUrl>file://C:/</jboss.deployUrl>
</properties>
</profile>
<!-- distant deployment -->
<profile>
<id>validation</id>
<properties>
<jboss.host>ENV_val</jboss.host>
<jboss.deployDir>/home/envval/jboss/server/default/deploy/</jboss.deployDir>
<jboss.deployUrl>scp://PROJECT_LAN_HOST</jboss.deployUrl>
</properties>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
我创建了一个"ant启动器",通过在Eclipse ant视图下单击来使用它:
<target name="copy war to JBoss local" description="Copy war to local JBoss">
<maven goal="upload:upload" options="-Pdeveloppement" />
</target>
Run Code Online (Sandbox Code Playgroud)
但您可以在命令行上运行它:
mvn upload:upload -Pdeveloppement
Run Code Online (Sandbox Code Playgroud)
顺便说一句,对于远程部署,您可能需要登录密码才能使用scp.您必须将它们添加到Maven settings.xml文件中:
<settings>
...
<servers>
<server>
<id>ENV_val</id>
<username>login</username>
<password>password</password>
</server>
</servers>
...
</settings>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
37208 次 |
| 最近记录: |