Class JavaModuleDependenciesExtension
java.lang.Object
org.gradlex.javamodule.dependencies.JavaModuleDependenciesExtension
- 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
ConstructorsConstructorDescriptionJavaModuleDependenciesExtension(@Nullable org.gradle.api.artifacts.VersionCatalogsExtension versionCatalogs, File rootDir) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRequiresRuntimeSupport(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>org.gradle.api.provider.Provider<String>Converts 'Module Name' to GA coordinates that can be used in dependency declarations as String: "group:name"org.gradle.api.provider.Provider<String>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>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>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>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"voidIf 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.ConfigurationContainerprotected abstract org.gradle.api.artifacts.dsl.DependencyHandlerprotected abstract org.gradle.api.file.ProjectLayoutabstract 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'.If your Module Names all start with a common prefix (e.g.Register mapping from Module Name to GA Coordinates (and optionally Capability Coordinates).abstract org.gradle.api.file.RegularFilePropertyCustom mappings can be defined in a property files in your build.protected abstract org.gradle.api.model.ObjectFactoryprotected abstract org.gradle.api.Projectprotected abstract org.gradle.api.provider.ProviderFactoryprotected abstract org.gradle.api.tasks.TaskContainergetTasks()abstract org.gradle.api.provider.Property<String>abstract org.gradle.api.provider.Property<Boolean>Deprecated.org.gradle.api.provider.Provider<String>moduleName(String ga) Finds the Module Name for given coordinatesorg.gradle.api.provider.Provider<String>moduleName(org.gradle.api.provider.Provider<String> ga) Finds the Module Name for given coordinatesorg.gradle.api.artifacts.ConfigurationversionsFromConsistentResolution(String... versionsProvidingProjects) Deprecated.use the 'org.gradlex.jvm-dependency-conflict-resolution' plugin instead.org.gradle.api.artifacts.ConfigurationversionsFromConsistentResolution(Collection<String> versionsProvidingProjects) Deprecated.use the 'org.gradlex.jvm-dependency-conflict-resolution' plugin instead.
-
Constructor Details
-
JavaModuleDependenciesExtension
public JavaModuleDependenciesExtension(@Nullable org.gradle.api.artifacts.VersionCatalogsExtension versionCatalogs, File rootDir)
-
-
Method Details
-
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
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
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.- Returns:
- no-op
-
getVersionCatalogName
- Returns:
- If a Version Catalog is used: which catalog? (default is 'libs')
-
getModuleNameCheck
Fail the build if a Module Name does not fit the corresponding project and source set names; defaults to 'true'. -
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
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
Converts 'Module Name' and 'Version' to GAV coordinates that can be used in dependency declarations as String: "group:name:version"- Parameters:
moduleName- The Module Nameversion- 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 Nameversion- 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
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
- 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()
-