@@ -77,7 +77,8 @@ public abstract class JavaModuleDependenciesExtension {
77
77
private static final String INTERNAL = "internal" ;
78
78
79
79
private final VersionCatalogsExtension versionCatalogs ;
80
- private final ModuleInfoCache moduleInfoCache ;
80
+
81
+ public abstract Property <ModuleInfoCache > getModuleInfoCache ();
81
82
82
83
/**
83
84
* Custom mappings can be defined in a property files in your build.
@@ -134,7 +135,7 @@ public abstract class JavaModuleDependenciesExtension {
134
135
135
136
public JavaModuleDependenciesExtension (VersionCatalogsExtension versionCatalogs ) {
136
137
this .versionCatalogs = versionCatalogs ;
137
- this . moduleInfoCache = getObjects ().newInstance (ModuleInfoCache .class );
138
+ getModuleInfoCache (). convention ( getProviders (). provider (() -> getObjects ().newInstance (ModuleInfoCache .class , false )) );
138
139
getModulesProperties ().set (new File (getProject ().getRootDir (), "gradle/modules.properties" ));
139
140
getVersionCatalogName ().convention ("libs" );
140
141
getModuleNameCheck ().convention (true );
@@ -212,7 +213,7 @@ private String toProjectName(String moduleNameSuffix) {
212
213
}
213
214
214
215
public Provider <Dependency > create (String moduleName , SourceSet sourceSetWithModuleInfo ) {
215
- if (moduleInfoCache . initializedInSettings ()) {
216
+ if (getModuleInfoCache (). get (). isInitializedInSettings ()) {
216
217
return createPrecise (moduleName , sourceSetWithModuleInfo );
217
218
} else {
218
219
return createWithGuessing (moduleName , sourceSetWithModuleInfo );
@@ -221,8 +222,8 @@ public Provider<Dependency> create(String moduleName, SourceSet sourceSetWithMod
221
222
222
223
public Provider <Dependency > createPrecise (String moduleName , SourceSet sourceSetWithModuleInfo ) {
223
224
return getProviders ().provider (() -> {
224
- String projectPath = moduleInfoCache .getProjectPath (moduleName );
225
- String capability = moduleInfoCache .getCapability (moduleName );
225
+ String projectPath = getModuleInfoCache (). get () .getProjectPath (moduleName );
226
+ String capability = getModuleInfoCache (). get () .getCapability (moduleName );
226
227
227
228
if (projectPath != null ) {
228
229
// local project
@@ -243,7 +244,7 @@ public Provider<Dependency> createWithGuessing(String moduleName, SourceSet sour
243
244
Map <String , String > allProjectNamesAndGroups = getProject ().getRootProject ().getSubprojects ().stream ().collect (
244
245
Collectors .toMap (Project ::getName , p -> (String ) p .getGroup (), (a , b ) -> a ));
245
246
246
- ModuleInfo moduleInfo = moduleInfoCache .get (sourceSetWithModuleInfo , getProviders ());
247
+ ModuleInfo moduleInfo = getModuleInfoCache (). get () .get (sourceSetWithModuleInfo , getProviders ());
247
248
String ownModuleNamesPrefix = moduleInfo .moduleNamePrefix (getProject ().getName (), sourceSetWithModuleInfo .getName (), getModuleNameCheck ().get ());
248
249
249
250
String moduleNameSuffix = ownModuleNamesPrefix == null ? null :
@@ -495,7 +496,7 @@ public void addRequiresRuntimeSupport(SourceSet sourceSetForModuleInfo, SourceSe
495
496
}
496
497
497
498
void doAddRequiresRuntimeSupport (SourceSet sourceSetForModuleInfo , SourceSet sourceSetForClasspath ) {
498
- List <String > requiresRuntime = getModuleInfoCache ().get (sourceSetForModuleInfo , getProviders ()).get (REQUIRES_RUNTIME );
499
+ List <String > requiresRuntime = getModuleInfoCache ().get (). get ( sourceSetForModuleInfo , getProviders ()).get (REQUIRES_RUNTIME );
499
500
String generatorTaskName = sourceSetForClasspath .getTaskName ("generate" , "syntheticModuleInfoFolders" );
500
501
if (requiresRuntime .isEmpty () || getProject ().getTasks ().getNames ().contains (generatorTaskName )) {
501
502
// Already active or not needed for this source set
@@ -558,8 +559,4 @@ private String moduleDebugInfo(String moduleName, File moduleInfoFile, File root
558
559
559
560
@ Inject
560
561
protected abstract SourceSetContainer getSourceSets ();
561
-
562
- ModuleInfoCache getModuleInfoCache () {
563
- return moduleInfoCache ;
564
- }
565
562
}
0 commit comments