{"record":{"id":"e48afed464af04af","repo":"quarkusio/quarkus","slug":"failed-to-locate-task-jar-in-the-project","errorCode":null,"errorMessage":"Failed to locate task 'jar' in the project.","messagePattern":"Failed to locate task 'jar' in the project\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java","lineNumber":225,"sourceCode":"                result = f;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * Convenience method to get the source sets associated with the current project.\n     *\n     * @return the source sets associated with the current project.\n     */\n    private SourceSetContainer getSourceSets() {\n        return project.getExtensions().getByType(SourceSetContainer.class);\n    }\n\n    public Path appJarOrClasses() {\n        final Jar jarTask = (Jar) project.getTasks().findByName(JavaPlugin.JAR_TASK_NAME);\n        if (jarTask == null) {\n            throw new RuntimeException(\"Failed to locate task 'jar' in the project.\");\n        }\n        final Provider<RegularFile> jarProvider = jarTask.getArchiveFile();\n        Path classesDir = null;\n        if (jarProvider.isPresent()) {\n            final File f = jarProvider.get().getAsFile();\n            if (f.exists()) {\n                classesDir = f.toPath();\n            }\n        }\n        if (classesDir == null) {\n            final SourceSet mainSourceSet = getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);\n            final String classesPath = QuarkusGradleUtils.getClassesDir(mainSourceSet, jarTask.getTemporaryDir(), false);\n            if (classesPath != null) {\n                classesDir = Paths.get(classesPath);\n            }\n        }\n        if (classesDir == null) {\n            throw new RuntimeException(\"Failed to locate project's classes directory\");","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java#L207-L243","documentation":"Thrown by QuarkusPluginExtension.appJarOrClasses() when the Gradle project does not contain a task named 'jar' (JavaPlugin.JAR_TASK_NAME). Quarkus needs the jar task's archive output (or fallback classes dir) to determine application artifacts. It indicates the Java plugin is not applied or the jar task was removed/renamed.","triggerScenarios":"Calling appJarOrClasses() (directly or via tasks like quarkusDev/quarkusBuild that rely on it) in a project where the java plugin isn't applied, the jar task was disabled/removed (e.g. tasks.named('jar'){enabled=false} or project.tasks.remove), or queried too early before task realization.","commonSituations":"Applying the quarkus plugin without the java plugin in a build.gradle.kts; custom builds that disable the jar task for spring-boot-style executable-jar repackaging; using quarkus plugin in a non-Java (e.g. Kotlin-only or platform/BOM) project.","solutions":["Apply the Java plugin (or one that applies it, e.g. 'java' or application) before/alongside the quarkus plugin","Do not disable or remove the jar task; if you customize it, keep it enabled","Ensure appJarOrClasses()/Quarkus tasks run after task configuration (not in a settings/context where tasks aren't yet registered)"],"exampleFix":"// before (build.gradle.kts)\nplugins { id(\"io.quarkus\") }\n// after\nplugins { id(\"java\"); id(\"io.quarkus\") }","handlingStrategy":"validation","validationCode":"def hasJarTask(project: Project): Boolean =\n  project.pluginManager.hasPlugin(\"java\") && project.tasks.names.contains(\"jar\")\n// only rely on quarkus tasks when hasJarTask(project) is true","typeGuard":"def isJarTask(t: Task?): Jar? = (t as? Jar)","tryCatchPattern":"try { ext.appJarOrClasses() } catch (e: RuntimeException) {\n  if (e.message?.contains(\"Failed to locate task 'jar'\") == true) {\n    logger.warn(\"Java plugin missing; applying it\"); project.pluginManager.apply(\"java\")\n  } else throw e\n}","preventionTips":["Always apply the java (or application) plugin with the quarkus plugin","Never disable or remove the standard jar task","Keep quarkus task configuration in afterEvaluate/after plugin application"],"tags":["gradle","build-configuration","jar-task"],"backgroundTag":"missing-gradle-task","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"}