• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • Introduction
      • How to install bnd
      • Guided Tour Workspace & Projects
      • bnd / bndlib Features and JAR Wrapping Techniques
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Concepts
      • Background
      • Best practices
    • Build and Development
      • Build
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • bnd CLI Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • basedir

    Prev Next
    Processor
    Get the base directory of the current processor context

    Summary

    The basedir macro returns the absolute path to the base directory of the current processor (project, workspace, or build context). This is the root directory from which relative paths are resolved.

    Syntax

    ${basedir}
    

    Parameters

    None - this macro takes no parameters.

    Behavior

    • Returns the absolute path to the base directory
    • The base directory is the root context for resolving relative file paths
    • Throws an exception if no base directory has been set (rare edge case)

    Examples

    Get the current project’s base directory:

    project.root=${basedir}
    

    Build a path relative to the base directory:

    resources.dir=${basedir}/src/main/resources
    

    Reference files using the base directory:

    Bundle-Icon: ${basedir}/icon.png
    

    Use Cases

    • Building absolute paths to project resources
    • Referencing files in build configurations
    • Creating platform-independent path references
    • Debugging path resolution issues
    • Documentation and logging of project locations

    Notes

    • The base directory is typically the project directory for bnd projects
    • In workspace contexts, it may be the workspace root
    • The path separator used in the returned path is platform-specific

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home