Class LicenseNameUrlOverrides

java.lang.Object
org.codehaus.mojo.license.download.LicenseNameUrlOverrides

public class LicenseNameUrlOverrides extends Object
Applies license-name-based URL overrides. When a license name matches one of the configured license name patterns, the URL from the matching override is used instead of the URL originally declared in the dependency's POM. This is useful for redirecting downloads to an internal mirror or for providing a canonical plain-text URL for well-known licenses that are otherwise only available as HTML pages.

The overrides are applied in the order they are configured; the first matching override wins.

  • Field Details

    • EMPTY

      public static final LicenseNameUrlOverrides EMPTY
      An instance with an empty override list, used as a null-safe default.
  • Constructor Details

  • Method Details

    • findMatch

      public LicenseNameUrlOverride findMatch(String licenseName)
      Finds the first LicenseNameUrlOverride matching the given licenseName.
      Parameters:
      licenseName - the license name as declared in the dependency's POM; may be null or blank
      Returns:
      the matching override, or null if no match or if licenseName is null or blank
    • overrideIfNecessary

      public String overrideIfNecessary(String licenseName, String currentUrl)
      If licenseName matches one of the configured name patterns, returns the URL configured for that override; otherwise returns currentUrl unchanged (which may be null or blank). Applied overrides are logged at INFO level.
      Parameters:
      licenseName - the license name as declared in the dependency's POM; may be null or blank
      currentUrl - the URL currently associated with the license; may be null or blank
      Returns:
      the override URL when the name matches, or currentUrl when there is no match
    • overrideIfNecessary

      public String overrideIfNecessary(String licenseName, String currentUrl, boolean logOverride)
      If licenseName matches one of the configured name patterns, returns the URL configured for that override; otherwise returns currentUrl unchanged (which may be null or blank).
      Parameters:
      licenseName - the license name as declared in the dependency's POM; may be null or blank
      currentUrl - the URL currently associated with the license; may be null or blank
      logOverride - whether to log the applied override at INFO level
      Returns:
      the override URL when the name matches, or currentUrl when there is no match