From c005b96214027bf20df30afbef3dbc5d08433fd1 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 --- .../java/org/hibernate/mvn/AbstractHbm2xMojo.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/maven-plugin/src/main/java/org/hibernate/mvn/AbstractHbm2xMojo.java b/maven-plugin/src/main/java/org/hibernate/mvn/AbstractHbm2xMojo.java index a1dd133fc4..f38aced244 100644 --- a/maven-plugin/src/main/java/org/hibernate/mvn/AbstractHbm2xMojo.java +++ b/maven-plugin/src/main/java/org/hibernate/mvn/AbstractHbm2xMojo.java @@ -12,9 +12,9 @@ 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.cfg.reveng.OverrideRepository; import org.hibernate.cfg.reveng.ReverseEngineeringSettings; import org.hibernate.cfg.reveng.ReverseEngineeringStrategy; @@ -72,7 +72,7 @@ public abstract class AbstractHbm2xMojo 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)); @@ -89,12 +89,12 @@ public void execute() { } } - private ReverseEngineeringStrategy setupReverseEngineeringStrategy() { + private ReverseEngineeringStrategy setupReverseEngineeringStrategy() throws MojoFailureException { ReverseEngineeringStrategy strategy; try { strategy = ReverseEngineeringStrategy.class.cast(Class.forName(revengStrategy).newInstance()); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | ClassCastException e) { - throw new BuildException(revengStrategy + " not instanced.", e); + throw new MojoFailureException(revengStrategy + " not instanced.", e); } if (revengFile != null) { @@ -116,15 +116,15 @@ private ReverseEngineeringStrategy 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); } }