【问题标题】:How to link source from outside of maven project and use that linked source for further development.?如何从 Maven 项目外部链接源代码并使用该链接源代码进行进一步开发。?
【发布时间】:2015-06-14 15:27:32
【问题描述】:

我的问题类似于link source using maven

如果我遵循上述问题的答案,我可以在我的最终战争文件中包含一些额外的类,这些类将由 maven 生成。

但我的要求是,我的 IDE(Eclipse) 应将其视为当前项目中的附加源。所以我会有一个额外的源文件夹(不是手动添加的)。此附加源包含一些将由当前项目使用的通用类。

这里我不想手动添加这个源文件夹。让 maven 完成这项工作,这样我就可以为一些常见的类和战争中的相同源类提供额外的源。

有人可以帮忙吗?提前致谢。

【问题讨论】:

  • 检查您使用的 Eclipse 版本以及您使用的 m2e 版本。它应该开箱即用。您的构建是否可以在命令行上正常运行?
  • 我使用的是 Eclipse Kepler 4.3 SR2,m2e 版本是 1.4.0.20130601。抱歉,我不熟悉 maven 命令行执行,因为我在 Eclipse 中使用 m2e 插件。
  • 你应该先在命令行上运行你的构建,如果它有效,而不是进入你的 IDE....
  • 感谢您宝贵的 cmets @khmarbaise。我将尝试构建并让您知道..

标签: java eclipse maven-2 pom.xml m2eclipse


【解决方案1】:

要添加源,您可以使用以下标签

<repositories>
    <repository>
        <id>file.repo</id>
        <url>file://url/repo</url>
    </repository>
</repositories>

或者你也可以添加

<pluginRepositories>
     <pluginRepository>
           <id></id>
           <name></name>
           <url>*your source*</url>
           <releases><enabled>true</enabled></releases>
           <snapshots><enabled>true</enabled></snapshots>
     </pluginRepository>
</pluginRepositories>

【讨论】:

  • 将不起作用,因为存储库用于二进制资源,或者换句话说,已经编译和打包的工件是 jar 文件。
  • 我们不能使用类似下面的东西吗? file.repofile://url/repo
  • 感谢您的回答。我尝试了上面的代码..但不工作..你能提供任何其他方法@khmarbaise ..?
猜你喜欢
  • 1970-01-01
  • 2014-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多