This plugin automatically creates .gitignore files in new projects to ensure that generated build artifacts are not committed to version control.
How It Works
When a new project is created, the Git plugin will:
- Create a
.gitignorefile in the project root that excludes common build directories - Create
.gitignorefiles in source directories to preserve empty directory structure in Git
Default Ignore Patterns
The plugin automatically creates entries to ignore the following directories (though actual names can be customized via project properties):
generated/- Directory for generated build artifacts (default: fromDEFAULT_PROP_TARGET_DIR, usually “generated”)bin/- Compiled binary output (default: fromDEFAULT_PROP_BIN_DIR, usually “bin”)bin_test/- Compiled test output (default: fromDEFAULT_PROP_TESTBIN_DIR, usually “bin_test”)
These patterns prevent accidental commits of compiled code and generated resources.
Preserving Empty Directories
The plugin also creates minimal .gitignore files in source directories (as returned by the project’s source path and test source configuration). These empty .gitignore files ensure that Git preserves the directory structure even if the directories are initially empty, which is important for bnd project initialization.
Customization
You can customize the directory names that should be ignored by modifying the project properties:
DEFAULT_PROP_TARGET_DIR- Directory for generated artifactsDEFAULT_PROP_BIN_DIR- Directory for compiled outputDEFAULT_PROP_TESTBIN_DIR- Directory for compiled test output
These properties are defined in aQute.bnd.osgi.Constants.
Usage in build.bnd
The Git plugin is typically enabled automatically in bnd workspaces. If you need to explicitly enable it, add the following to your cnf/build.bnd:
-plugin.Git: \
aQute.bnd.plugin.git.GitPlugin
When you create a new project in the workspace, the plugin will automatically generate appropriate .gitignore files.
Generated .gitignore
The plugin generates a root .gitignore in the project with entries similar to:
/generated/
/bin/
/bin_test/
And also creates empty .gitignore files in source directories to preserve the directory structure in Git. This ensures that:
- Build artifacts are never committed
- Empty source directories are preserved in the repository
- New developers have a clean workspace ready for builds
TODO Needs review - AI Generated content