使用maven分开本地下载和安装存储库? [英] separate local download and install repositories using maven?

查看:108
本文介绍了使用maven分开本地下载和安装存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想不时地从头开始重建我的项目结构,并想清除已建立的存储库来做到这一点.但是,我不想从Maven Central和其他存储库中删除下载的文件.有没有一种简单的方法告诉M​​aven将我构建的工件安装到单独的存储库中,即.还有一个用来存储下载的外部文件吗?

I want to rebuild my project structure from scratch from time to time and want to purge the built repository in order to do that. However, I don't want to remove downloaded files from maven central and other repositories. Is there a simple way to tell maven to install my built artifacts into a separate repository, ie. other then the one used to store downloaded, external files?

不是在谈论deploy,只是在mvn install.

更新

我找到了一个替代解决方案,该解决方案仅使用一个本地存储库来处理已下载和自建的工件:自建的工件随附有名为"maven-metadata-local.xml"的文件,因此我选择了要清除的存储库目录现在基于该文件的存在...

I found an alternate solution using only one local repository for both downloaded and self-built artifacts: the self-built ones are accompanied by files called "maven-metadata-local.xml", so I select the repository directories to purge based on the existence of that file now...

推荐答案

您不能使用您可以通过将系统变量maven.repo.local设置到另一个位置(或告诉Maven使用特定的settins.xml)来更改 ).但是,目前,无法将Maven配置为将特定的工件安装到与获取下载的工件的位置不同的本地存储库中.

You cannot do that with the install goal. maven-install-plugin will install the artifact to the same local repository that is used to fetch downloaded artifacts from. By default, this is ${user.home}/.m2/repository. You change that by setting the system variable maven.repo.local to another location (or by telling Maven to use a specific settins.xml). However, at the moment, Maven can't be configured to install specific artifacts to a different local repository than where it is fetching downloaded artifacts.

可能的解决方法是声明 install-file 目标,绑定到install阶段,并声明该目标以将您想要的所有工件安装到指定的本地存储库.

A possible work-around would be to declare an execution of the install-file goal, bound to the install phase and declare it to install all of the artifacts you want to to the specified local repository.

<plugin>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.5.2</version>
    <executions>
        <execution>
            <phase>install</phase>
            <goals>
                <goal>install-file</goal>
            </goals>
            <configuration>
                <file><!-- path to artifact to install --></file>
                <pomFile><!-- path to POM of artifact --></pomFile>
                <localRepositoryPath><!-- path to repository you want to install to --></localRepositoryPath>
            </configuration>
        </execution>
    </executions>
</plugin>

这篇关于使用maven分开本地下载和安装存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆