{"record":{"id":"28e34de0acdfbbb7","repo":"GoogleContainerTools/jib","slug":"no-classes-files-were-found-did-you-compile-your","errorCode":null,"errorMessage":"No classes files were found - did you compile your project?","messagePattern":"No classes files were found - did you compile your project\\?","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java","lineNumber":266,"sourceCode":"                  .collect(Collectors.toList()))\n          .addProjectDependencies(\n              projectDependencies.getFiles().stream()\n                  .map(File::toPath)\n                  .collect(Collectors.toList()));\n\n      switch (containerizingMode) {\n        case EXPLODED:\n          // Adds resource files\n          if (Files.exists(resourcesOutputDirectory)) {\n            javaContainerBuilder.addResources(resourcesOutputDirectory);\n          }\n\n          // Adds class files\n          for (File classesOutputDirectory : classesOutputDirectories) {\n            javaContainerBuilder.addClasses(classesOutputDirectory.toPath());\n          }\n          if (classesOutputDirectories.isEmpty()) {\n            log(LogEvent.warn(\"No classes files were found - did you compile your project?\"));\n          }\n          break;\n\n        case PACKAGED:\n          // Add a JAR\n          Jar jarTask = (Jar) project.getTasks().findByName(\"jar\");\n          Path jarPath = jarTask.getArchiveFile().get().getAsFile().toPath();\n          log(LogEvent.debug(\"Using JAR: \" + jarPath));\n          javaContainerBuilder.addToClasspath(jarPath);\n          break;\n\n        default:\n          throw new IllegalStateException(\"unknown containerizing mode: \" + containerizingMode);\n      }\n\n      return javaContainerBuilder.toContainerBuilder();\n\n    } catch (IOException ex) {","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java#L248-L284","documentation":"GradleProjectProperties logs this warning when the Gradle plugin builds a container in 'explode' (classes) mode and none of the project's classes output directories exist or contain anything, so the image would have an empty classes layer. It is almost always a sign that the project was not compiled before running Jib.","triggerScenarios":"createJibContainerBuilder on a Gradle project where javaContainerBuilderToContainerBuilder walks classesOutputDirectories and the list is empty — i.e. the classes task produced no output directories (e.g. jib task run before compileJava, or an empty/no-source project).","commonSituations":"Running jibBuildImage with --offline or in CI before running the compile step; a project with no Java/Kotlin sources; misconfigured sourceSets so classes land elsewhere; Gradle build cache/task wiring issues leaving build/classes empty.","solutions":["Run the compile step first (gradle jib depends on classes normally; if invoking tasks directly, run gradle classes jib:build or just gradle jib)","Verify the project actually has sources under src/main/java; an empty project legitimately produces this warning","Check custom sourceSets/output configuration so classesOutputDirectories points at real directories (e.g. build/classes/java/main)","If packaging a fat JAR instead, switch the packaging mode to PACKAGED"],"exampleFix":"// before\n./gradlew jib   # may skip compile in odd setups\n// after: ensure classes are built\n./gradlew classes jib","handlingStrategy":"validation","validationCode":"// fail the pipeline if classes output is empty before jib\nif [ -z \"$(find build/classes -name '*.class' 2>/dev/null)\" ]; then\n  echo \"No compiled classes — run gradle classes first\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":"tasks.named(\"jib\") {\n  // jib already depends on classes; if invoking programmatically:\n  dependsOn(\"classes\")\n}","preventionTips":["Always invoke jib tasks through Gradle so the classes dependency runs","Verify the project has sources and sourceSets are not customized away","Check build/classes/java/main exists in CI logs before pushing images"],"tags":["gradle","jib","build","empty-input"],"backgroundTag":"empty-result-set","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}