{"record":{"id":"93748d600743a795","repo":"GoogleContainerTools/jib","slug":"failed-to-resolve-dependent-project-from-project","errorCode":null,"errorMessage":"Failed to resolve dependent project from ${projectDependency}","messagePattern":"Failed to resolve dependent project from (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/skaffold/FilesTaskV2.java","lineNumber":265,"sourceCode":"  /**\n   * Resolves a {@link ProjectDependency} to its corresponding {@link Project} instance.\n   *\n   * <p>Uses reflection to handle both Gradle 6 (getDependencyProject()) and Gradle 9+ (getPath()).\n   *\n   * @param projectDependency the project dependency to resolve\n   * @return the resolved project\n   * @throws RuntimeException if the dependent project could not be resolved\n   */\n  private Project getDependentProject(ProjectDependency projectDependency) {\n    // Try getDependencyProject() first (Gradle 6-8)\n    try {\n      java.lang.reflect.Method getDependencyProjectMethod =\n          projectDependency.getClass().getMethod(\"getDependencyProject\");\n      return (Project) getDependencyProjectMethod.invoke(projectDependency);\n    } catch (NoSuchMethodException e) {\n      // Fall through to getPath() approach (Gradle 9+)\n    } catch (ReflectiveOperationException e) {\n      throw new RuntimeException(\n          \"Failed to resolve dependent project from \" + projectDependency, e);\n    }\n\n    // Try getPath() approach (Gradle 9+)\n    try {\n      java.lang.reflect.Method getPathMethod = projectDependency.getClass().getMethod(\"getPath\");\n      String path = (String) getPathMethod.invoke(projectDependency);\n      return getProject().project(path);\n    } catch (ReflectiveOperationException e) {\n      throw new RuntimeException(\n          \"Failed to resolve dependent project from \" + projectDependency, e);\n    }\n  }\n}\n","sourceCodeStart":247,"sourceCodeEnd":280,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/skaffold/FilesTaskV2.java#L247-L280","documentation":"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.","triggerScenarios":"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).","commonSituations":"Unusual custom ProjectDependency implementations, Gradle versions where the method exists but behaves unexpectedly, or security/classloader restrictions blocking reflective access in the build environment.","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."],"exampleFix":"// before (in build.gradle, custom dependency object passed around)\nconfigurations.runtimeClasspath.dependencies.add(myCustomProjectDependency)\n// after\ndependencies { implementation project(':my-lib') }","handlingStrategy":"try-catch","validationCode":"// Gradle build sanity check\ndef isPlainProjectDep = { dep -> dep instanceof org.gradle.api.artifacts.ProjectDependency }","typeGuard":"def asProject(dep) { dep instanceof org.gradle.api.artifacts.ProjectDependency ? dep : null }","tryCatchPattern":"try {\n  // run skaffold files task v2\n} catch (RuntimeException e) {\n  if (e.message?.startsWith('Failed to resolve dependent project from')) {\n    logger.warn('Unresolvable project dependency: ' + e.cause)\n  } else { throw e }\n}","preventionTips":["Use standard project(':name') dependencies only.","Keep jib plugin and Gradle versions aligned.","Check the cause chain when reflection failures appear."],"tags":["gradle","reflection","plugin-internals"],"backgroundTag":"deprecated-api-usage","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}