Maven定制部署到本地容器
Maven定制部署到本地容器
执行步骤:
- Maven先使用maven-dependency-plugin将依懒包copy到dependency目录。
- 用maven-antrun-plugin将package之后的目标文件和dependency目录下的文件copy到指定目录(如tomcat,jboss的deploy目录)。
注:根据需要替换deploy目录,我的是 d:/jboss/deploy
plugins配置
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo message="ant message echo" />
<echo
message="packageName:${project.build.directory}\${project.build.finalName}.${project.packaging}" />
<copy todir="d:/jboss/deploy">
<fileset dir="${project.build.directory}">
<include name="${project.build.finalName}.${project.packaging}" />
</fileset>
<fileset dir="${project.build.directory}/dependency">
<include name="*.jar" />
</fileset>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>