0

I have a maven project that consists of a couple of modules. The main structure and setup is this:

  • /project/pom.xml: packaging=pom, lists all sub-modules, version: TRUNK-SNAPSHOT
  • /project/core-module/pom.xml: packaging=jar
  • /project/war-module/pom.xml: packaging=war, depends on core-module with ${project.version}

I use IntelliJ for development if that somehow matters.

When I now develop/run/debug the war-module and meanwhile I change code in the core-module things get out of hand. The running war-module application (running via jetty:run-exploded) uses the core-module which is "installed" in my local ~/.m2/ repository instead of the current build. It doesen't matter if I do a "rebuild project" in IntelliJ or a mvn clean before running.

My question is: do I have to mvn install each time, can I circumvent the installed packages or do I have to change packaging options?

4

1 回答 1

1

长话短说,答案是:是的,在多模块项目中,您必须mvn install每次都运行,以便war-module编译您的依赖项并将其安装在本地存储库中。

但是,对于本地测试,我通常建议使用 IDE 功能来测试我们的本地更改。使用 IntelliJ 非常容易配置,它支持许多不同的应用程序服务器。

这样做的原因是:想象一下在一个大型团队中工作,使用企业共享存储库来保存您的公共依赖项,而无需将它们发布到 Maven 中心。如果您的任何同事对core-module、提交它们并通过您的内部共享 repo 使它们可用,那么 Maven 将下载该依赖项,然后用于运行 Jetty 插件。

这样做的好处是您将使用这些依赖项的最新版本进行测试,坏处是这些依赖项的代码与工作副本中的代码不同。

于 2013-01-24T14:12:37.173 回答