quarkusio/quarkus · error · RuntimeException
Failed to locate task 'jar' in the project.
Error message
Failed to locate task 'jar' in the project.
What it means
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.
Source
Thrown at devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java:225
result = f;
}
}
return result;
}
/**
* Convenience method to get the source sets associated with the current project.
*
* @return the source sets associated with the current project.
*/
private SourceSetContainer getSourceSets() {
return project.getExtensions().getByType(SourceSetContainer.class);
}
public Path appJarOrClasses() {
final Jar jarTask = (Jar) project.getTasks().findByName(JavaPlugin.JAR_TASK_NAME);
if (jarTask == null) {
throw new RuntimeException("Failed to locate task 'jar' in the project.");
}
final Provider<RegularFile> jarProvider = jarTask.getArchiveFile();
Path classesDir = null;
if (jarProvider.isPresent()) {
final File f = jarProvider.get().getAsFile();
if (f.exists()) {
classesDir = f.toPath();
}
}
if (classesDir == null) {
final SourceSet mainSourceSet = getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
final String classesPath = QuarkusGradleUtils.getClassesDir(mainSourceSet, jarTask.getTemporaryDir(), false);
if (classesPath != null) {
classesDir = Paths.get(classesPath);
}
}
if (classesDir == null) {
throw new RuntimeException("Failed to locate project's classes directory");View on GitHub (pinned to e1c734241f)
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)
Example fix
// before (build.gradle.kts)
plugins { id("io.quarkus") }
// after
plugins { id("java"); id("io.quarkus") } Defensive patterns
Strategy: validation
Validate before calling
def hasJarTask(project: Project): Boolean =
project.pluginManager.hasPlugin("java") && project.tasks.names.contains("jar")
// only rely on quarkus tasks when hasJarTask(project) is true Type guard
def isJarTask(t: Task?): Jar? = (t as? Jar)
Try / catch
try { ext.appJarOrClasses() } catch (e: RuntimeException) {
if (e.message?.contains("Failed to locate task 'jar'") == true) {
logger.warn("Java plugin missing; applying it"); project.pluginManager.apply("java")
} else throw e
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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/e48afed464af04af.
Report an issue: GitHub.