@@ -148,14 +148,31 @@ private Provider<String> mapByPrefix(Provider<String> moduleName) {
148
148
.filter (e -> moduleName .get ().startsWith (e .getKey ())).findFirst ();
149
149
if (prefixToGroup .isPresent ()) {
150
150
String group = prefixToGroup .get ().getValue ();
151
- String artifact = moduleName .get ().substring (prefixToGroup .get ().getKey ().length ());
151
+ String artifact = toProjectName ( moduleName .get ().substring (prefixToGroup .get ().getKey ().length () ));
152
152
return group + ":" + artifact ;
153
153
}
154
154
return null ;
155
155
}
156
156
);
157
157
}
158
158
159
+ private String toProjectName (String moduleNameSuffix ) {
160
+ List <String > allProjectNames = getProject ().getRootProject ().getSubprojects ().stream ().map (Project ::getName ).collect (Collectors .toList ());
161
+
162
+ Optional <String > perfectMatch = allProjectNames .stream ().filter (p -> p .replace ("-" , "." ).equals (moduleNameSuffix )).findFirst ();
163
+ Optional <String > existingProjectName = allProjectNames .stream ().filter (p -> moduleNameSuffix != null && moduleNameSuffix .startsWith (p .replace ("-" , "." ) + "." ))
164
+ .max (Comparator .comparingInt (String ::length ));
165
+
166
+ if (perfectMatch .isPresent ()) {
167
+ return perfectMatch .get ();
168
+ } else if (existingProjectName .isPresent ()) {
169
+ String capabilityClassifier = moduleNameSuffix .substring (existingProjectName .get ().length () + 1 ).replace ("." , "-" );
170
+ return existingProjectName .get () + "|" + capabilityClassifier ; // no exact match (assume last segment is capability)
171
+ }
172
+
173
+ return moduleNameSuffix ;
174
+ }
175
+
159
176
public Provider <Dependency > create (String moduleName , SourceSet sourceSetWithModuleInfo ) {
160
177
return getProviders ().provider (() -> {
161
178
Map <String , String > allProjectNamesAndGroups = getProject ().getRootProject ().getSubprojects ().stream ().collect (
0 commit comments