Skip to content

Commit d6d74c8

Browse files
committed
HBX-3169: Update the use of H2 in the Maven integration tests to 2.4.240
- Properly fail with a MojoFailureException when the properties file is not found - Handle the noProperties case Signed-off-by: Koen Aers <[email protected]>
1 parent f989a6b commit d6d74c8

File tree

4 files changed

+26
-34
lines changed

4 files changed

+26
-34
lines changed

maven/src/main/java/org/hibernate/tool/maven/AbstractGenerationMojo.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ public void execute() throws MojoFailureException {
9696
Thread.currentThread().setContextClassLoader(createExporterClassLoader(original));
9797
getLog().info("Starting " + this.getClass().getSimpleName() + "...");
9898
RevengStrategy strategy = setupReverseEngineeringStrategy();
99-
if (propertyFile.exists()) {
100-
executeExporter(createJdbcDescriptor(strategy, loadPropertiesFile()));
101-
} else {
102-
getLog().info("Property file '" + propertyFile + "' cannot be found, aborting...");
103-
}
99+
executeExporter(createJdbcDescriptor(strategy, loadPropertiesFile()));
104100
getLog().info("Finished " + this.getClass().getSimpleName() + "!");
105101
} finally {
106102
Thread.currentThread().setContextClassLoader(original);
@@ -134,8 +130,10 @@ private Properties loadPropertiesFile() throws MojoFailureException {
134130
result.load(is);
135131
return result;
136132
} catch (FileNotFoundException e) {
133+
getLog().error("Property file '" + propertyFile + "' cannot be found, aborting...");
137134
throw new MojoFailureException(propertyFile + " not found.", e);
138135
} catch (IOException e) {
136+
getLog().error("Property file '" + propertyFile + "' cannot be loaded, aborting...");
139137
throw new MojoFailureException("Problem while loading " + propertyFile, e);
140138
}
141139
}

test/maven/src/it/noPropertiesFile/invoker.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
# limitations under the License. #
1717
############################################################################
1818
invoker.java.version = 1.8+
19-
invoker.goals = generate-sources
19+
invoker.goals = generate-sources
20+
invoker.buildResult = failure

test/maven/src/it/noPropertiesFile/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@
2323
<artifactId>no-properties-file</artifactId>
2424
<version>0.0.1-SNAPSHOT</version>
2525

26-
<properties>
27-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
28-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
29-
30-
<java.version>1.8</java.version>
31-
<h2.version>1.4.195</h2.version>
32-
</properties>
33-
3426
<build>
3527
<plugins>
3628
<plugin>

test/maven/src/it/noPropertiesFile/verify.groovy renamed to test/maven/src/it/noPropertiesFile/postbuild.bsh

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,32 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
import java.io.*;
18+
import java.util.Scanner;
1919

20-
println "start verify.groovy"
20+
File buildLog = new File(basedir, "build.log");
2121

22-
File buildLog = new File(basedir, "build.log")
22+
if (!buildLog.exists()) {
23+
24+
System.out.println( "'" + buildLog.absolutePath + "' is not found.");
25+
26+
throw new FileNotFoundException("Could not find build log file: '" + buildLog + "'");
2327

24-
if (!buildLog.isFile()) {
25-
26-
println "'" + buildLog.absolutePath + "' is not a file."
27-
28-
throw new FileNotFoundException("Could not find build log file: '" + buildLog + "'")
29-
3028
} else {
3129

32-
println "inspecting build log lines"
33-
34-
boolean found = false
35-
String startString = "[INFO] Property file '"
36-
String endString = "src/main/resources/hibernate.properties' cannot be found, aborting..."
37-
buildLog.eachLine {
38-
line -> if (line.startsWith(startString) && line.endsWith(endString)) found = true
30+
System.out.println( "Inspecting build log lines");
31+
32+
String startString = "[ERROR] Property file '";
33+
String endString = "src/main/resources/hibernate.properties' cannot be found, aborting...";
34+
35+
Scanner s = new Scanner(buildLog);
36+
while (s.hasNextLine()) {
37+
String line = s.nextLine();
38+
if (line.startsWith(startString) && line.endsWith(endString)) {
39+
return true;
40+
}
3941
}
40-
return found
41-
42-
}
4342

43+
return false;
44+
45+
}
4446

45-
println "end verify.groovy"

0 commit comments

Comments
 (0)