quarkusio/quarkus · error · GradleException
Failed to clean up non-modified jars in lib/
Error message
Failed to clean up non-modified jars in lib/
What it means
During assembleLegacyJar, the Quarkus Gradle plugin deletes stale, non-modified jars from the lib/ directory of a previous legacy-jar build. If any file-system traversal or delete fails with IOException, the whole assemble step aborts with a GradleException. The original cause is not chained in this case, so the message alone must be investigated.
Source
Thrown at devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java:277
copy.include("lib/**");
}));
// Quarkus' 'legacy-jar' package type produces 'lib/modified-*.jar' files for some dependencies.
// The following code block removes the non-modified jars.
getLogger().info("Cleaning up lib/ directory in {}", buildDir);
try (Stream<Path> files = Files.walk(libDir)) {
files.filter(Files::isRegularFile).filter(f -> f.getFileName().toString().startsWith("modified-"))
.map(f -> f.getParent().resolve(f.getFileName().toString().substring("modified-".length())))
.toList() // necessary :(
.forEach(f -> {
try {
Files.deleteIfExists(f);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
} catch (IOException e) {
throw new GradleException("Failed to clean up non-modified jars in lib/");
}
copyRunnersAndArtifactProperties(appBuildDir);
}
private void assembleFullBuild() {
File targetDir = buildDir;
// build/quarkus-build/gen
Path genBuildDir = genBuildDir();
if (nativeEnabled()) {
if (nativeSourcesOnly()) {
getLogger().info("Copying Quarkus build for native sources from {} into {}", genBuildDir, targetDir);
} else {
getLogger().info("Copying Quarkus native build from {} into {}", genBuildDir, targetDir);
}View on GitHub (pinned to e1c734241f)
Solutions
- Stop any running Quarkus dev-mode or java -jar process that locks jars in build/ (or the app build dir) and rebuild
- Check permissions on the build output lib/ directory and delete it manually: rm -rf build/quarkus-app (or the configured build directory)
- On Windows, close file explorers/antivirus scanning the lib dir, or restart to release locks
- Run ./gradlew clean then re-run the build
Example fix
// shell-side fix ./gradlew stop # if using quarkusDev in another terminal rm -rf build/quarkus-app ./gradlew quarkusBuild
Defensive patterns
Strategy: validation
Validate before calling
// before quarkusBuild, ensure nothing holds build/ open and the dir is writable
assert new File("build/quarkus-app").canWrite() || !new File("build/quarkus-app").exists(); Try / catch
try {
./gradlew quarkusBuild
} catch (GradleException e) {
if (e.message?.startsWith("Failed to clean up non-modified jars")) {
"./gradlew clean".execute().waitFor(); retryBuild();
} else { throw e; }
} Prevention
- Always stop quarkusDev / running app JVMs before rebuilding
- Run ./gradlew clean after abnormal interruptions
- On Windows, exclude build/ from antivirus/indexers
- Avoid running builds with sudo into a user-owned workspace
When it happens
Trigger: IOException while walking/deleting files under the app build directory's lib/ (e.g. file locked by a running application, permission denied, directory deleted concurrently) in QuarkusBuild.assembleLegacyJar, called from finalizeQuarkusBuild.
Common situations: A previously started quarkusDev/quarkusRun JVM or an IDE still holds jar handles (Windows especially); build directory owned by another user after running with sudo; read-only CI workspace.
Related errors
- Failed to resolve ${appArtifact}
- Requested artifact ${appArtifact} does not match project ${g
- No platforms detected in the project
- Failed to determine the Quarkus core version for the project
- Failed to configure ${taskPath}: sourceSet ${sourceSet} has
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/34de57a3a77f78ae.
Report an issue: GitHub.