-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for a process API #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Maven Mojos (and maybe components) can create / fork processes, common examples would include: - ant-run plugin - maven-exec-plugin - maven-surefire currently the IDE has no effective way to know about forked processes, so there is no way to visualize them (e.g. in a process manager) nor to take special actions on them (e.g. automatically request to open a debug port). For executions of tests, the IDE even may want to be notified about individual test runs while the process is running. This now adds a new build-process API that mitigates the problem by allowing a mojo or component to make the IDE aware of subprocesses but is completely disabled if running outside an IDE. An integration can range from very basic, that is only notify that a process is running over to specialized callbacks that allows the IDE to intercept process creation in a generic way. An example implementation is provided for either resuse, extension or own implementation of such callbacks. To reflect this new opportunity, the minor version is increase to 1.3 even though neither consumers nor providers of the API need to take immediate actions here.
a8dbb28
to
93f6a58
Compare
Sounds ver helpfull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a comprehensive process API to the plexus build API, enabling IDEs to interact with and monitor processes spawned by Maven mojos (like ant-run, maven-exec, and maven-surefire plugins). The API provides visualization capabilities, optional termination control, and specialized callbacks for different process types.
- Introduces a new process management API with interfaces for BuildProcess, ProcessManager, and various callback types
- Provides default implementations including a no-op ProcessManager and a ProcessBuilder-based context
- Updates version from 1.2.1-SNAPSHOT to 1.3.0-SNAPSHOT to reflect the new API addition
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
ProcessBuilderContext.java | Implementation using ProcessBuilder to manage child processes with BuildProcess notification |
DefaultProcessManager.java | No-op default implementation that always returns null for new processes |
ProcessManager.java | Core interface for creating BuildProcess instances from contexts |
ProcessCallback.java | Interface for setting environment variables on processes |
JavaCallback.java | Specialized callback interface for Java VM processes |
JUnitCallback.java | Specialized callback interface for JUnit test executions |
BuildProcessContext.java | Context interface providing process name and termination capability |
BuildProcess.java | Interface representing a managed build process with lifecycle notifications |
pom.xml | Version bump to 1.3.0-SNAPSHOT |
README.md | Documentation updates explaining the new process API |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
if (allowTermination) { | ||
do { | ||
if (buildProcess.isTerminated()) { | ||
// request termination | ||
process.destroy(); | ||
break; | ||
} | ||
} while (!process.waitFor(200, TimeUnit.MILLISECONDS)); | ||
} | ||
buildProcess.notifyFinished(process.waitFor()); |
Copilot
AI
Oct 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential race condition: process.waitFor()
is called twice - once in the while loop condition (line 83) and again here. The second call may return immediately with a cached result, but this creates unnecessary complexity and potential timing issues. Store the exit code from the first waitFor()
call instead.
if (allowTermination) { | |
do { | |
if (buildProcess.isTerminated()) { | |
// request termination | |
process.destroy(); | |
break; | |
} | |
} while (!process.waitFor(200, TimeUnit.MILLISECONDS)); | |
} | |
buildProcess.notifyFinished(process.waitFor()); | |
int exitCode; | |
if (allowTermination) { | |
while (true) { | |
if (buildProcess.isTerminated()) { | |
// request termination | |
process.destroy(); | |
// Wait for process to actually terminate and get exit code | |
exitCode = process.waitFor(); | |
break; | |
} | |
if (process.waitFor(200, TimeUnit.MILLISECONDS)) { | |
exitCode = process.exitValue(); | |
break; | |
} | |
} | |
} else { | |
exitCode = process.waitFor(); | |
} | |
buildProcess.notifyFinished(exitCode); |
Copilot uses AI. Check for mistakes.
Maven Mojos (and maybe components) can create / fork processes, common examples would include:
currently the IDE has no effective way to know about forked processes, so there is no way to visualize them (e.g. in a process manager) nor to take special actions on them (e.g. automatically request to open a debug port). For executions of tests, the IDE even may want to be notified about individual test runs while the process is running.
This now adds a new build-process API that mitigates the problem by allowing a mojo or component to make the IDE aware of subprocesses but is completely disabled if running outside an IDE. An integration can range from very basic, that is only notify that a process is running over to specialized callbacks that allows the IDE to intercept process creation in a generic way. An example implementation is provided for either resuse, extension or own implementation of such callbacks.
To reflect this new opportunity, the minor version is increase to 1.3 even though neither consumers nor providers of the API need to take immediate actions here.