Parses a dependency coordinate in Maven or Ivy shorthand form into its component parts. Recognized forms: Maven: group:module:version[:classifier][@ext] Ivy: group#module;version (translated internally to the Maven form before parsing) @param a
(String allstr)
| 40 | * {@code version}, {@code classifier}, and {@code ext} entries |
| 41 | */ |
| 42 | public static Map<String, Object> getIvyParts(String allstr) { |
| 43 | Map<String, Object> result = new LinkedHashMap<String, Object>(); |
| 44 | if (allstr == null) return result; |
| 45 | // Accept the Ivy shorthand "group#module;version" by translating its separators to |
| 46 | // the Maven form before parsing. Neither '#' nor ';' is legal in a groupId, artifactId, |
| 47 | // or version (Ivy ranges use '[]()' not '#;'), so a straight replace cannot collide |
| 48 | // with the Maven form. |
| 49 | allstr = allstr.replace('#', ':').replace(';', ':'); |
| 50 | String ext = ""; |
| 51 | String[] parts; |
| 52 | if (allstr.contains("@")) { |
| 53 | parts = allstr.split("@"); |
| 54 | if (parts.length > 2) return result; |
| 55 | if (parts.length > 1) ext = parts[1]; |
| 56 | if (parts.length > 0) allstr = parts[0]; |
| 57 | } |
| 58 | parts = allstr.split(":"); |
| 59 | if (parts.length > 4) return result; |
| 60 | if (parts.length > 3) result.put("classifier", parts[3]); |
| 61 | if (parts.length > 2) result.put("version", parts[2]); |
| 62 | else result.put("version", "*"); |
| 63 | if (!ext.isEmpty()) result.put("ext", ext); |
| 64 | if (parts.length > 1) result.put("module", parts[1]); |
| 65 | if (parts.length > 0) result.put("group", parts[0]); |
| 66 | return result; |
| 67 | } |
| 68 | } |