0

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?

Hyderox
  • 13
  • 4
  • Although I answered your question, this question was previously asked and answered. [Reading a resource file from within jar](https://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar) [How to access Maven resources in JAR file?](https://stackoverflow.com/questions/38640729/how-to-access-maven-resources-in-jar-file) – Ramu Nov 09 '19 at 23:07
  • this is not really what I wanted to know. I don't use any java code in this process, just plain Maven resources – Hyderox Nov 11 '19 at 10:07

2 Answers2

0

You can read the file using below code.

InputStream inputStream = getClass().getClassLoader().getResourceAsStream("changelog/myFile.yml");
Ramu
  • 641
  • 6
  • 9
0

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>

Hyderox
  • 13
  • 4