gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
16.77k stars 4.69k forks source link

Eclipse plugin generates faulty .project/.classpath files for a project with fileSets that reference outside source folders #30818

Open nyholku opened 1 week ago

nyholku commented 1 week ago

Current Behavior

I try to import a simple springboot helloworld project into Eclipse. The project will have a large number dependencies to other projects, local jars and web repos, so I have added a sourceSets definition to build.gradle to be able to debug and modify code where ever I need.

In Eclipse When I do "Import... / Gradle / Existing Gradle project" the resulting Eclipse package view is missing the 'src/main/java'.

It looks like anything that references a sub directory of where the gradle.build is is ignored by Eclipse.

Eclipse picks the first sourceSets reference that is not a sub directory, turns that into a 'src' folder and all the rest references in the sourceSets into source folders with the reference name with -src appended.

Expected Behavior

I would expect all source folders to appear either under src or in their own folders in eclipse.

Context (optional)

No response

Self-contained Reproducer Project

This an obfuscated version on my gradle.build

plugins {
    id 'org.springframework.boot' version '3.3.0'
    id 'java'
    id 'eclipse'
}

apply plugin: 'io.spring.dependency-management'

group = 'com.myproject'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

compileJava.options.encoding = "ISO-8859-1"
compileJava.options.warnings = false

repositories {
    mavenCentral()
}  

sourceSets {
    main {
        java{
            srcDirs = [
            src/main/java',
            '../FooProjectA/src',
            '../FooProjectB/src', 
            '../FooProjectC/src', 
[SNIP more of the same]
            ]
        }
    }
}

Gradle version

Gradle 8.10.2

Build scan URL (optional)

No response

Your Environment (optional)

No response

ov7a commented 6 days ago

This issue needs a decision from the team responsible for that area. They have been informed. Response time may vary.


@gradle/bt-ide-experience Please clarify if that is the expected behavior or not.

@nyholku Can you clarify why do you rely on sourceSets instead of, e.g. Composite Builds?

Emerson10110 commented 1 day ago

O formato do seu sourceSets pode não ser reconhecido adequadamente pelo Eclipse. O Eclipse pode não estar lidando bem com os diretórios que estão fora do diretório do projeto principal, resultando na falta de pastas como src/main/java.