Skip to content

Extract output dir preparation to separate goal - #20

Merged
runeflobakk merged 3 commits into
mainfrom
better-eclipse-integration
Mar 4, 2026
Merged

runeflobakk merged 3 commits into
mainfrom
better-eclipse-integration

Conversation

@runeflobakk

@runeflobakk runeflobakk commented Mar 1, 2026 •

Copy link
Copy Markdown
Owner

The intention is to enable a more streamlined integration with IDEs which support incorporating Maven plugin goals as an integral part of the IDE's internal project building process (e.g. Eclipse).

The prepare-output-directory goal will create (if necessary) the output directory for the generated matchers, as well as add this directory to the project's test sources, which will include them in the regular test compilation. This goal is also automatically run within IDEs which support lifecycle-mapping-metadata.xml. The generate goal is now excluded in this file.

To properly configure the plugin in your build, it is now required to specify both goals:

<execution>
    <goals>
        <goal>prepare-output-directory</goal> <!-- This is new -->
        <goal>generate</goal>
    </goals>
</execution>

It is still applicable to run only the generate in order to manually update the generated matchers to reflect your records. But running a full build will now require the prepare-output-directory goal to be configured to have this directory to be included as a test compilation source directory.

This fixes #18 by avoiding the matcher generation in IDE (Eclipse) altogether.

The reason being that the record analyzing for code generation is based
on reflection, i.e. actually loading the classes to figure out how to
generate corresponding Matchers, and for IDEs able to integrate plugin
executions as part of their integral build processes, will typically
execute within the runtime JVM of the IDE, which may be incompatible
(i.e. earlier version) than the compilation target of the records to
load.

But creating the output directory and adding it as a test source folder
is still desireable to happen within the build of the IDE, so doing this
as a separate goal makes the IDE "discover" the output directory
automatically.

The generate goal will inform about this change if the output directory
has not been created, and suggest adding the goal to the plugin
execution configuration.
Allows the use of the generate goal without requiring the
prepare-output-directory goal, but if the directory does not exist,
emits a warning about the dir will not be included as test sources.

This will allow to try the plugin with the single goal to generate
matchers and manually include the folder in your IDE, and when
configured properly in the POM with both goals, it will still be
applicable to only run the single generate goal to update the generated
matchers when needed.
@runeflobakk
runeflobakk merged commit d94c9dd into main Mar 4, 2026
2 checks passed
@runeflobakk
runeflobakk deleted the better-eclipse-integration branch March 4, 2026 23:21
@runeflobakk

Copy link
Copy Markdown
Owner Author

This closes #13

runeflobakk added a commit to runeflobakk/myconfig that referenced this pull request Mar 15, 2026
Not necessary anymore, handled by the plugin itself
runeflobakk/record-matcher#20
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.

Executing in IDE incremental builds (e.g. Eclipse) fails if JRE version is earlier than JDK used to compile

1 participant