Skip to content

Refactor Project Build Tools to Use NetBeans Toolkit APIs#335

Merged
stefanofornari merged 6 commits into
jeddict:mainfrom
stefanofornari:ste/ref/project_build_tools
Jul 3, 2026
Merged

Refactor Project Build Tools to Use NetBeans Toolkit APIs#335
stefanofornari merged 6 commits into
jeddict:mainfrom
stefanofornari:ste/ref/project_build_tools

Conversation

@stefanofornari

@stefanofornari stefanofornari commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR refactors the Maven and Gradle project build tools to use the NetBeans platform's native APIs (org.netbeans.modules.maven.api.execute and org.netbeans.modules.gradle.api.execute) instead of invoking external commands directly. This provides better integration, improved security, and removes the need for manual command-line configuration.

Branch: ste/ref/project_build_tools
Base Branch: main
Total Changes: 52 files changed, 1,878 insertions(+), 1,210 deletions(-)


Key Changes

1. Build System Integration (Commits: f624561, 55f7037, cdc3efa, 79b9211)

Maven Tools:

  • Replaced direct mvn command execution with MavenCommandLineExecutor from NetBeans Maven API
  • Added runMavenGoals() tool that accepts goals, profiles, and properties as parameters
  • Uses RunUtils.createRunConfig() to create proper Maven execution configurations
  • Captures output using new CaptureOutputInputOutput utility
  • Implements 15-minute timeout for build operations

Gradle Tools:

  • Replaced direct gradle command execution with RunUtils.executeGradle() from NetBeans Gradle API
  • Added runGradleTasks() tool for executing Gradle tasks
  • Integrates with NetBeans Gradle plugin infrastructure
  • Proper project context handling

New Infrastructure:

  • CaptureOutputInputOutput - Utility class that wraps InputOutput to capture stdout/stderr for build output
  • Removed ExecutionTools.java - No longer needed as build execution is now handled by project-specific tools
  • Added AbstractBuildTool - Base class for build tools with common functionality

2. Tool Renaming for Clarity

All project-specific tools have been prefixed to avoid naming conflicts:

  • projectInfo -> mavenProjectInfo / gradleProjectInfo
  • jdkVersion -> mavenJdkVersion / gradleJdkVersion
  • projectDependencies -> mavenProjectDependencies / gradleProjectDependencies
  • runJavaClass -> runMavenGoals / runGradleTasks
  • Removed: buildProject, testProject (replaced by more flexible runMavenGoals/runGradleTasks)

3. UI Cleanup (Commit: da9084a)

Removed Project Configuration Fields:

  • Removed build command and test command fields from JeddictAIPropertiesPanel
  • Since command lines are no longer needed (they're grabbed from the underlying build system), these configuration options are obsolete
  • Simplified the properties panel to focus on project rules only
  • Updated Bundle.properties to remove unused localization keys

4. Dependency Updates

Added new dependencies in pom.xml:

  • org.netbeans.modules.gradle and org.netbeans.modules.gradle-java APIs
  • mockito-junit-jupiter for testing

5. Testing Infrastructure

Enhanced test coverage with:

  • New test utilities: DummyGradleConfigurationProvider, DummyProjectManager, DummyProjectSources
  • Updated existing tests to work with new APIs
  • New test classes: MavenToolsTest, BuildToolsTest, HackerTest, CaptureOutputInputOutputTest, etc.

Technical Benefits

  1. Security: No longer executes blind external commands; uses NetBeans' controlled execution environment
  2. Configuration: No need to configure build/test commands manually; uses project metadata from NetBeans
  3. Extensibility: Pattern can be extended to other build systems (e.g., Ant)
  4. Better Integration: Leverages NetBeans' project system APIs for proper context handling
  5. Output Capture: Proper capture of stdout/stderr for AI consumption

Testing Notes

  • Existing tests have been updated to work with the new implementation
  • New tests added for the refactored build tools
  • The xvfb-run setup for CI/CD is preserved from main branch

…sses

to run maven so that there is no need to specify executables or build
the command line.
Similarly, it replaces direct XML manipulatioin for pom.xml in dealing 
with dependencies.
…sses

to run maven so that there is no need to specify executables or build
the command line.
Similarly, it replaces direct XML manipulatioin for pom.xml in dealing 
with dependencies.
instead of running maven as an external command. This has several benefits:
- no configuration
- more secure because it does not execute blindly an external command
- potentially extensible (or at least pattern) for any build system
- no need to deal directly with command arguments
- fewer tools, but not restricted to a few goals (do more with less)
no need any more to provide it as project option.
@stefanofornari stefanofornari changed the title Build commands from the NB maven/gradle modules Refactor Project Build Tools to Use NetBeans Toolkit APIs Jun 27, 2026
@stefanofornari stefanofornari merged commit b5772b4 into jeddict:main Jul 3, 2026
3 checks passed
@stefanofornari stefanofornari deleted the ste/ref/project_build_tools branch July 3, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants