|
15 | 15 | import liquibase.ext.TimeoutLockService; |
16 | 16 | import liquibase.lockservice.LockServiceFactory; |
17 | 17 | import liquibase.resource.ClassLoaderResourceAccessor; |
18 | | -import liquibase.resource.InputStreamList; |
| 18 | +import liquibase.resource.Resource; |
| 19 | +import liquibase.resource.URIResource; |
19 | 20 | import se.fortnox.reactivewizard.db.DbDriver; |
20 | 21 |
|
21 | 22 | import javax.inject.Inject; |
22 | 23 | import java.io.IOException; |
23 | | -import java.io.InputStream; |
24 | 24 | import java.net.URI; |
25 | 25 | import java.net.URISyntaxException; |
26 | 26 | import java.net.URL; |
@@ -56,9 +56,7 @@ public LiquibaseMigrate(LiquibaseConfig liquibaseConfig) throws LiquibaseExcepti |
56 | 56 | while (resources.hasMoreElements()) { |
57 | 57 | URL url = resources.nextElement(); |
58 | 58 | String file = url.toExternalForm(); |
59 | | - int jarFileSep = file.lastIndexOf('!'); |
60 | | - String loggedFileName = file.substring(jarFileSep + 1); |
61 | | - Liquibase liquibase = new Liquibase(loggedFileName, new UrlAwareClassLoaderResourceAccessor(file), conn); |
| 59 | + Liquibase liquibase = new Liquibase(file, new UrlAwareClassLoaderResourceAccessor(file), conn); |
62 | 60 | liquibase.getDatabase().setDefaultSchemaName(liquibaseConfig.getSchema()); |
63 | 61 |
|
64 | 62 | liquibaseList.add(liquibase); |
@@ -152,34 +150,30 @@ void exit() { |
152 | 150 | System.exit(0); |
153 | 151 | } |
154 | 152 |
|
155 | | - class UrlAwareClassLoaderResourceAccessor extends ClassLoaderResourceAccessor { |
| 153 | + static class UrlAwareClassLoaderResourceAccessor extends ClassLoaderResourceAccessor { |
156 | 154 | private final String realFileName; |
157 | 155 |
|
158 | 156 | public UrlAwareClassLoaderResourceAccessor(String realFileName) { |
159 | 157 | this.realFileName = realFileName; |
160 | 158 | } |
161 | 159 |
|
162 | 160 | @Override |
163 | | - public InputStreamList openStreams(String relativeTo, String path) throws IOException { |
| 161 | + public Resource get(String path) throws IOException { |
164 | 162 | if (realFileName.endsWith(path)) { |
165 | 163 | path = realFileName; |
166 | 164 | } |
167 | 165 |
|
168 | 166 | if (path.startsWith("file:") || path.startsWith("jar:file:")) { |
169 | 167 | URL url = new URL(path); |
170 | | - InputStream resourceAsStream = url.openStream(); |
171 | | - InputStreamList inputStreamList = new InputStreamList(); |
172 | 168 | URI uri; |
173 | 169 | try { |
174 | 170 | uri = url.toURI(); |
175 | 171 | } catch (URISyntaxException e) { |
176 | 172 | throw new RuntimeException(e); |
177 | 173 | } |
178 | | - inputStreamList.add(uri, resourceAsStream); |
179 | | - |
180 | | - return inputStreamList; |
| 174 | + return new URIResource(path, uri); |
181 | 175 | } |
182 | | - return super.openStreams(relativeTo, path); |
| 176 | + return super.get(path); |
183 | 177 | } |
184 | 178 | } |
185 | 179 | } |
0 commit comments