GoogleContainerTools/jib · error · RuntimeException
Failed to resolve dependent project from ${projectDependency
Error message
Failed to resolve dependent project from ${projectDependency} What it means
FilesTaskV2.getDependentProject resolves a ProjectDependency to its Project. It first tries reflection on getDependencyProject() (Gradle <9); if any ReflectiveOperationException other than NoSuchMethodException occurs there (e.g. IllegalAccessException, InvocationTargetException), it throws this RuntimeException. The reflection-based lookup is a compatibility shim across Gradle API changes.
Source
Thrown at jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/skaffold/FilesTaskV2.java:265
/**
* Resolves a {@link ProjectDependency} to its corresponding {@link Project} instance.
*
* <p>Uses reflection to handle both Gradle 6 (getDependencyProject()) and Gradle 9+ (getPath()).
*
* @param projectDependency the project dependency to resolve
* @return the resolved project
* @throws RuntimeException if the dependent project could not be resolved
*/
private Project getDependentProject(ProjectDependency projectDependency) {
// Try getDependencyProject() first (Gradle 6-8)
try {
java.lang.reflect.Method getDependencyProjectMethod =
projectDependency.getClass().getMethod("getDependencyProject");
return (Project) getDependencyProjectMethod.invoke(projectDependency);
} catch (NoSuchMethodException e) {
// Fall through to getPath() approach (Gradle 9+)
} catch (ReflectiveOperationException e) {
throw new RuntimeException(
"Failed to resolve dependent project from " + projectDependency, e);
}
// Try getPath() approach (Gradle 9+)
try {
java.lang.reflect.Method getPathMethod = projectDependency.getClass().getMethod("getPath");
String path = (String) getPathMethod.invoke(projectDependency);
return getProject().project(path);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(
"Failed to resolve dependent project from " + projectDependency, e);
}
}
}
View on GitHub (pinned to fb949e2676)
Solutions
- Check the wrapped cause 'e' printed by the RuntimeException to identify the actual reflective failure.
- Verify the dependency is a normal ProjectDependency created by Gradle's project(...) DSL, not a custom implementation.
- If on Gradle 9+, ensure the getPath() fallback path is reachable (the getDependencyProject() method should simply be absent, not failing).
- Update jib-gradle-plugin to a version matching your Gradle major version.
Example fix
// before (in build.gradle, custom dependency object passed around)
configurations.runtimeClasspath.dependencies.add(myCustomProjectDependency)
// after
dependencies { implementation project(':my-lib') } Defensive patterns
Strategy: try-catch
Validate before calling
// Gradle build sanity check
def isPlainProjectDep = { dep -> dep instanceof org.gradle.api.artifacts.ProjectDependency } Type guard
def asProject(dep) { dep instanceof org.gradle.api.artifacts.ProjectDependency ? dep : null } Try / catch
try {
// run skaffold files task v2
} catch (RuntimeException e) {
if (e.message?.startsWith('Failed to resolve dependent project from')) {
logger.warn('Unresolvable project dependency: ' + e.cause)
} else { throw e }
} Prevention
- Use standard project(':name') dependencies only.
- Keep jib plugin and Gradle versions aligned.
- Check the cause chain when reflection failures appear.
When it happens
Trigger: Calling getDependentProject (via dependentProject or findProjectDependencies in the Skaffold files task v2) on a projectDependency object whose getDependencyProject() method exists but fails reflectively: method is not accessible (IllegalAccessException) or the underlying invocation throws (InvocationTargetException).
Common situations: Unusual custom ProjectDependency implementations, Gradle versions where the method exists but behaves unexpectedly, or security/classloader restrictions blocking reflective access in the build environment.
Understand the failure class
Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.
Related errors
- manifestTemplateClass + " cannot be instantiated"
- ${HELPFUL_SUGGESTIONS_PREFIX}, perhaps you should make sure
- container.appRoot is not an absolute Unix-style path: ${inva
- invalid value for containerizingMode: ${invalidContainerizin
- container.workingDirectory is not an absolute Unix-style pat
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/93748d600743a795.
Report an issue: GitHub.