TNG / ArchUnit

A Java architecture test library, to specify and assert architecture rules in plain Java
http://archunit.org
Apache License 2.0
3.24k stars 298 forks source link

jar files cannot be loaded using http #643

Open OLibutzki opened 3 years ago

OLibutzki commented 3 years ago

I would like to import the classes using a http url which references a jar file:

final JavaClasses javaClasses = new ClassFileImporter().importUrl(
new URL("jar:https://repo1.maven.org/maven2/org/jmolecules/integrations/jmolecules-spring-data-jpa/0.3.0/jmolecules-spring-data-jpa-0.3.0.jar!/")
);

Unfortunately the com.tngtech.archunit.core.importer.NormalizedUri replaces :// with :/. Because of this replacement the url changes to https:/repo1.maven.org/maven2/org/jmolecules/integrations/jmolecules-spring-data-jpa/0.3.0/jmolecules-spring-data-jpa-0.3.0.jar!/ and the file cannot be downloaded anymore.

codecholeric commented 3 years ago

Yes, back then I decided to only import local file URIs, because I didn't think anybody would have the use case to import http URIs :wink: Also because I thought that most times users would want to import classes multiple times and then having it locally would make sense anyway. Would you like to create a PR for it? I can unfortunately not promise anything how fast I can get to the issue myself...

OLibutzki commented 3 years ago

To be honest, the issue is not high prioritized as there is a reasonable workaround of adding the library as runtime dependency and excluding all its transitive dependencies.

That does the trick and I benefit from maven's local repository caching.

Nevertheless, it's a bug (or missing feature) and therefore it's worth to have this issue.