2020import org .gradle .api .artifacts .Configuration ;
2121import org .gradle .api .artifacts .ConfigurationContainer ;
2222import org .gradle .api .artifacts .Dependency ;
23+ import org .gradle .api .artifacts .ExternalDependency ;
2324import org .gradle .api .artifacts .ModuleDependency ;
2425import org .gradle .api .artifacts .ProjectDependency ;
2526import org .gradle .api .artifacts .VersionCatalog ;
6364import java .util .stream .Collectors ;
6465
6566import static java .util .Optional .empty ;
67+ import static org .gradlex .javamodule .dependencies .internal .utils .DependencyDeclarationsUtil .copyVersionConstraint ;
6668import static org .gradlex .javamodule .dependencies .internal .utils .ModuleInfo .Directive .REQUIRES_RUNTIME ;
6769
6870/**
@@ -280,7 +282,7 @@ private Provider<Dependency> createWithGuessing(String moduleName, SourceSet sou
280282 private @ Nullable ModuleDependency createExternalDependency (String moduleName ) {
281283 Provider <String > coordinates = getModuleNameToGA ().getting (moduleName ).orElse (mapByPrefix (getProviders ().provider (() -> moduleName )));
282284 if (coordinates .isPresent ()) {
283- Map < String , Object > component ;
285+ ExternalDependency component ;
284286 String capability ;
285287 if (coordinates .get ().contains ("|" )) {
286288 String [] split = coordinates .get ().split ("\\ |" );
@@ -344,7 +346,7 @@ public Provider<String> gav(Provider<String> moduleName, Provider<String> versio
344346 * @return Dependency notation
345347 */
346348 @ SuppressWarnings ("unused" )
347- public Provider <Map < String , Object > > gav (String moduleName ) {
349+ public Provider <ExternalDependency > gav (String moduleName ) {
348350 return ga (moduleName ).map (ga -> findGav (ga , moduleName ));
349351 }
350352
@@ -358,24 +360,19 @@ public Provider<Map<String, Object>> gav(String moduleName) {
358360 * @return Dependency notation
359361 */
360362 @ SuppressWarnings ("unused" )
361- public Provider <Map < String , Object > > gav (Provider <String > moduleName ) {
363+ public Provider <ExternalDependency > gav (Provider <String > moduleName ) {
362364 return ga (moduleName ).map (ga -> findGav (ga , moduleName .get ()));
363365 }
364366
365- private Map < String , Object > findGav (String ga , String moduleName ) {
367+ private ExternalDependency findGav (String ga , String moduleName ) {
366368 VersionCatalog catalog = versionCatalogs == null ? null : versionCatalogs .find (getVersionCatalogName ().get ()).orElse (null );
367369 Optional <VersionConstraint > version = catalog == null ? empty () : catalog .findVersion (moduleName .replace ('_' , '.' ));
368- Map <String , Object > gav = new HashMap <>();
369- String [] gaSplit = ga .split (":" );
370- if (gaSplit .length < 2 ) {
371- throw new RuntimeException ("Invalid mapping: " + moduleName + "=" + ga );
372- }
373- gav .put (GAV .GROUP , gaSplit [0 ]);
374- gav .put (GAV .ARTIFACT , gaSplit [1 ]);
375- version .ifPresent (versionConstraint -> gav .put (GAV .VERSION , versionConstraint ));
376- return gav ;
370+ ExternalDependency dependency = (ExternalDependency ) getDependencies ().create (ga );
371+ version .ifPresent (versionConstraint -> dependency .version (copy -> copyVersionConstraint (versionConstraint , copy )));
372+ return dependency ;
377373 }
378374
375+
379376 /**
380377 * Finds the Module Name for given coordinates
381378 *
0 commit comments