欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Maven定制部署到本地容器 博客分类: maven mavendeploy项目管理部署 

程序员文章站 2024-03-13 11:14:03
...

Maven定制部署到本地容器

执行步骤:

  1. Maven先使用maven-dependency-plugin将依懒包copy到dependency目录。
  2. 用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>