{"record":{"id":"aa375a810c192dcc","repo":"quarkusio/quarkus","slug":"failed-to-archive-classes-at-s-into-s","errorCode":null,"errorMessage":"Failed to archive classes at %s into %s","messagePattern":"Failed to archive classes at (.+?) into (.+?)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java","lineNumber":204,"sourceCode":"                        || parentFirstArtifacts.contains(dep.getKey()) ? libBoot : libMain, dep))\n                .peek(depAndTarget -> {\n                    ResolvedDependency dep = depAndTarget.getValue();\n                    Path targetDir = depAndTarget.getKey();\n                    dep.getResolvedPaths().forEach(p -> {\n                        String file = FastJarFormat.getJarFileName(dep, p);\n                        Path target = targetDir.resolve(file);\n                        if (!Files.exists(target)) {\n                            getLogger().debug(\"Dependency {} : copying {} to {}\",\n                                    dep.toGACTVString(),\n                                    p, target);\n                            if (Files.isDirectory(p)) {\n                                // This case can happen when we are building a jar from inside the Quarkus repository\n                                // and Quarkus Bootstrap's localProjectDiscovery has been set to true. In such a case\n                                // the non-jar dependencies are the Quarkus dependencies picked up on the file system\n                                try {\n                                    ZipUtils.zip(p, target);\n                                } catch (IOException e) {\n                                    throw new GradleException(\n                                            String.format(\"Failed to archive classes at %s into %s\", p, target), e);\n                                }\n                            } else {\n                                try {\n                                    Files.copy(p, target, StandardCopyOption.COPY_ATTRIBUTES);\n                                } catch (IOException e) {\n                                    throw new GradleException(String.format(\"Failed to copy %s to %s\", p, target), e);\n                                }\n                            }\n                        }\n                    });\n                })\n                .collect(Collectors.toMap(Map.Entry::getKey, depAndTarget -> 1, Integer::sum))\n                .forEach((path, count) -> getLogger().info(\"Copied {} files into {}\", count, path));\n    }\n\n    private static Set<ArtifactKey> dependenciesListToArtifactKeySet(String optionalDependenciesProp) {\n        return Arrays.stream(optionalDependenciesProp.split(\",\"))","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java#L186-L222","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","Re-run the compile/classes task first (./gradlew classes) so the classes directory is complete, then rebuild","Check write permissions and space in the dependency target directory","Clean the output: ./gradlew clean quarkusBuild"],"exampleFix":"// before\n./gradlew quarkusBuild -Dquarkus.bootstrap.local-project-discovery=true\n// after\n./gradlew classes quarkusBuild # or drop the localProjectDiscovery flag","handlingStrategy":"retry","validationCode":"// ensure classes are fully compiled before packaging deps\nFile classes = new File(\"build/classes/java/main\");\nif (classes.exists() && classes.list().length == 0) {\n    throw new IllegalStateException(\"Run ./gradlew classes first\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ./gradlew classes quarkusBuild\n} catch (GradleException e) {\n    if (e.message?.startsWith(\"Failed to archive classes\")) {\n        retryBuildAfterClean(); // one clean+rebuild attempt\n    } else { throw e; }\n}","preventionTips":["Disable localProjectDiscovery outside the Quarkus repo itself","Run compile tasks before quarkusBuild in custom pipelines","Avoid concurrent IDE and CLI builds of the same project","Clean build/classes after killed builds"],"tags":["gradle","zip","local-project-discovery","dependency-packaging"],"backgroundTag":"dependency-archive-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}