@@ -77,7 +77,8 @@ public abstract class JavaModuleDependenciesExtension {
7777 private static final String INTERNAL = "internal" ;
7878
7979 private final VersionCatalogsExtension versionCatalogs ;
80- private final ModuleInfoCache moduleInfoCache ;
80+
81+ public abstract Property <ModuleInfoCache > getModuleInfoCache ();
8182
8283 /**
8384 * Custom mappings can be defined in a property files in your build.
@@ -134,7 +135,7 @@ public abstract class JavaModuleDependenciesExtension {
134135
135136 public JavaModuleDependenciesExtension (VersionCatalogsExtension versionCatalogs ) {
136137 this .versionCatalogs = versionCatalogs ;
137- this . moduleInfoCache = getObjects ().newInstance (ModuleInfoCache .class );
138+ getModuleInfoCache (). convention ( getProviders (). provider (() -> getObjects ().newInstance (ModuleInfoCache .class , false )) );
138139 getModulesProperties ().set (new File (getProject ().getRootDir (), "gradle/modules.properties" ));
139140 getVersionCatalogName ().convention ("libs" );
140141 getModuleNameCheck ().convention (true );
@@ -212,7 +213,7 @@ private String toProjectName(String moduleNameSuffix) {
212213 }
213214
214215 public Provider <Dependency > create (String moduleName , SourceSet sourceSetWithModuleInfo ) {
215- if (moduleInfoCache . initializedInSettings ()) {
216+ if (getModuleInfoCache (). get (). isInitializedInSettings ()) {
216217 return createPrecise (moduleName , sourceSetWithModuleInfo );
217218 } else {
218219 return createWithGuessing (moduleName , sourceSetWithModuleInfo );
@@ -221,8 +222,8 @@ public Provider<Dependency> create(String moduleName, SourceSet sourceSetWithMod
221222
222223 public Provider <Dependency > createPrecise (String moduleName , SourceSet sourceSetWithModuleInfo ) {
223224 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 );
226227
227228 if (projectPath != null ) {
228229 // local project
@@ -243,7 +244,7 @@ public Provider<Dependency> createWithGuessing(String moduleName, SourceSet sour
243244 Map <String , String > allProjectNamesAndGroups = getProject ().getRootProject ().getSubprojects ().stream ().collect (
244245 Collectors .toMap (Project ::getName , p -> (String ) p .getGroup (), (a , b ) -> a ));
245246
246- ModuleInfo moduleInfo = moduleInfoCache .get (sourceSetWithModuleInfo , getProviders ());
247+ ModuleInfo moduleInfo = getModuleInfoCache (). get () .get (sourceSetWithModuleInfo , getProviders ());
247248 String ownModuleNamesPrefix = moduleInfo .moduleNamePrefix (getProject ().getName (), sourceSetWithModuleInfo .getName (), getModuleNameCheck ().get ());
248249
249250 String moduleNameSuffix = ownModuleNamesPrefix == null ? null :
@@ -510,7 +511,7 @@ public void addRequiresRuntimeSupport(SourceSet sourceSetForModuleInfo, SourceSe
510511 }
511512
512513 void doAddRequiresRuntimeSupport (SourceSet sourceSetForModuleInfo , SourceSet sourceSetForClasspath ) {
513- List <String > requiresRuntime = getModuleInfoCache ().get (sourceSetForModuleInfo , getProviders ()).get (REQUIRES_RUNTIME );
514+ List <String > requiresRuntime = getModuleInfoCache ().get (). get ( sourceSetForModuleInfo , getProviders ()).get (REQUIRES_RUNTIME );
514515 String generatorTaskName = sourceSetForClasspath .getTaskName ("generate" , "syntheticModuleInfoFolders" );
515516 if (requiresRuntime .isEmpty () || getProject ().getTasks ().getNames ().contains (generatorTaskName )) {
516517 // Already active or not needed for this source set
@@ -573,8 +574,4 @@ private String moduleDebugInfo(String moduleName, File moduleInfoFile, File root
573574
574575 @ Inject
575576 protected abstract SourceSetContainer getSourceSets ();
576-
577- ModuleInfoCache getModuleInfoCache () {
578- return moduleInfoCache ;
579- }
580577}
0 commit comments