简体   繁体   English

Maven指定源位置

[英]Maven Specify Source Location

Is there a way to tell maven where your sources are locally in a pom.xml with a relative path? 有没有一种方法可以告诉Maven您的源在带有相对路径的pom.xml中的本地位置? We have lots of projects in our SVN repo, and locally I mirror the repository. SVN存储库中有很多项目,在本地我镜像存储库。 In my IntelliJ IDEA I can do this and modify my local source code for a foreign dependency and its quite useful in some situations. 在我的IntelliJ IDEA中,我可以执行此操作,并为外部依赖项修改本地源代码,并且在某些情况下它非常有用。

To be clear this is different from Can I configure sources location for Maven? 为了清楚起见,这与我可以为Maven配置源位置不同吗? in two ways. 有两种方式。 One its a few years later in time and two I want to use sources already existing locally that share the same relative path as in SVN. 几年后,我想使用其中之一,而我想使用本地已有的与SVN共享相同相对路径的源。

My question is also different from I see that you can tell maven to download sources uploaded to your repository in this post Get source JARs from Maven repository because I dont want to involve our maven repo. 我的问题也与我看到的不同,在这篇文章中,您可以告诉Maven下载上载到资源库的源,因为我不想涉及我们的Maven回购,所以从Maven资源库获取源JAR

There are 2 directions for your question. 您的问题有2个指示。

Direction I. Create own repostitory (It also called corporate repository ) 方向I.创建自己的重新存储(也称为公司存储库
1. Create own maven repository 1.创建自己的Maven存储库
See: https://maven.apache.org/guides/introduction/introduction-to-repositories.html ---> at section: Internal Repositories . 请参阅: 内部存储库部分中的https://maven.apache.org/guides/introduction/introduction-to-repositories.html --->。
2. Inform IntelliJ IDEA use own repository in pom.xml file by figure out your repository address. 2.通过找出您的存储库地址,通知pom.xml文件中的IntelliJ IDEA使用自己的存储库。


Direction II. 方向二。
You want IntelliJ IDEA doesn't download existing artifacts from internet. 您希望IntelliJ IDEA不会从Internet下载现有工件。

Yes, If artifacts are existing. 是的, 如果存在工件。 IntelliJ IDEA import to your project automatically. IntelliJ IDEA自动导入到您的项目。 You don't need do anything. 您什么都不需要做。

Local repository at: ...\\.m2\\repository (3 dots at the start, in Windows operating system only). 本地存储库位于: ...\\.m2\\repository (开头为3个点,仅在Windows操作系统中)。

You also maybe want put your artifacts to ...\\.m2\\repository , and must follow Maven's predefined structure. 您可能还希望将工件放入...\\.m2\\repository ,并且必须遵循Maven的预定义结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM