maven 安装到 .m2 和另一个文件夹

maven install to .m2 AND another folder

我有大量项目要迁移到 Maven...但是我有一些限制。

其中之一是将构建结果保留在某个文件夹中。

我正在尝试让 Maven 将项目工件安装到本地存储库(像往常一样,.m2,因为它们之间存在依赖关系)并将 jars/wars/ears 文件放入自定义文件夹中之前提到过。

我已经用过这个:

<project>
    ...
    <build>
        <directory>${basedir}/../../target/</directory>
        <plugins>
        </plugins>
    </build>
</project>

proyect 包含几个 .ear 和 .jar,我们曾经 运行 许多 ant 来获取在特定文件夹中生成的那些文件。

我正在尝试将这些文件从 maven 放入该文件夹,所以我在每个 pom 中都显示了完全相同的代码,但是当我 运行 maven 时,除了最后一个以外的所有文件都被存放了在文件夹中(因为我想每个 pom 都会清理那个文件夹)

如果您只想将包复制到其他路径,您可以使用maven-antrun-plugin来执行此操作。

您可以像这样配置插件:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>config</id>
            <phase>install</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <target>
                    <copy todir="${the.custom.folder}" overwrite="true">
                        <fileset dir="${project.build.directory}" includes="**/*.jar **/*.ear" />
                    </copy>
                </target>
            </configuration>
        </execution>
    </executions>
</plugin>

还可以查看一些工件存储库,例如 Artifactory or Nexus