@@ -33,11 +33,11 @@ public final class JavaDocsCrawler {
3333 // latest periodically to avoid crawling artifacts that stopped being published.
3434 private static final Map <String , String > GROUPS_AND_MIN_VERSION =
3535 Map .of (
36- "io.opentelemetry" , "1.49.0 " ,
37- "io.opentelemetry.instrumentation" , "2.15 .0" ,
38- "io.opentelemetry.contrib" , "1.46 .0" ,
39- "io.opentelemetry.semconv" , "1.32 .0" ,
40- "io.opentelemetry.proto" , "1.3.2 " );
36+ "io.opentelemetry" , "1.60.1 " ,
37+ "io.opentelemetry.instrumentation" , "2.25 .0" ,
38+ "io.opentelemetry.contrib" , "1.54 .0" ,
39+ "io.opentelemetry.semconv" , "1.40 .0" ,
40+ "io.opentelemetry.proto" , "1.10.0 " );
4141
4242 private static final String MAVEN_CENTRAL_BASE_URL =
4343 "https://search.maven.org/solrsearch/select?q=g:" ;
@@ -160,9 +160,10 @@ static List<Artifact> crawlJavaDocs(
160160 HttpClient client , String minVersion , List <Artifact > artifacts )
161161 throws IOException , InterruptedException {
162162 List <Artifact > updatedArtifacts = new ArrayList <>();
163+ SemanticVersion minSemanticVersion = SemanticVersion .parse (minVersion );
163164
164165 for (Artifact artifact : artifacts ) {
165- if (compareVersions (artifact .getVersion (), minVersion ) < 0 ) {
166+ if (SemanticVersion . parse (artifact .getVersion ()). compareTo ( minSemanticVersion ) < 0 ) {
166167 logger .info (
167168 String .format (
168169 "Skipping crawling %s due to version %s being less than minVersion %s" ,
@@ -210,13 +211,7 @@ static List<Artifact> crawlJavaDocs(
210211 return updatedArtifacts ;
211212 }
212213
213- static int compareVersions (String version , String otherVersion ) {
214- SemanticVersion semanticVersion = SemanticVersion .parse (version );
215- SemanticVersion otherSemanticVersion = SemanticVersion .parse (otherVersion );
216- return semanticVersion .compareTo (otherSemanticVersion );
217- }
218-
219- private static final class SemanticVersion implements Comparable <SemanticVersion > {
214+ static final class SemanticVersion implements Comparable <SemanticVersion > {
220215 private static final Comparator <List <Integer >> CORE_VERSION_COMPARATOR =
221216 (left , right ) -> {
222217 for (int i = 0 ; i < Math .max (left .size (), right .size ()); i ++) {
@@ -238,7 +233,7 @@ private SemanticVersion(List<Integer> coreVersionParts, String qualifier) {
238233 this .qualifier = qualifier ;
239234 }
240235
241- private static SemanticVersion parse (String version ) {
236+ static SemanticVersion parse (String version ) {
242237 String [] versionParts = version .split ("-" , 2 );
243238 List <Integer > coreVersionParts = new ArrayList <>();
244239 for (String part : versionParts [0 ].split ("\\ ." )) {
@@ -264,7 +259,53 @@ public int compareTo(SemanticVersion other) {
264259 if (other .qualifier .isEmpty ()) {
265260 return -1 ;
266261 }
267- return qualifier .compareTo (other .qualifier );
262+ return compareQualifier (qualifier , other .qualifier );
263+ }
264+
265+ private static int compareQualifier (String leftQualifier , String rightQualifier ) {
266+ String [] leftParts = leftQualifier .split ("\\ ." );
267+ String [] rightParts = rightQualifier .split ("\\ ." );
268+
269+ for (int i = 0 ; i < Math .max (leftParts .length , rightParts .length ); i ++) {
270+ if (i >= leftParts .length ) {
271+ return -1 ;
272+ }
273+ if (i >= rightParts .length ) {
274+ return 1 ;
275+ }
276+
277+ String leftIdentifier = leftParts [i ];
278+ String rightIdentifier = rightParts [i ];
279+ if (leftIdentifier .equals (rightIdentifier )) {
280+ continue ;
281+ }
282+
283+ boolean leftNumeric = isNumericIdentifier (leftIdentifier );
284+ boolean rightNumeric = isNumericIdentifier (rightIdentifier );
285+ if (leftNumeric && rightNumeric ) {
286+ if (leftIdentifier .length () != rightIdentifier .length ()) {
287+ return Integer .compare (leftIdentifier .length (), rightIdentifier .length ());
288+ }
289+ return leftIdentifier .compareTo (rightIdentifier );
290+ }
291+ if (leftNumeric != rightNumeric ) {
292+ return leftNumeric ? -1 : 1 ;
293+ }
294+ return leftIdentifier .compareTo (rightIdentifier );
295+ }
296+ return 0 ;
297+ }
298+
299+ private static boolean isNumericIdentifier (String identifier ) {
300+ if (identifier .isEmpty ()) {
301+ return false ;
302+ }
303+ for (int i = 0 ; i < identifier .length (); i ++) {
304+ if (!Character .isDigit (identifier .charAt (i ))) {
305+ return false ;
306+ }
307+ }
308+ return true ;
268309 }
269310 }
270311
0 commit comments