Skip to content

Commit

Permalink
Liquibase.xml files should be searched from all module jar files -
Browse files Browse the repository at this point in the history
TRUNK-5407
  • Loading branch information
dkayiwa committed Jun 12, 2018
1 parent 992be67 commit 775e726
Showing 1 changed file with 3 additions and 37 deletions.
40 changes: 3 additions & 37 deletions api/src/main/java/org/openmrs/module/ModuleFactory.java
Expand Up @@ -1018,43 +1018,9 @@ private static void runDiff(Module module, String version, String sql) {
* @param module the module being executed on
*/
private static void runLiquibase(Module module) {
JarFile jarFile = null;
boolean liquibaseFileExists = false;

try {
try {
jarFile = new JarFile(module.getFile());
}
catch (IOException e) {
throw new ModuleException("Unable to get jar file", module.getName(), e);
}

//check whether module has a liquibase.xml
InputStream inStream = null;
ZipEntry entry = null;
try {
inStream = ModuleUtil.getResourceFromApi(jarFile, module.getModuleId(), module.getVersion(),
MODULE_CHANGELOG_FILENAME);
if (inStream == null) {
// Try the old way. Loading from the root of the omod
entry = jarFile.getEntry(MODULE_CHANGELOG_FILENAME);
}
liquibaseFileExists = (inStream != null) || (entry != null);
}
finally {
IOUtils.closeQuietly(inStream);
}
}
finally {
try {
if (jarFile != null) {
jarFile.close();
}
}
catch (IOException e) {
log.warn("Unable to close jarfile: " + jarFile.getName());
}
}
ModuleClassLoader moduleClassLoader = ModuleFactory.getModuleClassLoaderMap().get(module);
InputStream inStream = moduleClassLoader.getResourceAsStream(MODULE_CHANGELOG_FILENAME);
boolean liquibaseFileExists = (inStream != null);

if (liquibaseFileExists) {
try {
Expand Down

0 comments on commit 775e726

Please sign in to comment.