diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/buildtool')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java index c511ced77b..a60042922b 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java @@ -54,6 +54,8 @@ import com.google.devtools.build.lib.events.Reporter; import com.google.devtools.build.lib.packages.InputFile; import com.google.devtools.build.lib.packages.License; import com.google.devtools.build.lib.packages.License.DistributionType; +import com.google.devtools.build.lib.packages.NoSuchPackageException; +import com.google.devtools.build.lib.packages.NoSuchTargetException; import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.packages.TargetUtils; import com.google.devtools.build.lib.pkgcache.LoadingCallback; @@ -675,7 +677,14 @@ public final class BuildTool { private void validateLicensingForTargets(Iterable<ConfiguredTarget> configuredTargets, boolean keepGoing) throws ViewCreationFailedException { for (ConfiguredTarget configuredTarget : configuredTargets) { - final Target target = configuredTarget.getTarget(); + Target target = null; + try { + target = env.getPackageManager().getTarget(env.getReporter(), configuredTarget.getLabel()); + } catch (NoSuchPackageException | NoSuchTargetException | InterruptedException e) { + env.getReporter().handle(Event.error("Failed to get target to validate license")); + throw new ViewCreationFailedException( + "Build aborted due to issue getting targets to validate licenses", e); + } if (TargetUtils.isTestRule(target)) { continue; // Tests are exempt from license checking @@ -697,7 +706,7 @@ public final class BuildTool { } } } - } else if (configuredTarget.getTarget() instanceof InputFile) { + } else if (target instanceof InputFile) { // Input file targets do not provide licenses because they do not // depend on the rule where their license is taken from. This is usually // not a problem, because the transitive collection of licenses always @@ -706,7 +715,7 @@ public final class BuildTool { // // See FileTarget#getLicense for more information about the handling of // license issues with File targets. - License license = configuredTarget.getTarget().getLicense(); + License license = target.getLicense(); if (!license.checkCompatibility(distribs, target, configuredTarget.getLabel(), getReporter(), staticallyLinked)) { if (!keepGoing) { |