Class JavaModuleDependenciesExtension

java.lang.Object
org.gradlex.javamodule.dependencies.JavaModuleDependenciesExtension

@NullMarked public abstract class JavaModuleDependenciesExtension extends Object
- Configure behavior of the 'java-module-dependencies' plugin - Add additional mappings using getModuleNameToGA() - Define dependencies and dependency constraints by Module Name using ga(String), gav(String, String) or gav(String)
  • Constructor Summary

    Constructors
    Constructor
    Description
    JavaModuleDependenciesExtension(@Nullable org.gradle.api.artifacts.VersionCatalogsExtension versionCatalogs, File rootDir)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addRequiresRuntimeSupport(org.gradle.api.tasks.SourceSet sourceSetForModuleInfo, org.gradle.api.tasks.SourceSet sourceSetForClasspath)
    Adds support for compiling module-info.java in the given source set with the given task, if 'requires runtime' dependencies are used.
     
    org.gradle.api.provider.Provider<org.gradle.api.artifacts.Dependency>
    create(String moduleName, org.gradle.api.tasks.SourceSet sourceSetWithModuleInfo)
     
    org.gradle.api.provider.Provider<String>
    ga(String moduleName)
    Converts 'Module Name' to GA coordinates that can be used in dependency declarations as String: "group:name"
    org.gradle.api.provider.Provider<String>
    ga(org.gradle.api.provider.Provider<String> moduleName)
    Converts 'Module Name' to GA coordinates that can be used in dependency declarations as String: "group:name"
    org.gradle.api.provider.Provider<org.gradle.api.artifacts.ExternalDependency>
    gav(String moduleName)
    If a Version Catalog is used: Converts 'Module Name' and the matching 'Version' from the Version Catalog to GAV coordinates that can be used in dependency Declarations as Map: [group: "...", name: "...", version: "..."]
    org.gradle.api.provider.Provider<String>
    gav(String moduleName, String version)
    Converts 'Module Name' and 'Version' to GAV coordinates that can be used in dependency declarations as String: "group:name:version"
    org.gradle.api.provider.Provider<org.gradle.api.artifacts.ExternalDependency>
    gav(org.gradle.api.provider.Provider<String> moduleName)
    If a Version Catalog is used: Converts 'Module Name' and the matching 'Version' from the Version Catalog to GAV coordinates that can be used in dependency Declarations as Map: [group: "...", name: "...", version: "..."]
    org.gradle.api.provider.Provider<String>
    gav(org.gradle.api.provider.Provider<String> moduleName, org.gradle.api.provider.Provider<String> version)
    Converts 'Module Name' and 'Version' to GAV coordinates that can be used in dependency declarations as String: "group:name:version"
    void
    If a module-info.java contains 'provides' directives, generate the corresponding META_INF/services entries for backward compatibility to load the module on the classpath.
    abstract org.gradle.api.provider.Property<Boolean>
    Set this to true to use the analytic help tasks (like :moduleDependencies) of the plugin without performing the actual dependency calculation.
    protected abstract org.gradle.api.artifacts.ConfigurationContainer
     
    protected abstract org.gradle.api.artifacts.dsl.DependencyHandler
     
    protected abstract org.gradle.api.file.ProjectLayout
     
    abstract org.gradle.api.provider.Property<ModuleInfoCache>
     
    abstract org.gradle.api.provider.Property<Boolean>
    Fail the build if a Module Name does not fit the corresponding project and source set names; defaults to 'true'.
    abstract org.gradle.api.provider.MapProperty<String,String>
    If your Module Names all start with a common prefix (e.g.
    abstract org.gradle.api.provider.MapProperty<String,String>
    Register mapping from Module Name to GA Coordinates (and optionally Capability Coordinates).
    abstract org.gradle.api.file.RegularFileProperty
    Custom mappings can be defined in a property files in your build.
    protected abstract org.gradle.api.model.ObjectFactory
     
    protected abstract org.gradle.api.Project
     
    protected abstract org.gradle.api.provider.ProviderFactory
     
    protected abstract org.gradle.api.tasks.TaskContainer
     
    abstract org.gradle.api.provider.Property<String>
     
    abstract org.gradle.api.provider.Property<Boolean>
    Deprecated.
    org.gradle.api.provider.Provider<String>
    Finds the Module Name for given coordinates
    org.gradle.api.provider.Provider<String>
    moduleName(org.gradle.api.provider.Provider<String> ga)
    Finds the Module Name for given coordinates
    org.gradle.api.artifacts.Configuration
    versionsFromConsistentResolution(String... versionsProvidingProjects)
    Deprecated.
    use the 'org.gradlex.jvm-dependency-conflict-resolution' plugin instead.
    org.gradle.api.artifacts.Configuration
    Deprecated.
    use the 'org.gradlex.jvm-dependency-conflict-resolution' plugin instead.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JavaModuleDependenciesExtension

      public JavaModuleDependenciesExtension(@Nullable org.gradle.api.artifacts.VersionCatalogsExtension versionCatalogs, File rootDir)
  • Method Details

    • getModuleInfoCache

      public abstract org.gradle.api.provider.Property<ModuleInfoCache> getModuleInfoCache()
    • getModulesProperties

      public abstract org.gradle.api.file.RegularFileProperty getModulesProperties()
      Custom mappings can be defined in a property files in your build. The default location for this file is 'gradle/modules.properties' (relative to root project). Here, the location of the file can be changed.
    • getModuleNameToGA

      public abstract org.gradle.api.provider.MapProperty<String,String> getModuleNameToGA()
      Register mapping from Module Name to GA Coordinates (and optionally Capability Coordinates). - moduleNameToGA.put("org.slf4j", "org.slf4j:slf4j-api") - moduleNameToGA.put("org.slf4j.test.fixtures", "org.slf4j:slf4j-api|org.slf4j:slf4j-api-test-fixtures")
      Returns:
      the mappings from Module Name to GA coordinates; can be modified
    • getModuleNamePrefixToGroup

      public abstract org.gradle.api.provider.MapProperty<String,String> getModuleNamePrefixToGroup()
      If your Module Names all start with a common prefix (e.g. 'com.example.product.module.') followed by a name that corresponds to the artifact name and all have the group (e.g. 'com.example.product'), you can register a mapping for all these Modules. and with that allow Gradle to map them correctly even if you publish some of your Modules or use included builds.

      moduleNamePrefixToGroup.put("com.example.product.module.", "com.example.product")

      Returns:
      the mappings from 'Module Name Prefix' to 'group'
    • getWarnForMissingVersions

      @Deprecated public abstract org.gradle.api.provider.Property<Boolean> getWarnForMissingVersions()
      Deprecated.
      Returns:
      no-op
    • getVersionCatalogName

      public abstract org.gradle.api.provider.Property<String> getVersionCatalogName()
      Returns:
      If a Version Catalog is used: which catalog? (default is 'libs')
    • getModuleNameCheck

      public abstract org.gradle.api.provider.Property<Boolean> getModuleNameCheck()
      Fail the build if a Module Name does not fit the corresponding project and source set names; defaults to 'true'.
    • getAnalyseOnly

      public abstract org.gradle.api.provider.Property<Boolean> getAnalyseOnly()
      Set this to true to use the analytic help tasks (like :moduleDependencies) of the plugin without performing the actual dependency calculation.
      Returns:
      true – for analyse-only mode
    • generateMetaInfServices

      public void generateMetaInfServices()
      If a module-info.java contains 'provides' directives, generate the corresponding META_INF/services entries for backward compatibility to load the module on the classpath.
    • ga

      public org.gradle.api.provider.Provider<String> ga(String moduleName)
      Converts 'Module Name' to GA coordinates that can be used in dependency declarations as String: "group:name"
      Parameters:
      moduleName - The Module Name
      Returns:
      Dependency notation
    • ga

      public org.gradle.api.provider.Provider<String> ga(org.gradle.api.provider.Provider<String> moduleName)
      Converts 'Module Name' to GA coordinates that can be used in dependency declarations as String: "group:name"
      Parameters:
      moduleName - The Module Name
      Returns:
      Dependency notation
    • create

      public org.gradle.api.provider.Provider<org.gradle.api.artifacts.Dependency> create(String moduleName, org.gradle.api.tasks.SourceSet sourceSetWithModuleInfo)
    • gav

      public org.gradle.api.provider.Provider<String> gav(String moduleName, String version)
      Converts 'Module Name' and 'Version' to GAV coordinates that can be used in dependency declarations as String: "group:name:version"
      Parameters:
      moduleName - The Module Name
      version - The (required) version
      Returns:
      Dependency notation
    • gav

      public org.gradle.api.provider.Provider<String> gav(org.gradle.api.provider.Provider<String> moduleName, org.gradle.api.provider.Provider<String> version)
      Converts 'Module Name' and 'Version' to GAV coordinates that can be used in dependency declarations as String: "group:name:version"
      Parameters:
      moduleName - The Module Name
      version - The (required) version
      Returns:
      Dependency notation
    • gav

      public org.gradle.api.provider.Provider<org.gradle.api.artifacts.ExternalDependency> gav(String moduleName)
      If a Version Catalog is used: Converts 'Module Name' and the matching 'Version' from the Version Catalog to GAV coordinates that can be used in dependency Declarations as Map: [group: "...", name: "...", version: "..."]
      Parameters:
      moduleName - The Module Name
      Returns:
      Dependency notation
    • gav

      public org.gradle.api.provider.Provider<org.gradle.api.artifacts.ExternalDependency> gav(org.gradle.api.provider.Provider<String> moduleName)
      If a Version Catalog is used: Converts 'Module Name' and the matching 'Version' from the Version Catalog to GAV coordinates that can be used in dependency Declarations as Map: [group: "...", name: "...", version: "..."]
      Parameters:
      moduleName - The Module Name
      Returns:
      Dependency notation
    • moduleName

      public org.gradle.api.provider.Provider<String> moduleName(String ga)
      Finds the Module Name for given coordinates
      Parameters:
      ga - The GA coordinates
      Returns:
      the first name found or unset
    • moduleName

      public org.gradle.api.provider.Provider<String> moduleName(org.gradle.api.provider.Provider<String> ga)
      Finds the Module Name for given coordinates
      Parameters:
      ga - The GA coordinates
      Returns:
      the first name found or unset
    • allLocalModules

      public Set<LocalModule> allLocalModules()
      Returns:
      information about all modules defined in module-info.java files in the build
    • versionsFromConsistentResolution

      @Deprecated public org.gradle.api.artifacts.Configuration versionsFromConsistentResolution(String... versionsProvidingProjects)
      Deprecated.
      use the 'org.gradlex.jvm-dependency-conflict-resolution' plugin instead.
    • versionsFromConsistentResolution

      @Deprecated public org.gradle.api.artifacts.Configuration versionsFromConsistentResolution(Collection<String> versionsProvidingProjects)
      Deprecated.
      use the 'org.gradlex.jvm-dependency-conflict-resolution' plugin instead.
      Use consistent resolution to manage versions consistently through in the main application project(s).
      Parameters:
      versionsProvidingProjects - projects which runtime classpaths are the runtime classpaths of the applications/services being built.
    • addRequiresRuntimeSupport

      public void addRequiresRuntimeSupport(org.gradle.api.tasks.SourceSet sourceSetForModuleInfo, org.gradle.api.tasks.SourceSet sourceSetForClasspath)
      Adds support for compiling module-info.java in the given source set with the given task, if 'requires runtime' dependencies are used.
      Parameters:
      sourceSetForModuleInfo - The source set that contains the module-info.java (e.g. 'main')
      sourceSetForClasspath - The source set that contains the code that is compiled (e.g. 'test')
    • getProject

      @Inject protected abstract org.gradle.api.Project getProject()
    • getObjects

      @Inject protected abstract org.gradle.api.model.ObjectFactory getObjects()
    • getProviders

      @Inject protected abstract org.gradle.api.provider.ProviderFactory getProviders()
    • getLayout

      @Inject protected abstract org.gradle.api.file.ProjectLayout getLayout()
    • getDependencies

      @Inject protected abstract org.gradle.api.artifacts.dsl.DependencyHandler getDependencies()
    • getConfigurations

      @Inject protected abstract org.gradle.api.artifacts.ConfigurationContainer getConfigurations()
    • getTasks

      @Inject protected abstract org.gradle.api.tasks.TaskContainer getTasks()