• 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
  • fmodified ( ';' RESOURCE )+

    Prev Next
    Macro
    Get the latest modification timestamp from a list of files

    Summary

    The fmodified macro finds the most recent modification time among a list of files and returns it as a long integer (milliseconds since epoch). This is useful for detecting when files have changed.

    Syntax

    ${fmodified;<file>[;<file>...]}
    

    Parameters

    • file - One or more file paths (can be comma or semicolon-separated lists)

    Behavior

    • Checks the last modified timestamp of each specified file
    • Returns the latest (most recent) modification time found
    • Returns the time in milliseconds since Unix epoch (January 1, 1970)
    • Non-existent files are ignored
    • Returns 0 if no files exist

    Examples

    Get modification time of a single file:

    ${fmodified;build.gradle}
    # Returns: 1700000000000 (example timestamp)
    

    Find latest modification among multiple files:

    ${fmodified;src/Main.java;src/Util.java;src/Config.java}
    # Returns timestamp of most recently modified file
    

    Check if source files changed:

    source.modified=${fmodified;${lsr;src;*.java}}
    

    Compare modification times:

    ${if;${vcompare;${fmodified;input.txt};${fmodified;output.txt}};input-newer;output-newer}
    

    Track build inputs:

    Build-Input-Modified: ${fmodified;${buildpath}}
    

    Use Cases

    • Detecting when source files have changed
    • Implementing incremental build logic
    • Tracking file dependencies
    • Determining if regeneration is needed
    • Caching and cache invalidation
    • Build timestamp tracking

    Notes

    • Returns milliseconds since epoch (not seconds)
    • Non-existent files are silently ignored
    • To convert to readable format, use ${long2date} macro
    • Returns 0 if all files are missing
    • The timestamp represents the OS file system’s last modified time
    • Useful with ${if} or ${vcompare} for conditional logic

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home