java 单个 pom.xml 中的多个 install:install-file

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10802280/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 02:38:34  来源:igfitidea点击:

Multiple install:install-file in a single pom.xml

javamavenmaven-3

提问by Thorbj?rn Ravn Andersen

(Please read at least this before answering: This is a temporary measure! No, we do not want to set up a local repository manager and manually run a script)

(请在回答之前至少阅读此内容:这是临时措施!不,我们不想设置本地存储库管理器并手动运行脚本)

We have a legacy project with a few dependencies which we have a local copy of including source and javadoc, and which has been proven to work well in production, but which is not available in the same quality in Central. We want to use those jars we already have.

我们有一个带有一些依赖项的遗留项目,我们有一个包含源代码和 javadoc 的本地副本,并且已被证明在生产中运行良好,但在 Central 中无法以相同的质量提供。我们想使用我们已经拥有的那些罐子。

I have found that I can manually run a suitably complex mvn install:install-filecommand to get the artifacts injected in the repository of the local machine, but I would like to have it work as part of the normal maven build of our various modules.

我发现我可以手动运行一个适当复杂的mvn install:install-file命令来将工件注入到本地机器的存储库中,但我希望它作为我们各种模块的正常 maven 构建的一部分工作。

Given I have an otherwise blank module containing multiple jars which each need to be inserted with an install:install-filehow should I do this in my pom.xml to be fully conformant with the normal Maven build?

鉴于我有一个包含多个 jar 的空白模块,每个模块都需要插入,install:install-file我应该如何在我的 pom.xml 中执行此操作以完全符合正常的 Maven 构建?

Or can I just attach multiple jars to be the output of the module and somehow attach javadoc and source too)?

或者我可以只附加多个 jars 作为模块的输出,并以某种方式附加 javadoc 和源代码)?

(and, please, no suggestion about submitting to central or setting up a local repository manager. This is a temporary solution until we have an opportunity to upgrade to a newer version of the dependencies)

(并且,请不要建议提交到中央或设置本地存储库管理器。这是一个临时解决方案,直到我们有机会升级到更新版本的依赖项)

回答by jtahlborn

I would imagine something like this would work (this will install it on every build):

我想像这样的东西会起作用(这将在每个构建中安装它):

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <executions>
                <execution>
                    <id>inst_1</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                    <configuration>
                        <!-- config for file 1 -->
                    </configuration>
                </execution>
                <execution>
                    <id>inst_2</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                    <configuration>
                        <!-- config for file 2 -->
                    </configuration>
                </execution>
                <!-- execution file 3... -->
            </executions>
        </plugin>            
    </plugins>
</build>