Java - GeoLite2 database corruption when creating .jar in Gradle

74 views Asked by At

Recently I have been using GeoLite2 City database in my application to get information on the user location using their IP. The database works fine in my local machine, but when I compile it to a .jar using ./gradlew -Pprod clean bootJar I get this error when trying to access a component that uses the database:

InvalidDatabaseException
Could not find a MaxMind DB metadata marker in this file (<InputStream>). Is this a valid MaxMind DB file?

Searching for this error, I found this thread on StackOveflow that explained the need to disable resource filtering for binary files in Maven. Thing is, I'm using gradle, which as far as I know, does not have this resource and should not be facing this problem.

Regardless, I tried searching for a solution and tried implementing something based on this thread to fix the issue. I ended up adding this to my build.gradle:

processResources {
    from('src/main/resources/data') {
        include '**/*.mmdb'
    }
}

That, however, also did not work. It seems like this should be a simple issue, but I have not been able to solve it and neither did I find someone with the same issue so far. Any help would be appreaciated!

1

There are 1 answers

0
allkenang On

You could try this (note: I did not test it)

processResources {
     filesNotMatching("**/*.mmdb") {
         
     }
 }