Devskiller / jpa2ddl

JPA Schema Generator Plugin
Apache License 2.0
110 stars 33 forks source link

ZipFileSystem must be created before opening #44

Closed m-pavel closed 10 months ago

m-pavel commented 3 years ago

Allow to run plugin in multi-module maven project, #43

oliverhenlich commented 2 years ago

Hi @jkubrynski,

Any thoughts on this PR? We have hit this issue (FileSystemNotFoundException) for anyone running our build on a non-windows machine.

I've tracked down where there is a difference in behaviour on the two platforms to this method:

static Set<String> listClassNamesInPackage(String packageName) throws Exception {
        Set<String> classes = new HashSet<>();
        Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources(packageName.replace('.', File.separatorChar));
        if (!resources.hasMoreElements()) {

Specifically the call to .getContextClassLoader().getResources() behaves differently on windows and linux

It's the presence of those jar paths that triggers the FileSystemNotFoundException this PR addresses.

Here is an example of the paths:

0 "file:/Users/bla/dev/src/company/main-modules/domain/src/main/java/com/company"
1 "file:/Users/bla/dev/src/company/main-modules/domain/target/generated-sources/jaxb/com/company"
2 "file:/Users/bla/dev/src/company/main-modules/domain/target/generated-sources/protobuf/java/com/company"
3 "file:/Users/bla/dev/src/company/main-modules/domain/target/generated-sources/protobuf/grpc-java/com/company"
4 "file:/Users/bla/dev/src/company/main-modules/domain/target/generated-sources/java/com/company"
5 "file:/Users/bla/dev/src/company/main-modules/domain/target/classes/com/company"
6 "jar:file:/Users/bla/.m2/repository/com/company/common/company-common-framework/2.2.12/company-common-framework-2.2.12.jar!/com/company"
7 "jar:file:/Users/bla/.m2/repository/com/company/common/company-common-protobuf/2.2.12/company-common-protobuf-2.2.12.jar!/com/company"
8 "jar:file:/Users/bla/.m2/repository/com/company/common/company-common-hibernate/2.2.12/company-common-hibernate-2.2.12.jar!/com/company"

Cheers Oliver