From aa7012d7e677cb360ad1dea220f1f16f7a0e499a Mon Sep 17 00:00:00 2001 From: Martin Panzer Date: Mon, 28 Feb 2022 20:46:16 +0100 Subject: [PATCH] close created CuratedApplication This will close all opened zip file systems of dependencies. These files where still locked during mojo execution by m2e, since the mojo is never destroyed. --- .../io/quarkus/maven/GenerateCodeMojo.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/devtools/maven/src/main/java/io/quarkus/maven/GenerateCodeMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/GenerateCodeMojo.java index a8d764f453a55..2b434e3049588 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/GenerateCodeMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/GenerateCodeMojo.java @@ -67,21 +67,22 @@ void generateCode(Path sourcesDir, ClassLoader originalTccl = Thread.currentThread().getContextClassLoader(); try { - final CuratedApplication curatedApplication = bootstrapApplication(launchMode); + try (final CuratedApplication curatedApplication = bootstrapApplication(launchMode)) { - QuarkusClassLoader deploymentClassLoader = curatedApplication.createDeploymentClassLoader(); - Thread.currentThread().setContextClassLoader(deploymentClassLoader); + QuarkusClassLoader deploymentClassLoader = curatedApplication.createDeploymentClassLoader(); + Thread.currentThread().setContextClassLoader(deploymentClassLoader); - final Class codeGenerator = deploymentClassLoader.loadClass("io.quarkus.deployment.CodeGenerator"); - final Method initAndRun = codeGenerator.getMethod("initAndRun", ClassLoader.class, PathCollection.class, - Path.class, Path.class, - Consumer.class, ApplicationModel.class, Properties.class, String.class, - boolean.class); - initAndRun.invoke(null, deploymentClassLoader, PathList.of(sourcesDir), - generatedSourcesDir(test), buildDir().toPath(), - sourceRegistrar, curatedApplication.getApplicationModel(), mavenProject().getProperties(), - launchMode.name(), - test); + final Class codeGenerator = deploymentClassLoader.loadClass("io.quarkus.deployment.CodeGenerator"); + final Method initAndRun = codeGenerator.getMethod("initAndRun", ClassLoader.class, PathCollection.class, + Path.class, Path.class, + Consumer.class, ApplicationModel.class, Properties.class, String.class, + boolean.class); + initAndRun.invoke(null, deploymentClassLoader, PathList.of(sourcesDir), + generatedSourcesDir(test), buildDir().toPath(), + sourceRegistrar, curatedApplication.getApplicationModel(), mavenProject().getProperties(), + launchMode.name(), + test); + } } catch (Exception any) { throw new MojoExecutionException("Quarkus code generation phase has failed", any); } finally {