循环依赖项目的 Eclipse m2e 插件问题
Eclipse m2e plugin issue for cyclic dependent projects
我对循环依赖项目的 m2e 插件有疑问。
首先,我知道循环依赖是不好的,maven 也不允许它,应该避免等等,但是我们的遗留项目在没有改变项目结构的情况下进行了 mavenized(继续循环依赖)。
以前,将每个项目添加到其他项目构建路径并将循环依赖性构建路径问题设置为警告是解决方法。这样,我可以在一个项目中进行更改,并立即在另一个项目中看到效果。
现在项目已经 mavenized,我想通过启用 m2e 工作空间解析(通过选中 "Resolve dependencies from workspace projects" 选项)来实现相同的工作空间环境。
在 eclipse neon(版本:Neon.3 Release (4.6.3) Build id:20170314-1500)和 m2e 版本 1.7.0.20160603-1933 中,这是可能的。尽管构建路径中存在循环,但相应的 maven 依赖项已从工作区项目中解决。
但是,在 eclipse 2019-09 R(版本:2019-09 R (4.13.0) Build id:20190917-1200,m2e 版本为 1.13.0.20190716-1624)及以后的版本中,构建结果陷入无限循环。
对于两个循环项目 MY PROJECT A 和 MY PROJECT B,maven 工件 ID 分别为 MYPROJECTAARTIFACTID、MYPROJECTBARTIFACTID,下面是 2019-09 R 版本无限构建的 m2e 日志(我无法从 neon 版本收集日志)。
重复一下,我知道 maven 本身不允许循环项目设置,但通常 eclipse 允许它,即使对于具有 maven 性质的项目也是如此。
如何在最新的 eclipse 版本中实现相同的功能?
2020-05-22 21:19:26,588 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.builder.MavenBuilder - Building project MY PROJECT B
2020-05-22 21:19:26,683 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:26,697 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.ProjectRegistryManager - Refreshing: [L/MY PROJECT B/pom.xml]
2020-05-22 21:19:26,709 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:26,712 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Reading 1 Maven project(s): [D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml]
2020-05-22 21:19:26,764 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultUpdatePolicyAnalyzer - Skipped remote request for ...
2020-05-22 21:19:26,868 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Read 1 Maven project(s) in 156 ms
2020-05-22 21:19:27,036 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.m.MavenMarkerManager - Created marker 'GroupId is duplicate of parent groupId' on resource '/MY PROJECT B/pom.xml'.
2020-05-22 21:19:27,043 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:27,086 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loading lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:27,670 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.c.DefaultDependencyCollector - Dependency collection stats: {ConflictMarker.analyzeTime=637200, ConflictMarker.markTime=709300, ConflictMarker.nodeCount=118, ConflictIdSorter.graphTime=487300, ConflictIdSorter.topsortTime=290200, ConflictIdSorter.conflictIdCount=45, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=3881500, ConflictResolver.conflictItemCount=72, DefaultDependencyCollector.collectTime=398895400, DefaultDependencyCollector.transformTime=7801200}
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] INFO o.e.m.c.i.l.LifecycleMappingFactory - Using org.eclipse.m2e.jdt.JarLifecycleMapping lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loaded lifecycle mapping in 699 ms for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - MY PROJECT B is configured by :
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.jdt.javaConfigurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.java.unsupportedDependencyTypeConfigurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jpa.configurator.jdt
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.utility.configurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.webfragment.configurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.sonatype.m2e.mavenarchiver.jararchiverconfigurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jaxrs.configurator
2020-05-22 21:19:27,786 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolving dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT
2020-05-22 21:19:27,786 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Reading Maven project: D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml
2020-05-22 21:19:27,790 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultUpdatePolicyAnalyzer - Skipped remote request for com.my.company:... locally cached metadata up-to-date.
2020-05-22 21:19:28,529 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.c.DefaultDependencyCollector - Dependency collection stats: {ConflictMarker.analyzeTime=925200, ConflictMarker.markTime=269600, ConflictMarker.nodeCount=328, ConflictIdSorter.graphTime=1694200, ConflictIdSorter.topsortTime=470600, ConflictIdSorter.conflictIdCount=88, ConflictIdSorter.conflictIdCycleCount=48, ConflictResolver.totalTime=7407900, ConflictResolver.conflictItemCount=309, DefaultDependencyCollector.collectTime=730670400, DefaultDependencyCollector.transformTime=10784800}
2020-05-22 21:19:28,539 [Worker-7: Building Workspace] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/MY PROJECT A: com.my.company:MYPROJECTAARTIFACTID:1.0.1-SNAPSHOT with classifier to /MY PROJECT A/target/classes
2020-05-22 21:19:28,598 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Read Maven project: D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml in 812 ms
2020-05-22 21:19:28,598 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolved dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT in 812 ms
2020-05-22 21:19:28,600 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:28,601 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loading lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,607 [Worker-1: Decoration Calculation] DEBUG o.e.j.i.storage.file.FileSnapshot - file=C:\Program Files\Git\etc\gitconfig, isRacyClean=false, read=2020-05-22 21:18:57.612000000, lastModified=2020-04-28 20:51:11.602527000, delta=2075266009473000 ns, racy<=2500000000 ns
2020-05-22 21:19:28,607 [Worker-1: Decoration Calculation] DEBUG o.e.j.i.storage.file.FileSnapshot - file=C:\Program Files\Git\etc\gitconfig, is unmodified
.......
2020-05-22 21:19:28,677 [Worker-7: Building Workspace] INFO o.e.m.c.i.l.LifecycleMappingFactory - Using org.eclipse.m2e.jdt.JarLifecycleMapping lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loaded lifecycle mapping in 77 ms for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - MY PROJECT B is configured by :
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.jdt.javaConfigurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.java.unsupportedDependencyTypeConfigurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jpa.configurator.jdt
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.utility.configurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.webfragment.configurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.sonatype.m2e.mavenarchiver.jararchiverconfigurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jaxrs.configurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolving dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Reading Maven project: D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml
2020-05-22 21:19:28,689 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.c.DefaultDependencyCollector - Dependency collection stats: {ConflictMarker.analyzeTime=288800, ConflictMarker.markTime=102300, ConflictMarker.nodeCount=328, ConflictIdSorter.graphTime=336300, ConflictIdSorter.topsortTime=260900, ConflictIdSorter.conflictIdCount=88, ConflictIdSorter.conflictIdCycleCount=48, ConflictResolver.totalTime=3849800, ConflictResolver.conflictItemCount=309, DefaultDependencyCollector.collectTime=5078800, DefaultDependencyCollector.transformTime=4849700}
2020-05-22 21:19:28,697 [Worker-7: Building Workspace] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/MY PROJECT A: com.my.company:MYPROJECTAARTIFACTID:1.0.1-SNAPSHOT with classifier to /MY PROJECT A/target/classes
2020-05-22 21:19:28,739 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Read Maven project: D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml in 61 ms
2020-05-22 21:19:28,739 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolved dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT in 61 ms
2020-05-22 21:19:28,740 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:28,741 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loading lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] INFO o.e.m.c.i.l.LifecycleMappingFactory - Using org.eclipse.m2e.jdt.JarLifecycleMapping lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loaded lifecycle mapping in 63 ms for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - MY PROJECT B is configured by :
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.jdt.javaConfigurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.java.unsupportedDependencyTypeConfigurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jpa.configurator.jdt
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.utility.configurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.webfragment.configurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.sonatype.m2e.mavenarchiver.jararchiverconfigurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jaxrs.configurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolving dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT
................
----------------------------编辑1-------- ------------------
示例项目已添加到 github ( https://github.com/simpleusr/eclipseproblem ) 以重现问题。它也因最新的 eclipse 版本而失败:2020-03 (4.15.0) Build id:20200313-1211
Eclipse 允许编译具有循环依赖性的多个项目。但是在这里,解决 Maven 依赖关系会导致无限循环,这是另一回事。为了解析和下载依赖项,Eclipse 使用 Eclipse IDE.
附带的嵌入式 Maven
因为Maven 不允许循环依赖,你也不能从命令行构建它。在 Eclipse 中,它可以在 pom.xml
文件中没有对其他项目的无效 Maven 依赖项的情况下工作,方法是手动将其他项目添加到 Java 构建路径并允许 Java 的循环依赖项编译器。但是这些手动设置将在 Maven > 更新项目....
中被覆盖
如果你想使用 Maven 来构建你的项目,你有两个选择:
- 将所有内容放入一个单个 Maven 项目,可能有多个源文件夹。您可以在 post 处理步骤中将构建的 JAR 拆分为多个 JAR。这与多个循环相互依赖的项目具有相同的缺点:如果不是具有所有依赖项的整个代码都在类路径上,则可能会在 运行 时间丢失东西。
- 消除循环。根据我的经验,这就是我的建议,因为投入的时间(可能数周)会在很长一段时间内得到回报 运行(模块化代码比意大利面条代码更有趣)。
我对循环依赖项目的 m2e 插件有疑问。
首先,我知道循环依赖是不好的,maven 也不允许它,应该避免等等,但是我们的遗留项目在没有改变项目结构的情况下进行了 mavenized(继续循环依赖)。
以前,将每个项目添加到其他项目构建路径并将循环依赖性构建路径问题设置为警告是解决方法。这样,我可以在一个项目中进行更改,并立即在另一个项目中看到效果。
现在项目已经 mavenized,我想通过启用 m2e 工作空间解析(通过选中 "Resolve dependencies from workspace projects" 选项)来实现相同的工作空间环境。
在 eclipse neon(版本:Neon.3 Release (4.6.3) Build id:20170314-1500)和 m2e 版本 1.7.0.20160603-1933 中,这是可能的。尽管构建路径中存在循环,但相应的 maven 依赖项已从工作区项目中解决。
但是,在 eclipse 2019-09 R(版本:2019-09 R (4.13.0) Build id:20190917-1200,m2e 版本为 1.13.0.20190716-1624)及以后的版本中,构建结果陷入无限循环。 对于两个循环项目 MY PROJECT A 和 MY PROJECT B,maven 工件 ID 分别为 MYPROJECTAARTIFACTID、MYPROJECTBARTIFACTID,下面是 2019-09 R 版本无限构建的 m2e 日志(我无法从 neon 版本收集日志)。
重复一下,我知道 maven 本身不允许循环项目设置,但通常 eclipse 允许它,即使对于具有 maven 性质的项目也是如此。
如何在最新的 eclipse 版本中实现相同的功能?
2020-05-22 21:19:26,588 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.builder.MavenBuilder - Building project MY PROJECT B
2020-05-22 21:19:26,683 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:26,697 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.ProjectRegistryManager - Refreshing: [L/MY PROJECT B/pom.xml]
2020-05-22 21:19:26,709 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:26,712 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Reading 1 Maven project(s): [D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml]
2020-05-22 21:19:26,764 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultUpdatePolicyAnalyzer - Skipped remote request for ...
2020-05-22 21:19:26,868 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Read 1 Maven project(s) in 156 ms
2020-05-22 21:19:27,036 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.m.MavenMarkerManager - Created marker 'GroupId is duplicate of parent groupId' on resource '/MY PROJECT B/pom.xml'.
2020-05-22 21:19:27,043 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:27,086 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loading lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:27,670 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.c.DefaultDependencyCollector - Dependency collection stats: {ConflictMarker.analyzeTime=637200, ConflictMarker.markTime=709300, ConflictMarker.nodeCount=118, ConflictIdSorter.graphTime=487300, ConflictIdSorter.topsortTime=290200, ConflictIdSorter.conflictIdCount=45, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=3881500, ConflictResolver.conflictItemCount=72, DefaultDependencyCollector.collectTime=398895400, DefaultDependencyCollector.transformTime=7801200}
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] INFO o.e.m.c.i.l.LifecycleMappingFactory - Using org.eclipse.m2e.jdt.JarLifecycleMapping lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loaded lifecycle mapping in 699 ms for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - MY PROJECT B is configured by :
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.jdt.javaConfigurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.java.unsupportedDependencyTypeConfigurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jpa.configurator.jdt
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.utility.configurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.webfragment.configurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.sonatype.m2e.mavenarchiver.jararchiverconfigurator
2020-05-22 21:19:27,785 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jaxrs.configurator
2020-05-22 21:19:27,786 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolving dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT
2020-05-22 21:19:27,786 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Reading Maven project: D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml
2020-05-22 21:19:27,790 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultUpdatePolicyAnalyzer - Skipped remote request for com.my.company:... locally cached metadata up-to-date.
2020-05-22 21:19:28,529 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.c.DefaultDependencyCollector - Dependency collection stats: {ConflictMarker.analyzeTime=925200, ConflictMarker.markTime=269600, ConflictMarker.nodeCount=328, ConflictIdSorter.graphTime=1694200, ConflictIdSorter.topsortTime=470600, ConflictIdSorter.conflictIdCount=88, ConflictIdSorter.conflictIdCycleCount=48, ConflictResolver.totalTime=7407900, ConflictResolver.conflictItemCount=309, DefaultDependencyCollector.collectTime=730670400, DefaultDependencyCollector.transformTime=10784800}
2020-05-22 21:19:28,539 [Worker-7: Building Workspace] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/MY PROJECT A: com.my.company:MYPROJECTAARTIFACTID:1.0.1-SNAPSHOT with classifier to /MY PROJECT A/target/classes
2020-05-22 21:19:28,598 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Read Maven project: D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml in 812 ms
2020-05-22 21:19:28,598 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolved dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT in 812 ms
2020-05-22 21:19:28,600 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:28,601 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loading lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,607 [Worker-1: Decoration Calculation] DEBUG o.e.j.i.storage.file.FileSnapshot - file=C:\Program Files\Git\etc\gitconfig, isRacyClean=false, read=2020-05-22 21:18:57.612000000, lastModified=2020-04-28 20:51:11.602527000, delta=2075266009473000 ns, racy<=2500000000 ns
2020-05-22 21:19:28,607 [Worker-1: Decoration Calculation] DEBUG o.e.j.i.storage.file.FileSnapshot - file=C:\Program Files\Git\etc\gitconfig, is unmodified
.......
2020-05-22 21:19:28,677 [Worker-7: Building Workspace] INFO o.e.m.c.i.l.LifecycleMappingFactory - Using org.eclipse.m2e.jdt.JarLifecycleMapping lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loaded lifecycle mapping in 77 ms for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - MY PROJECT B is configured by :
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.jdt.javaConfigurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.java.unsupportedDependencyTypeConfigurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jpa.configurator.jdt
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.utility.configurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.webfragment.configurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.sonatype.m2e.mavenarchiver.jararchiverconfigurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jaxrs.configurator
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolving dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT
2020-05-22 21:19:28,678 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Reading Maven project: D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml
2020-05-22 21:19:28,689 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.c.DefaultDependencyCollector - Dependency collection stats: {ConflictMarker.analyzeTime=288800, ConflictMarker.markTime=102300, ConflictMarker.nodeCount=328, ConflictIdSorter.graphTime=336300, ConflictIdSorter.topsortTime=260900, ConflictIdSorter.conflictIdCount=88, ConflictIdSorter.conflictIdCycleCount=48, ConflictResolver.totalTime=3849800, ConflictResolver.conflictItemCount=309, DefaultDependencyCollector.collectTime=5078800, DefaultDependencyCollector.transformTime=4849700}
2020-05-22 21:19:28,697 [Worker-7: Building Workspace] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/MY PROJECT A: com.my.company:MYPROJECTAARTIFACTID:1.0.1-SNAPSHOT with classifier to /MY PROJECT A/target/classes
2020-05-22 21:19:28,739 [Worker-7: Building Workspace] DEBUG o.e.m.c.internal.embedder.MavenImpl - Read Maven project: D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml in 61 ms
2020-05-22 21:19:28,739 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolved dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT in 61 ms
2020-05-22 21:19:28,740 [Worker-7: Building Workspace] DEBUG o.e.a.i.i.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for D:\MAVEN_REPONEW
2020-05-22 21:19:28,741 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loading lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] INFO o.e.m.c.i.l.LifecycleMappingFactory - Using org.eclipse.m2e.jdt.JarLifecycleMapping lifecycle mapping for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - Loaded lifecycle mapping in 63 ms for MavenProject: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT @ D:\LOCALGITREPOS\CYCLE_2019\MYPROJECTBARTIFACTID\MY PROJECT B\pom.xml.
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - MY PROJECT B is configured by :
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.jdt.javaConfigurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.java.unsupportedDependencyTypeConfigurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jpa.configurator.jdt
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.utility.configurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.maven.ide.eclipse.configuration.wtp.webfragment.configurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.sonatype.m2e.mavenarchiver.jararchiverconfigurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.l.LifecycleMappingFactory - - org.eclipse.m2e.wtp.jaxrs.configurator
2020-05-22 21:19:28,804 [Worker-7: Building Workspace] DEBUG o.e.m.c.i.p.r.DefaultMavenDependencyResolver - Resolving dependencies for P/MY PROJECT B: com.my.company:MYPROJECTBARTIFACTID:1.0.1-SNAPSHOT
................
----------------------------编辑1-------- ------------------
示例项目已添加到 github ( https://github.com/simpleusr/eclipseproblem ) 以重现问题。它也因最新的 eclipse 版本而失败:2020-03 (4.15.0) Build id:20200313-1211
Eclipse 允许编译具有循环依赖性的多个项目。但是在这里,解决 Maven 依赖关系会导致无限循环,这是另一回事。为了解析和下载依赖项,Eclipse 使用 Eclipse IDE.
附带的嵌入式 Maven因为Maven 不允许循环依赖,你也不能从命令行构建它。在 Eclipse 中,它可以在 pom.xml
文件中没有对其他项目的无效 Maven 依赖项的情况下工作,方法是手动将其他项目添加到 Java 构建路径并允许 Java 的循环依赖项编译器。但是这些手动设置将在 Maven > 更新项目....
如果你想使用 Maven 来构建你的项目,你有两个选择:
- 将所有内容放入一个单个 Maven 项目,可能有多个源文件夹。您可以在 post 处理步骤中将构建的 JAR 拆分为多个 JAR。这与多个循环相互依赖的项目具有相同的缺点:如果不是具有所有依赖项的整个代码都在类路径上,则可能会在 运行 时间丢失东西。
- 消除循环。根据我的经验,这就是我的建议,因为投入的时间(可能数周)会在很长一段时间内得到回报 运行(模块化代码比意大利面条代码更有趣)。