Search code examples
javamavenjarwarliquibase

How to access file in a JAR when running a Maven build


I want to run a liquibase update by the liquibase-maven-plugin, but the changeset yml file is inside a .jar that I pull in by dependency.

When I open the .jar with TotalCommander, it has the following structure: xy.jar/changelog/changeset.yml.

I tried including it as a resource directory, but it failed telling me the .jar is not a directory.

I also tried building to a WAR and just setting the liquibase changeLogFile property to the path leading to the .jar, like {projectDir}/target/..war/..lib/..jar/changelog/myFile.yml But maven could not find it this way.

Is it possible to access this file somehow?


Solution

  • Thanks for the reply, but the solution was simpler, I'm just rusty in this area :) I simply had to add the required JAR from the WAR as a Maven Dependency. This adds the JAR's content to the classpath in the Maven build process, so I can reference to it's files as they were on the project root path.

    TLDR: add JAR as dependency in the pom and use the path:

    <changeLogFile>changelog/xy.jar</changeLogFile>