Maven pom.xml 配置笔记

拷贝jar包到指定目录

使用maven-antrun-plugin,可以将jar包拷贝到指定目录下
以下示例是将jar包拷贝到上级路径的target目录下,父目录使用${project.parent.relativePath}/..是因为如果只用${project.parent.relativePath}返回的是pom

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-antrun-pluginartifactId>
                <version>1.7version>
                <executions>
                    <execution>
                        <id>copy-jarsid>
                        <phase>packagephase>
                        <goals>
                            <goal>rungoal>
                        goals>
                        <configuration>
                            <target>
                                <echo message="copy jars"/>
                                <copy file="target/${project.artifactId}-${project.version}.jar"
                                      todir="${project.parent.relativePath}/../target">
                                copy>
                            target>
                        configuration>
                    execution>
                executions>
            plugin>
        plugins>
    build>

你可能感兴趣的:(Maven)