public static Optional < Dependency > parseJarName ( String sourceName , String jarName ) { if ( SPECIAL_CASES . containsKey ( jarName ) ) { Dependency specialCase = SPECIAL_CASES . get ( jarName ) ; return Optional . of ( new Dependency ( sourceName , specialCase . getName ( ) , specialCase . getVersion ( ) ) ) ; } // Go over all known patterns for ( Pattern p : PATTERNS ) { Matcher m = p . matcher ( jarName ) ; if ( m . matches ( ) ) { LOG . trace ( "Applied pattern '{}' to {}" , p . pattern ( ) , jarName ) ; return Optional . of ( new Dependency ( sourceName , m . group ( 1 ) , m . group ( 2 ) ) ) ; } } // Otherwise this jar name is unknown to us return Optional . empty ( ) ; }
Generate dependency from a jar file name .