Skip to content

fix(delombok): add sourcepath when module-info.java is present - #1754

Merged
larsgrefer merged 1 commit into
freefair:mainfrom
dtrunk90:fix/delombok-sourcepath-for-modules
Apr 28, 2026
Merged

larsgrefer merged 1 commit into
freefair:mainfrom
dtrunk90:fix/delombok-sourcepath-for-modules

Conversation

@dtrunk90

Copy link
Copy Markdown
Contributor

Problem

When a source set contains module-info.java, the delombok task already sets
modulePath from the compile classpath (added in the hasModuleInfo branch).
However, the source directories are not added to sourcepath in that case.

This causes javac (invoked internally by Lombok's delombok) to emit errors for
every source file in the compilation unit:

error: file should be on source path, or on patch path for module

These errors are non-fatal — delombok still produces correct output — but they
are noisy and misleading.

Root cause

When javac processes module-info.java in module mode, it requires the module's
source root to be declared via --source-path so it can correctly associate
source files with the named module. Without it, javac cannot determine which
module the input files belong to.

The plugin already adds the annotation processor output directory to sourcepath
(line 117), but omits the actual source directories when module-info.java is
present.

Fix

Add sourceSet.getJava().getSourceDirectories() to the sourcepath in the same
hasModuleInfo branch that already configures the module path:

if (hasModuleInfo) {
    delombok.getModulePath().from(sourceSet.getCompileClasspath());
    delombok.getSourcepath().from(sourceSet.getJava().getSourceDirectories());
}

When a source set contains module-info.java, delombok already puts the
compile classpath on the module path. However, without the source
directories on the sourcepath, javac emits errors:

  error: file should be on source path, or on patch path for module

This adds the source directories to the sourcepath in the same
hasModuleInfo branch, consistent with the existing modulePath setup.
@larsgrefer
larsgrefer merged commit a1cf246 into freefair:main Apr 28, 2026
6 checks passed
dtrunk90 added a commit to slugify/slugify that referenced this pull request Apr 29, 2026
dtrunk90 added a commit to slugify/slugify that referenced this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants