【发布时间】:2015-05-22 23:02:21
【问题描述】:
我有两个模块,组件和应用程序。由于构建过程后期的依赖冲突(谷歌协议缓冲区),组件模块被着色。
<!-- snip from Component's pom.xml -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<relocations>
<relocation>
<pattern>com.google.protobuf</pattern>
<shadedPattern>my.package.protocols.shaded.com.google.protobuf</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
应用程序依赖于组件模块。但是,Application 中的源文件不能引用 Component 所依赖的着色库。这对于与组件交互至关重要。
<-- snip from Application's pom.xml -->
<dependency>
<groupId>my-group</groupId>
<artifactId>component</artifactId>
<version>${project.version}</version>
</dependency>
即使 IntelliJ 找不到导入,Maven 构建工作正常。我错过了什么/做错了什么?
【问题讨论】:
-
我也遇到了同样的问题(与您描述的情况完全相同)。在其他 SO 帖子中,他们建议转到 File -> Invalidate Caches / Restart。我有时而不是有时看到这项工作(这一次,它不起作用)。例如,对于较早的分支,使缓存无效并重新启动有效,但对于另一个分支,这不起作用。我想知道如何解决这个问题。
-
我最终将阴影模块分离到它自己的项目中。当然不是一个通用的解决方案,但由于 CI 的原因,它最终在我们的案例中工作得更好。但是,我将 Q 保持打开状态,希望有另一种解决方案。如果没有,我会用 JetBrains 开票。
-
您有机会使用 JetBrains 开票吗?我仍然卡住了..不幸的是,我在一个大项目上,并且没有选择将 maven 模块重构到自己的项目中。
-
这周我没有休假。如果更紧急,请随时打开。
-
您使用的是哪个版本的 IntelliJ?
标签: maven intellij-idea