Fix postgres startup failure (#5539)
* Fix postgres startup failure * Spotless
This commit is contained in:
parent
5fa20438b6
commit
9027138962
|
@ -578,8 +578,8 @@
|
||||||
</dialect>
|
</dialect>
|
||||||
<dialect>
|
<dialect>
|
||||||
<className>ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgresDialect</className>
|
<className>ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgresDialect</className>
|
||||||
<prependFile>classpath:ca/uhn/fhir/jpa/docs/database/hapifhirpostgres94-init01.sql</prependFile>
|
|
||||||
<targetFileName>postgres.sql</targetFileName>
|
<targetFileName>postgres.sql</targetFileName>
|
||||||
|
<appendFile>classpath:ca/uhn/fhir/jpa/docs/database/hapifhirpostgres94-init01.sql</appendFile>
|
||||||
</dialect>
|
</dialect>
|
||||||
</dialects>
|
</dialects>
|
||||||
<outputDirectory>${project.build.directory}/classes/ca/uhn/hapi/fhir/jpa/docs/database</outputDirectory>
|
<outputDirectory>${project.build.directory}/classes/ca/uhn/hapi/fhir/jpa/docs/database</outputDirectory>
|
||||||
|
|
|
@ -112,15 +112,7 @@ public class DdlGeneratorHibernate61 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNotBlank(nextDialect.getPrependFile())) {
|
writeContentsToFile(nextDialect.getPrependFile(), classLoader, outputFile);
|
||||||
ResourceLoader loader = new DefaultResourceLoader(classLoader);
|
|
||||||
Resource resource = loader.getResource(nextDialect.getPrependFile());
|
|
||||||
try (Writer w = new FileWriter(outputFile, false)) {
|
|
||||||
w.append(resource.getContentAsString(StandardCharsets.UTF_8));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new MojoFailureException("Failed to write to file " + outputFile + ": " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String outputFileName = outputFile.getAbsolutePath();
|
String outputFileName = outputFile.getAbsolutePath();
|
||||||
ourLog.info("Writing to file: {}", outputFileName);
|
ourLog.info("Writing to file: {}", outputFileName);
|
||||||
|
@ -130,6 +122,21 @@ public class DdlGeneratorHibernate61 {
|
||||||
schemaExport.setDelimiter(";");
|
schemaExport.setDelimiter(";");
|
||||||
schemaExport.setOutputFile(outputFileName);
|
schemaExport.setOutputFile(outputFileName);
|
||||||
schemaExport.execute(targetTypes, action, metadata, standardRegistry);
|
schemaExport.execute(targetTypes, action, metadata, standardRegistry);
|
||||||
|
|
||||||
|
writeContentsToFile(nextDialect.getAppendFile(), classLoader, outputFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void writeContentsToFile(String prependFile, ClassLoader classLoader, File outputFile)
|
||||||
|
throws MojoFailureException {
|
||||||
|
if (isNotBlank(prependFile)) {
|
||||||
|
ResourceLoader loader = new DefaultResourceLoader(classLoader);
|
||||||
|
Resource resource = loader.getResource(prependFile);
|
||||||
|
try (Writer w = new FileWriter(outputFile, true)) {
|
||||||
|
w.append(resource.getContentAsString(StandardCharsets.UTF_8));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new MojoFailureException("Failed to write to file " + outputFile + ": " + e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,11 +68,29 @@ public class GenerateDdlMojo extends AbstractMojo {
|
||||||
generator.generateDdl();
|
generator.generateDdl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws MojoExecutionException, MojoFailureException {
|
||||||
|
/*
|
||||||
|
* Note, to execute this, add the following snippet to this module's POM. The whole project won't work with
|
||||||
|
* that added, but you can add it temporarily in order to debug this in IJ:
|
||||||
|
* <dependency>
|
||||||
|
* <groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
|
* <artifactId>hapi-fhir-jpaserver-model</artifactId>
|
||||||
|
* <version>${project.version}</version>
|
||||||
|
* </dependency>
|
||||||
|
*/
|
||||||
|
GenerateDdlMojo m = new GenerateDdlMojo();
|
||||||
|
m.packageNames = List.of("ca.uhn.fhir.jpa.model.entity");
|
||||||
|
m.outputDirectory = "hapi-tinder-plugin/target";
|
||||||
|
m.dialects = List.of(new Dialect("ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect", "h2.sql"));
|
||||||
|
m.execute();
|
||||||
|
}
|
||||||
|
|
||||||
public static class Dialect {
|
public static class Dialect {
|
||||||
|
|
||||||
private String className;
|
private String className;
|
||||||
private String targetFileName;
|
private String targetFileName;
|
||||||
private String prependFile;
|
private String prependFile;
|
||||||
|
private String appendFile;
|
||||||
|
|
||||||
public Dialect() {
|
public Dialect() {
|
||||||
super();
|
super();
|
||||||
|
@ -84,6 +102,14 @@ public class GenerateDdlMojo extends AbstractMojo {
|
||||||
setTargetFileName(theTargetFileName);
|
setTargetFileName(theTargetFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAppendFile() {
|
||||||
|
return appendFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppendFile(String theAppendFile) {
|
||||||
|
appendFile = theAppendFile;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClassName() {
|
public String getClassName() {
|
||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
@ -108,21 +134,4 @@ public class GenerateDdlMojo extends AbstractMojo {
|
||||||
prependFile = thePrependFile;
|
prependFile = thePrependFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws MojoExecutionException, MojoFailureException {
|
|
||||||
/*
|
|
||||||
* Note, to execute this, add the following snippet to this module's POM. The whole project won't work with
|
|
||||||
* that added, but you can add it temporarily in order to debug this in IJ:
|
|
||||||
* <dependency>
|
|
||||||
* <groupId>ca.uhn.hapi.fhir</groupId>
|
|
||||||
* <artifactId>hapi-fhir-jpaserver-model</artifactId>
|
|
||||||
* <version>${project.version}</version>
|
|
||||||
* </dependency>
|
|
||||||
*/
|
|
||||||
GenerateDdlMojo m = new GenerateDdlMojo();
|
|
||||||
m.packageNames = List.of("ca.uhn.fhir.jpa.model.entity");
|
|
||||||
m.outputDirectory = "hapi-tinder-plugin/target";
|
|
||||||
m.dialects = List.of(new Dialect("ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect", "h2.sql"));
|
|
||||||
m.execute();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -963,7 +963,7 @@
|
||||||
<reflections_version>0.9.11</reflections_version>
|
<reflections_version>0.9.11</reflections_version>
|
||||||
<servicemix_saxon_version>9.8.0-15</servicemix_saxon_version>
|
<servicemix_saxon_version>9.8.0-15</servicemix_saxon_version>
|
||||||
<servicemix_xmlresolver_version>1.2_5</servicemix_xmlresolver_version>
|
<servicemix_xmlresolver_version>1.2_5</servicemix_xmlresolver_version>
|
||||||
<swagger_version>2.1.12</swagger_version>
|
<swagger_version>2.2.19</swagger_version>
|
||||||
<slf4j_version>2.0.3</slf4j_version>
|
<slf4j_version>2.0.3</slf4j_version>
|
||||||
<log4j_to_slf4j_version>2.19.0</log4j_to_slf4j_version>
|
<log4j_to_slf4j_version>2.19.0</log4j_to_slf4j_version>
|
||||||
<spring_version>6.0.12</spring_version>
|
<spring_version>6.0.12</spring_version>
|
||||||
|
|
Loading…
Reference in New Issue