GoogleContainerTools/jib · warning
No classes files were found - did you compile your project?
Error message
No classes files were found - did you compile your project?
What it means
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.
Source
Thrown at jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java:266
.collect(Collectors.toList()))
.addProjectDependencies(
projectDependencies.getFiles().stream()
.map(File::toPath)
.collect(Collectors.toList()));
switch (containerizingMode) {
case EXPLODED:
// Adds resource files
if (Files.exists(resourcesOutputDirectory)) {
javaContainerBuilder.addResources(resourcesOutputDirectory);
}
// Adds class files
for (File classesOutputDirectory : classesOutputDirectories) {
javaContainerBuilder.addClasses(classesOutputDirectory.toPath());
}
if (classesOutputDirectories.isEmpty()) {
log(LogEvent.warn("No classes files were found - did you compile your project?"));
}
break;
case PACKAGED:
// Add a JAR
Jar jarTask = (Jar) project.getTasks().findByName("jar");
Path jarPath = jarTask.getArchiveFile().get().getAsFile().toPath();
log(LogEvent.debug("Using JAR: " + jarPath));
javaContainerBuilder.addToClasspath(jarPath);
break;
default:
throw new IllegalStateException("unknown containerizing mode: " + containerizingMode);
}
return javaContainerBuilder.toContainerBuilder();
} catch (IOException ex) {View on GitHub (pinned to fb949e2676)
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
Example fix
// before ./gradlew jib # may skip compile in odd setups // after: ensure classes are built ./gradlew classes jib
Defensive patterns
Strategy: validation
Validate before calling
// fail the pipeline if classes output is empty before jib if [ -z "$(find build/classes -name '*.class' 2>/dev/null)" ]; then echo "No compiled classes — run gradle classes first"; exit 1 fi
Try / catch
tasks.named("jib") {
// jib already depends on classes; if invoking programmatically:
dependsOn("classes")
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- container.appRoot is not an absolute Unix-style path: ${inva
- invalid value for containerizingMode: ${invalidContainerizin
- container.workingDirectory is not an absolute Unix-style pat
- from.platforms contains a platform configuration that is mis
- container.volumes is not an absolute Unix-style path: ${inva
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/28e34de0acdfbbb7.
Report an issue: GitHub.