Skip to content

Conversation

@iamvirul
Copy link

@iamvirul iamvirul commented Oct 3, 2025

Purpose

Currently, Ballerina tool packages that do not contain any .bal files fail bal build and bal test commands with the error "package is empty. Please add at least one .bal file." This occurs despite bal pack working as expected for such packages. This fix addresses this discrepancy, allowing tool packages without .bal files to be built and tested successfully.

Fixes #44292

Approach

The issue was identified in io.ballerina.cli.task.CompileTask.java and io.ballerina.cli.task.CreateDependencyGraphTask.java, where a check for an empty package (ProjectUtils.isProjectEmpty(project)) was being performed without considering if the package was a tool package (i.e., containing a BalTool.toml).

The approach taken is to modify the conditional check in both CompileTask.java and CreateDependencyGraphTask.java. The condition now explicitly checks if project.currentPackage().balToolToml().isEmpty() is true in addition to ProjectUtils.isProjectEmpty(project). This ensures that if a package is identified as a tool package (by the presence of BalTool.toml), it is not considered "empty" even if it lacks .bal source files, thus preventing the erroneous compilation and test failures.

Samples

This change primarily affects the build and test behavior of tool packages without .bal files. Existing test cases for tool packages should now pass, and new test cases specifically covering this scenario (a tool package with BalTool.toml but no .bal files) would further validate the fix.

Remarks

N/A

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support ([Bug]: The bal test command fails for tool packages without .bal files #44292)
  • Added necessary tests (The fix is implemented, and existing tests for tool packages should now pass. New unit tests specifically for this scenario would be beneficial.)
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples for this format

@iamvirul iamvirul requested a review from azinneera as a code owner October 3, 2025 06:14
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.

[Bug]: The bal test command fails for tool packages without .bal files

1 participant