quarkusio/quarkus · error · GradleException

Failed to archive classes at %s into %s

Error message

Failed to archive classes at %s into %s

What it means

When a dependency resolved by jarDependencies is a directory of classes rather than a jar (e.g. a Quarkus project dependency discovered on the local file system when localProjectDiscovery=true), the plugin zips it into a jar with ZipUtils.zip. An IOException during zipping fails the build with this GradleException naming the source path and target jar.

Source

Thrown at devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java:204

                        || parentFirstArtifacts.contains(dep.getKey()) ? libBoot : libMain, dep))
                .peek(depAndTarget -> {
                    ResolvedDependency dep = depAndTarget.getValue();
                    Path targetDir = depAndTarget.getKey();
                    dep.getResolvedPaths().forEach(p -> {
                        String file = FastJarFormat.getJarFileName(dep, p);
                        Path target = targetDir.resolve(file);
                        if (!Files.exists(target)) {
                            getLogger().debug("Dependency {} : copying {} to {}",
                                    dep.toGACTVString(),
                                    p, target);
                            if (Files.isDirectory(p)) {
                                // This case can happen when we are building a jar from inside the Quarkus repository
                                // and Quarkus Bootstrap's localProjectDiscovery has been set to true. In such a case
                                // the non-jar dependencies are the Quarkus dependencies picked up on the file system
                                try {
                                    ZipUtils.zip(p, target);
                                } catch (IOException e) {
                                    throw new GradleException(
                                            String.format("Failed to archive classes at %s into %s", p, target), e);
                                }
                            } else {
                                try {
                                    Files.copy(p, target, StandardCopyOption.COPY_ATTRIBUTES);
                                } catch (IOException e) {
                                    throw new GradleException(String.format("Failed to copy %s to %s", p, target), e);
                                }
                            }
                        }
                    });
                })
                .collect(Collectors.toMap(Map.Entry::getKey, depAndTarget -> 1, Integer::sum))
                .forEach((path, count) -> getLogger().info("Copied {} files into {}", count, path));
    }

    private static Set<ArtifactKey> dependenciesListToArtifactKeySet(String optionalDependenciesProp) {
        return Arrays.stream(optionalDependenciesProp.split(","))

View on GitHub (pinned to e1c734241f)

Solutions

  1. If building inside a multi-module/reactor project, disable localProjectDiscovery (e.g. quarkus.bootstrap.local-project-discovery=false / remove -Dquarkus.bootstrap.local-project-discovery=true) so dependencies come from the repository
  2. Re-run the compile/classes task first (./gradlew classes) so the classes directory is complete, then rebuild
  3. Check write permissions and space in the dependency target directory
  4. Clean the output: ./gradlew clean quarkusBuild

Example fix

// before
./gradlew quarkusBuild -Dquarkus.bootstrap.local-project-discovery=true
// after
./gradlew classes quarkusBuild # or drop the localProjectDiscovery flag
Defensive patterns

Strategy: retry

Validate before calling

// ensure classes are fully compiled before packaging deps
File classes = new File("build/classes/java/main");
if (classes.exists() && classes.list().length == 0) {
    throw new IllegalStateException("Run ./gradlew classes first");
}

Try / catch

try {
    ./gradlew classes quarkusBuild
} catch (GradleException e) {
    if (e.message?.startsWith("Failed to archive classes")) {
        retryBuildAfterClean(); // one clean+rebuild attempt
    } else { throw e; }
}

Prevention

When it happens

Trigger: ZipUtils.zip(p, target) throws IOException while archiving a non-jar (class-directory) dependency — unreadable class files under the project's classes output, or the target jar cannot be written in the dependency dir.

Common situations: Building from inside the Quarkus repository with localProjectDiscovery enabled; an IDE build holding/locking the classes directory; partially-compiled or deleted classes output while the build runs.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/aa375a810c192dcc. Report an issue: GitHub.