buildship icon indicating copy to clipboard operation
buildship copied to clipboard

Problem with Gradle-Build, if testImplementation testFixtures and implementation is used

Open cherni78 opened this issue 3 years ago • 12 comments
trafficstars

Expected Behavior

Eclipse compiles if I use testImplementation testFixtures and implementation of the same project as it does with Gradle 7.4.2!

Current Behavior

As soon as I need the above listed configurations, Eclipse doesn't compile successful.

Context

A minimal setup to reproduce is present here: https://github.com/BisonSchweizAG/gradleproblem/tree/main

Steps to Reproduce

Clone above project, import into Eclipse --> will not compile! Build on command line will work. Remove needed line testImplementation testFixtures(project(':projectA')) from build.gradle --> Eclipse compiles, command line build won't!

Your Environment

Eclipse:
Version: 2022-06 (4.24.0)
Build id: 20220609-1112

Gradle: 7.5.1

Buildship: 3.1.6.v20220511-1359

cherni78 avatar Sep 20 '22 08:09 cherni78

Reproduced here. We've been hit very hard by this issue; when refreshing gradle in eclipse everything's broken.

flozano avatar Oct 13 '22 08:10 flozano

BTW: it still happens with SNAPSHOT version of buildship:

Eclipse Buildship	Buildship, Eclipse Plug-ins for Gradle	3.1.7.v20220902-0443-s	org.eclipse.buildship
Eclipse Buildship	Buildship, Eclipse Plug-ins for Gradle	3.1.7.v20220902-0443-s	org.eclipse.buildship.oomph

and gradle 7.5.1.

I just confirmed that downgrading to gradle 7.4.2 fixes the issue and that 7.5 reproduces the issue also.

flozano avatar Oct 13 '22 08:10 flozano

Still the same problem with the actual version 7.6.

cherni78 avatar Dec 01 '22 12:12 cherni78

still happens in eclipse 2022-12 with gradle 7.6...

flozano avatar Dec 15 '22 11:12 flozano

Still happens with latest snapshot of buildship (3.1.7.v20221111-0445-s)

flozano avatar Dec 15 '22 14:12 flozano

is there any workaround other than downgrading gradle?

flozano avatar Dec 15 '22 14:12 flozano

Unfortunately, no! Respectively no one that I would know.

cherni78 avatar Dec 20 '22 06:12 cherni78

seems related to https://github.com/gradle/gradle/issues/21853

stefanrybacki avatar Dec 29 '22 16:12 stefanrybacki

Yes, it is related! The workaround mentioned there works for me too.

eclipse.classpath {
    file.whenMerged { classpath ->
        classpath.entries.findAll { entry -> entry instanceof org.gradle.plugins.ide.eclipse.model.ProjectDependency && entry.entryAttributes.test }
        	.each { it.entryAttributes['test'] = 'false' }
	}
}

cherni78 avatar Dec 30 '22 06:12 cherni78

This is happening to me to. Gradle 8.1, Eclipse JDTLS 1.23.

The workaround above works. Here it is in Kotlin.

import org.gradle.plugins.ide.eclipse.model.ProjectDependency
import org.gradle.plugins.ide.eclipse.model.Classpath

eclipse.classpath.file {
    whenMerged(Action<Classpath> { ->
        entries.filter { entry -> entry is ProjectDependency && entry.entryAttributes.containsKey("test") }
            .forEach { (it as ProjectDependency).entryAttributes["test"] = "false" }
    })
}

filipe-amberflo-io avatar Jun 16 '23 19:06 filipe-amberflo-io

When generating the eclipse project files with the eclipse plugin, aka ./gradlew eclipse the files get generated just fine. So afaict this is more of a buildship issue, even if it just uses gradle classes.

But for me, this is just the next link in a long chain of issues with the gradle <-> eclipse connection. I'm tired. If you let this issue lying around, it'll solve itself because no one is using eclipse or gradle anymore.

E.g.: you can only do this workaround if you do it after the java plugin gets applied, because existing configs get mercilessly overwritten (https://github.com/gradle/gradle/blob/master/subprojects/ide/src/main/java/org/gradle/plugins/ide/eclipse/EclipsePlugin.java#L240) and while not recommended, you can do apply plugin: 'eclipse', then do your config, and then apply the java plugin (maybe because you do blanket-configs for all modules).

mr1chter avatar Jun 21 '23 15:06 mr1chter

Fixed in https://github.com/gradle/gradle/pull/28556

donat avatar Apr 19 '24 11:04 donat