From a34f4dd9694c14a9757b55701b1f5ca56a5d2d82 Mon Sep 17 00:00:00 2001 From: Koen Aers Date: Tue, 7 Oct 2025 14:52:56 +0200 Subject: [PATCH] HBX-3146: Remove the use of Ant BuildException from the Maven mojos Signed-off-by: Koen Aers --- .../hibernate/tool/maven/AbstractGenerationMojo.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/maven/src/main/java/org/hibernate/tool/maven/AbstractGenerationMojo.java b/maven/src/main/java/org/hibernate/tool/maven/AbstractGenerationMojo.java index ea76fa0f74..d39ccbcd47 100644 --- a/maven/src/main/java/org/hibernate/tool/maven/AbstractGenerationMojo.java +++ b/maven/src/main/java/org/hibernate/tool/maven/AbstractGenerationMojo.java @@ -27,15 +27,13 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; import java.util.Properties; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.tools.ant.BuildException; import org.hibernate.tool.api.metadata.MetadataDescriptor; import org.hibernate.tool.api.metadata.MetadataDescriptorFactory; import org.hibernate.tool.api.metadata.MetadataConstants; @@ -94,7 +92,7 @@ public abstract class AbstractGenerationMojo extends AbstractMojo { @Parameter(defaultValue = "${project}", readonly = true, required = true) private MavenProject project; - public void execute() { + public void execute() throws MojoFailureException { ClassLoader original = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(createExporterClassLoader(original)); @@ -132,15 +130,15 @@ private RevengStrategy setupReverseEngineeringStrategy() { return strategy; } - private Properties loadPropertiesFile() { + private Properties loadPropertiesFile() throws MojoFailureException { try (FileInputStream is = new FileInputStream(propertyFile)) { Properties result = new Properties(); result.load(is); return result; } catch (FileNotFoundException e) { - throw new BuildException(propertyFile + " not found.", e); + throw new MojoFailureException(propertyFile + " not found.", e); } catch (IOException e) { - throw new BuildException("Problem while loading " + propertyFile, e); + throw new MojoFailureException("Problem while loading " + propertyFile, e); } }