Comments (7)
Thank you for the detailed explanations.
The problem is independent of Gradle or Buildship and has to be solved in JDT Debug. I have created Issue #327 and provided pull request #328. I hope it will be accepted.
Since Buildship already handles the attribute Without test code correctly, this issue should be closed.
from buildship.
Your projectB/.classpath
file seems not be created by Buildship. There should not exists a classpath entry with path /projectA
:
<classpathentry kind="src" path="/projectA">
<attributes>
<attribute name="without_test_code" value="true"/>
</attributes>
</classpathentry>
In Buildship, references to other projects and external dependencies are handled with the Gradle Classpath Container which is automatically added to the .classpath
file when importing or refreshing the Gradle project.
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
There should be no direct entry for projectA
in the file projectB/.classpath
.
The actual entries of the classpath container can be inspected in the Package or Project Explorer under the folder Project and External Dependencies:
With theses steps you can ensure that the projects will be correctly imported:
- Remove the projects from the Eclipse workspace
- Delete all
.classpath
and.project
files and all.settings
folders - Import the Gradle project again in Eclipse
from buildship.
Hello,
Indeed you're right, it works fine when importing the project as a gradle project.
However, it does not when using gradlew eclipse
+ Import existing project
. Do you know who we might reach for such issue? Is it an issue on gradle that generates a wrong classpath? Is it an issue on eclipse, not interpreting the without_test
correctly? Is it an issue on buildship because, even if the project is not imported as gradle project, my understanding was that buildship was still doing some magic?
For the last option, I've had this understanding because I had to tweak some classpath attributes to make other things work, such as gradle_used_by_scope
. And I mean, I don't think eclipse natively supports this attribute, does it? I've always believed that it was buildship that read these attributes and tweaked the run conf accordingly?
from buildship.
projectA/build.gradle
plugins {
id 'java-library'
id 'eclipse'
}
projectB/build.gradle
plugins {
id 'java-library'
id 'eclipse'
}
dependencies {
implementation project(':projectA')
}
After invoking ./gradlew eclipse
these files are created:
projectA/.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="output" path="bin/default"/>
<classpathentry output="bin/test" kind="src" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
</classpath>
projectB/.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="output" path="bin/default"/>
<classpathentry output="bin/test" kind="src" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
<classpathentry kind="src" path="/projectA">
<attributes>
<attribute name="without_test_code" value="true"/>
</attributes>
</classpathentry>
</classpath>
That looks correct and also importing these as normal projects (and not via Buildship) shows the expected behavior, e.g. the properties for projectB:
MyClass
from projectA
cannot be imported from MyOtherClass
in projectB
.
Could you provide a minimal reproducible example for your concrete case?
from buildship.
Thanks for checking this out.
The best way to reproduce the issue would be to clone https://github.com/sebkur/test-gradle-eclipse
You can tweak the gradle version in gradle-wrapper.properties
if you want, but I tested with both 7.4.2, 7.6.2 and 8.2.1. (with a more recent version of gradle, you'll need to remove the task sourcesJar and artifacts in build.gradle)
Then you run ./gradlew eclipse
and import project in eclipse as a regular project. In the properties of project "util", you'll see that it depends on core
without test code
.
But then, if you try to run test TestResources
in util
, it will fail at :
List<URL> testing = Resources.getAll("testing.txt");
Assert.assertEquals(1, testing.size());
Because it'll find both util/src/test/resources/testing.txt
and core/src/test/resources/testing.txt
. Where it should not have the second one in its classpath.
If you look at the generated command line, you can see the test classpath of core
:
from buildship.
Thanks again for checking this out and for dispatching it (and fixing it!) to the correct project!
from buildship.
@Tiller The pull request #328 has been integrated and will be part of the upcoming Eclipse 2024-03 (release date 2024-03-13). Integration builds with this fix are already available.
from buildship.
Related Issues (20)
- Launch Group that runs gradle task with the post launch action set to wait for termination waits infinitely
- Update site pages incorrect in the user documentation HOT 4
- deadlock during startup HOT 8
- Use preferences to decide if tabs or spaces are used in build script editor
- [Mac] After update on Eclipse version 09.2023 Splash Screen upside down HOT 2
- Kotlin Language server does not work on Windows
- The 3.1.8 release does not exist but a new release is needed for SimRel HOT 1
- Please ship org.gradle.toolingapi source jar in p2 repo
- An internal error occurred during: "Install semantic highlighting". HOT 1
- Problems building java17 projects with Buildship 3.1.8 and Eclipse 202312 HOT 5
- Importing java-library builds via "Projects from Folder or Archive" does not work correctly
- Marker Property value is too long
- Gradle tasks fail to load upon Eclipse start, manual refresh works as expected HOT 2
- 'files' dependencies should be added to the module path when applicable
- Improve Eclipse refresh time
- Finish button grayed out when importing a Gradle Project using Java 1.8,0_401
- Caused by: BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 66 HOT 4
- Importing https://github.com/open-telemetry/opentelemetry-java doesn't create Eclipse projects
- Setup a chatroom in chat.eclipse.org for the community HOT 1
- The "Refresh Gradle Project" command does not reload .settings/org.eclipse.jdt.apt.core.prefs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buildship.