diff --git a/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java index b48bc1db35876e..0dfff29072d9ca 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java @@ -32,6 +32,7 @@ import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.ExtendedEventHandler; import com.google.devtools.build.lib.packages.DependencyFilter; +import com.google.devtools.build.lib.packages.NoSuchTargetException; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.pkgcache.FilteringPolicies; @@ -54,6 +55,7 @@ import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; import com.google.devtools.build.lib.skyframe.ConfiguredTargetValue; import com.google.devtools.build.lib.skyframe.GraphBackedRecursivePackageProvider; +import com.google.devtools.build.lib.skyframe.PackageValue; import com.google.devtools.build.lib.skyframe.RecursivePackageProviderBackedTargetPatternResolver; import com.google.devtools.build.lib.skyframe.SkyFunctions; import com.google.devtools.build.lib.skyframe.TargetPatternValue; @@ -432,8 +434,14 @@ public TargetAccessor getAccessor() { @Override public Target getTarget(Label label) throws TargetNotFoundException, QueryException, InterruptedException { - ConfiguredTarget configuredTarget = getConfiguredTarget(label); - return configuredTarget == null ? null : configuredTarget.getTarget(); + try { + return ((PackageValue) + walkableGraphSupplier.get().getValue(PackageValue.key(label.getPackageIdentifier()))) + .getPackage() + .getTarget(label.getName()); + } catch (NoSuchTargetException e) { + throw new TargetNotFoundException(e); + } } @Override