Skip to content

source location not available in extensions when running through the Gradle task while it is available in IntelliJ plugin execution #752

@Vampire

Description

@Vampire

I'm not sure whether this is an asciidotor-gradle-plugin issue or something deeper, so sorry if this is the wrong repo.

If I add
executionMode = org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask.IN_PROCESS
to
https://github.com/spockframework/spock/blob/master/build.gradle#L346
and
set a breakpoint at https://github.com/spockframework/spock/blob/8a6a43dacf91e782cda3df30edc3e8b783a8ca9f/build-logic/asciidoc-extensions/src/main/java/org/spockframework/plugins/asciidoctor/IncludedSourceLinker.java#L591
and then execute gradlew asciidoctor --rerun through the debugger.

Then the debugger properly breaks at the breakpoint.
But if I then evaluate block.getSourceLocation() it returns null.

But if I change the

log(new LogRecord(WARN, "listing with only inline code found; " +
  "if this is not source from a file, consider using a literal block instead; " +
  "first line: " + lines.get(0)));

to

log(new LogRecord(WARN, block.getSourceLocation(), "listing with only inline code found; " +
  "if this is not source from a file, consider using a literal block instead; " +
  "location: " + block.getSourceLocation()));

then do gradlew :build-logic:asciidoc-extensions:installAsciidocExtension
and open the docs/interaction_based_testing.adoc in IntelliJ with the extensions enabled,
the correct line is highlighted in the IDE while with the previous code all warnings are shown on the first line in the file.

So it seems that when IntelliJ executes that extension, the source location is populated,
while when running through the Gradle task, the source location is not set.

It would be nice if the source location would also be available when running through the Gradle task.

Metadata

Metadata

Assignees

Labels

5.xIssues related to 5.x series

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions