Class AlignOptions

java.lang.Object
eu.maveniverse.domtrip.maven.AlignOptions

public final class AlignOptions extends Object
Options for controlling how dependencies are aligned with project conventions.

When adding or aligning dependencies, these options specify the version management style, version source, and property naming convention. Null values indicate auto-detection from existing POM conventions.

Usage Examples:

// Auto-detect all conventions
AlignOptions options = AlignOptions.defaults();

// Force managed + property style
AlignOptions options = AlignOptions.builder()
    .versionStyle(AlignOptions.VersionStyle.MANAGED)
    .versionSource(AlignOptions.VersionSource.PROPERTY)
    .build();

// Force specific property name
AlignOptions options = AlignOptions.builder()
    .versionSource(AlignOptions.VersionSource.PROPERTY)
    .propertyName("junit.version")
    .build();

// Custom property naming pattern
AlignOptions options = AlignOptions.builder()
    .versionSource(AlignOptions.VersionSource.PROPERTY)
    .propertyNameGenerator(coords -> coords.groupId() + "." + coords.artifactId() + ".version")
    .build();

// Add with scope
AlignOptions options = AlignOptions.builder()
    .scope("test")
    .build();
Since:
1.1.0
  • Method Details

    • defaults

      public static AlignOptions defaults()
      Create an AlignOptions instance with all conventions set to auto-detect.
      Returns:
      an AlignOptions whose fields are all null, indicating auto-detection of conventions
      Since:
      1.1.0
    • builder

      public static AlignOptions.Builder builder()
      Create a new Builder for constructing AlignOptions.
      Returns:
      a new Builder instance for configuring and building an AlignOptions object
      Since:
      1.1.0
    • versionStyle

      public AlignOptions.VersionStyle versionStyle()
      Gets the configured version placement style or defers to auto-detection when unspecified.
      Returns:
      the configured version style, or null to indicate auto-detection
      Since:
      1.1.0
    • versionSource

      public AlignOptions.VersionSource versionSource()
      The configured version source, or null to indicate auto-detection.
      Returns:
      the version source override, or null if auto-detection is used
      Since:
      1.1.0
    • namingConvention

      public AlignOptions.PropertyNamingConvention namingConvention()
      The property naming convention to use, or null to indicate auto-detection.
      Returns:
      the naming convention override, or null if it should be auto-detected
      Since:
      1.1.0
    • propertyNameGenerator

      public Function<Coordinates, String> propertyNameGenerator()
      Custom function that generates property names from dependency coordinates, or null to use convention-based generation.

      When provided, this function is used to derive property names allowing arbitrary naming patterns beyond the built-in AlignOptions.PropertyNamingConvention options.

      Precedence: an explicit property name overrides this generator, which overrides an explicit naming convention, which in turn falls back to auto-detection.

      Returns:
      the property name generator, or null
      Since:
      1.1.0
    • propertyName

      public String propertyName()
      Provides the explicit property name override.
      Returns:
      the explicit property name override, or null to indicate auto-generation
      Since:
      1.1.0
    • scope

      public String scope()
      Get the Maven dependency scope configured for this instance.

      May be null to indicate the default scope.

      Returns:
      the dependency scope (e.g., "test", "provided"), or null to use the default
      Since:
      1.1.0
    • generatePropertyName

      public static String generatePropertyName(Coordinates coords, AlignOptions.PropertyNamingConvention convention)
      Generates a version property name for the given coordinates and naming convention.

      Examples:

      • DOT_SUFFIX: junit-jupiter.version
      • DASH_SUFFIX: junit-jupiter-version
      • CAMEL_CASE: junitJupiterVersion
      • DOT_PREFIX: version.junit-jupiter
      Parameters:
      coords - the dependency coordinates (artifactId is used as the base name)
      convention - the naming convention to apply
      Returns:
      the generated property name
      Since:
      1.1.0