Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 551129

Summary: Circular dependency error reported that could be resolved due to main and test build separation
Product: [Eclipse Project] JDT Reporter: Eric Milles <eric.milles>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED MOVED QA Contact:
Severity: normal    
Priority: P3 CC: loskutov, pspeed-eclipse
Version: 4.13   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug
Attachments:
Description Flags
Example of circular dependencies between test and main sources
none
Sample project illustrating the incorrect cyclic dependency error. pspeed-eclipse: review?

Description Eric Milles CLA 2019-09-16 11:01:30 EDT
Consider the following use case that currently reports circular project dependency errors:

* Project A main sources are core/framework code

* Project B main sources depend on Project A main sources

* Project A test sources depend on Project B main sources (for some facility they provide that makes testing easier)

Since Eclipse 4.8 (Photon), we have been able to indicate to Eclipse that main and test sources are different and they are indeed built separately.  However, the circular dependency detection does not account for this new separation.  Since there is no circular dependency between Project A and B main sources, they should be able to compile normally.  Then Project A and B test sources.
Comment 1 Eric Milles CLA 2019-09-16 11:07:18 EDT
Created attachment 279899 [details]
Example of circular dependencies between test and main sources

The comes from the Apache Groovy project (https://github.com/apache/groovy), which has Gradle submodules.  The core project's tests depend on the subprojects groovy-ant, groovy-xml, groovy-test, groovy-macro and groovy-dateutil.
Comment 2 Eric Milles CLA 2021-02-02 15:34:51 EST
I also tried using the "without_test_code" attribute, which I had missed.  It is still reporting a cycle.  If I delete the errors and try to build either project first, there is an error saying the dependent project must be built first.

/ProjectA
  .classpath
    <classpathentry kind="src" path="src/main"/>
    <classpathentry kind="src" path="src/test"><!-- tests ProjectA using ProjectB fixtures -->
      <attributes>
        <attribute name="test" value="true" />
      </attributes>
    </classpathentry>
    <classpathentry kind="src" path="/ProjectB" combineaccessrules="false">
      <attributes>
        <attribute name="test" value="true" />
        <attribute name="without_test_code" value="true" />
      </attributes>
    </classpathentry>

/ProjectB
  .classpath
    <classpathentry kind="src" path="src/main"/><!-- provides test support using ProjectA API -->
    <classpathentry kind="src" path="src/test">
      <attributes>
        <attribute name="test" value="true" />
      </attributes>
    </classpathentry>
    <classpathentry kind="src" path="/ProjectA" combineaccessrules="false">
      <attributes>
        <attribute name="without_test_code" value="true" />
      </attributes>
    </classpathentry>
Comment 3 Eclipse Genie CLA 2023-02-21 11:39:25 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Paul Speed CLA 2023-05-16 18:27:26 EDT
Created attachment 289072 [details]
Sample project illustrating the incorrect cyclic dependency error.

I've attempted to create a "simple as possible" project that illustrates the issue.  Two projects: framework and basic.  Basic depends on interfaces from framework.  Framework depends on basic for tests only.

I will note that as compared to our real project, the 'basic' dependency also appears in the "Java Build Path -> Libraries" tab.  I'm a bit new to Eclipse so it's possible I have missed something in the setup of these projects.  However, on our real project this bug is also evident and that project lists the test dependency only in the 'Java Build Path -> Projects' tab.
Comment 5 Andrey Loskutov CLA 2023-05-17 02:42:26 EDT
(In reply to Paul Speed from comment #4)
> Created attachment 289072 [details]
> Sample project illustrating the incorrect cyclic dependency error.
> 
> I've attempted to create a "simple as possible" project that illustrates the
> issue.  Two projects: framework and basic.  Basic depends on interfaces from
> framework.  Framework depends on basic for tests only.
> 
> I will note that as compared to our real project, the 'basic' dependency
> also appears in the "Java Build Path -> Libraries" tab.  I'm a bit new to
> Eclipse so it's possible I have missed something in the setup of these
> projects.  However, on our real project this bug is also evident and that
> project lists the test dependency only in the 'Java Build Path -> Projects'
> tab.

Bugzilla is not used anymore for bug tracking.
Please report this issue at https://github.com/eclipse-jdt/eclipse.jdt.core/issues .
Please also make sure you have tried to reproduce with latest 4.27 Eclipse.