Skip to content

Compile hook scripts to maven.compiler.release, not the running JDK - #760

Draft
slachiewicz wants to merge 2 commits into
masterfrom
agent/script-target-bytecode
Draft

slachiewicz wants to merge 2 commits into
masterfrom
agent/script-target-bytecode

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

The library side landed in maven-script-interpreter 1.8 (ScriptRunner.setTargetBytecode); this wires it into the plugin. Hook scripts are compiled to the first of scriptTargetBytecode, maven.compiler.release, maven.compiler.target that is set (each looked up in -D properties, then the project), and to the running JDK's level when none is, so verify.groovy no longer fails when a project targets an older bytecode level than the JDK running Maven.

Fixes #742

@slachiewicz slachiewicz added the bug Something isn't working label Sep 15, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review September 15, 2026 23:38
Comment thread src/site/markdown/examples/pre-post-build-script.md.vm Outdated
@slachiewicz
slachiewicz marked this pull request as draft September 17, 2026 19:26
verify.groovy and other pre-/post-build scripts were always compiled to
the bytecode level of the JDK running Maven, so a project pinned to an
older release could fail with an unrecognized bytecode version. Wire
the new ScriptRunner.setTargetBytecode (maven-script-interpreter 1.8)
to a scriptTargetBytecode parameter that defaults to
maven.compiler.release and falls back to maven.compiler.target.

Fixes #742
A defaultValue of ${maven.compiler.release} hid half of the fallback
chain (maven.compiler.target) in code and made the site text describe
the wrong default. Resolving parameter, release and target in one
method keeps the -D-then-project lookup the expression evaluator gave
the default, and lets the docs state the order and the opt-out.
@slachiewicz
slachiewicz force-pushed the agent/script-target-bytecode branch from e07fdad to 45b92eb Compare September 19, 2026 23:01
@slachiewicz
slachiewicz marked this pull request as ready for review September 19, 2026 23:03
@slachiewicz
slachiewicz marked this pull request as draft September 19, 2026 23:05
}

private static MavenSession newSession(MavenExecutionRequest request) {
return new MavenSession(null, (RepositorySystemSession) null, request, null);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as constructors in MavenSession are deprecated we can try to use a mockito to moc a session or add suppression for deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ScriptRunner compiles verify.groovy to JDK version, not maven.compiler.release version, then fails evaluation

2 participants