rzo1 commented on code in PR #606: URL: https://github.com/apache/opennlp/pull/606#discussion_r1639507441
########## opennlp-tools-models/src/main/java/opennlp/tools/models/ClasspathModelFinder.java: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package opennlp.tools.models; + +import java.net.URI; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + +import io.github.classgraph.ClassGraph; Review Comment: Reyling on `java.class.path` property or trying to cast to `URLClassloader` (on the current thread context class loader) is also error prone as not all vendors / classloaders extend it anymore or use the `Class-Path:` property in manifests for Java 9+ module system. Implementing it with pure JDK classes from scratch within OpenNLP and cover all edge cases (like it is done in [Classgraph](https://stackoverflow.com/a/31785767)) might be cumbersome and doesn't add much value just for the sake of reducing transient libs here. What we could do as a compromise is to implement (in an additional PR) some sort of hacky loader/scan alternative which does not cover all edge cases and declare `classgraph` as an **optional** dependency in this module. People, who don't want to use `classgraph` can use the hacky alternative (if it covers their use-case) via `ucp` / reflections. People, who need a more sophisticated solution can add `classgraph` as a dependency on their end and have the functionality availble in all edge cases and environments (such as servlet containers, ee containers, quarkus / spring boot envs, etc.) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
