1414
1515import static java .util .Optional .empty ;
1616
17+ /**
18+ * - Configure behavior of the 'java-module-dependencies' plugin
19+ * - Add additional mappings using {@link #getModuleNameToGA()}
20+ * - Define dependencies and dependency constraints by Module Name
21+ * using {@link #ga(String)}, {@link #gav(String, String)} or {@link #gav(String)}
22+ */
1723public abstract class JavaModuleDependenciesExtension {
1824 static final String JAVA_MODULE_DEPENDENCIES = "javaModuleDependencies" ;
1925
2026 private final VersionCatalogsExtension versionCatalogs ;
2127
28+ /**
29+ * @return the mappings from Module Name to GA coordinates; can be modified
30+ */
2231 public abstract MapProperty <String , String > getModuleNameToGA ();
2332
33+ /**
34+ * @return If a Version Catalog is used: print a WARN for missing versions (default is 'true')
35+ */
2436 public abstract Property <Boolean > getWarnForMissingVersions ();
2537
38+ /**
39+ * @return If a Version Catalog is used: which catalog? (default is 'libs')
40+ */
2641 public abstract Property <String > getVersionCatalogName ();
2742
2843 public JavaModuleDependenciesExtension (VersionCatalogsExtension versionCatalogs ) {
@@ -35,6 +50,9 @@ public JavaModuleDependenciesExtension(VersionCatalogsExtension versionCatalogs)
3550 /**
3651 * Converts 'Module Name' to GA coordinates that can be used in
3752 * dependency declarations as String: "group:name"
53+ *
54+ * @param moduleName The Module Name
55+ * @return Dependency notation
3856 */
3957 public Provider <String > ga (String moduleName ) {
4058 return getModuleNameToGA ().getting (moduleName );
@@ -43,15 +61,23 @@ public Provider<String> ga(String moduleName) {
4361 /**
4462 * Converts 'Module Name' and 'Version' to GA coordinates that can be used in
4563 * dependency declarations as String: "group:name:version"
64+ *
65+ * @param moduleName The Module Name
66+ * @param version The (required) version
67+ * @return Dependency notation
4668 */
4769 public Provider <String > gav (String moduleName , String version ) {
4870 return getModuleNameToGA ().getting (moduleName ).map (s -> s + ":" + version );
4971 }
5072
5173 /**
74+ * If a Version Catalog is used:
5275 * Converts 'Module Name' and the matching 'Version' from the Version Catalog to
5376 * GAV coordinates that can be used in dependency Declarations as Map:
5477 * [group: "...", name: "...", version: "..."]
78+ *
79+ * @param moduleName The Module Name
80+ * @return Dependency notation
5581 */
5682 public Provider <Map <String , Object >> gav (String moduleName ) {
5783 Provider <String > ga = ga (moduleName );
@@ -73,6 +99,12 @@ public Provider<Map<String, Object>> gav(String moduleName) {
7399 });
74100 }
75101
102+ /**
103+ * Finds the Module Name for given coordinates
104+ *
105+ * @param ga The GA coordinates
106+ * @return the first name found or 'null'
107+ */
76108 @ Nullable
77109 public String moduleName (String ga ) {
78110 for (Map .Entry <String , String > mapping : getModuleNameToGA ().get ().entrySet ()) {
0 commit comments