eclipse / buildship

The Eclipse Plug-ins for Gradle project.
528 stars 167 forks source link

The "Refresh Gradle Project" command does not reload .settings/org.eclipse.jdt.apt.core.prefs #1305

Open nakamura-to opened 2 months ago

nakamura-to commented 2 months ago

Expected Behavior

When the "Refresh Gradle Project" command is executed, the Processor options specified in build.gradle are displayed on the Annotation Processing screen.

Current Behavior

When the "Refresh Gradle Project" command is executed, the Processor options specified in build.gradle are reflected in the .settings/org.eclipse.jdt.apt.core.prefs file, but they are not reflected on the Annotation Processing screen.

Context

I want to use synchronizationTasks to ensure that all settings related to annotation processing are reflected from Gradle to Eclipse.

Steps to Reproduce

plugins {
    id 'java-library'
    id 'com.diffplug.eclipse.apt' version '3.44.0'
}

compileJava {
    aptOptions {
        processorArgs = ['myOption' : 'hello']
    }
}

eclipse {
    synchronizationTasks 'cleanEclipse', 'eclipse'
}
#
#Mon May 20 21:44:34 JST 2024
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genTestSrcDir=.apt_generated_tests
org.eclipse.jdt.apt.reconcileEnabled=true
org.eclipse.jdt.apt.genSrcDir=.apt_generated
eclipse.preferences.version=1
org.eclipse.jdt.apt.processorOptions/myOption=hello

You will notice that the processorOptions remain empty in the Annotation Processing screen.

Your Environment

oleosterhagen commented 1 month ago

In your Gradle script the configuration of the JDT Annotation Processing (APT) is done by the Gradle plugin com.diffplug.eclipse.apt and not Eclipse Buildship. Any problems with this plugin should be reported here: https://github.com/diffplug/goomph/issues

The problem seems to be an unsupported combination of using Buildship (e.g. Refresh Gradle Project) and standalone project generation (cleanEclipse, eclipse).

Using the standalone project generator you could try these steps:

  1. Remove the block eclipse (with synchronizationTasks) from your build.gradle.
  2. Run ./gradlew eclipse
  3. Import the project into Eclipse: File > Import... > General > Existing Projects into Workspace (not Existing Gradle Project)

Now the configured processor option should be shown in the Annotation Processing dialog.