Skip to content

Commit

Permalink
Generalize fix to not emit a -gensrc.jar if the annotation processor …
Browse files Browse the repository at this point in the history
…classpath is

non-empty but there are no annotation processors to run.

PiperOrigin-RevId: 206244327
  • Loading branch information
cushon authored and Copybara-Service committed Jul 26, 2018
1 parent 6964a0b commit 1d96c7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,7 @@ public Artifact createGensrcJar(Artifact outputJar) {
*/
public boolean usesAnnotationProcessing() {
JavaTargetAttributes attributes = getAttributes();
return getJavacOpts().contains("-processor")
// The target may have a processorpath even if no annotation processors are enabled,
// so check for processor names.
|| !attributes.plugins().plugins().processorClasses().isEmpty();
return getJavacOpts().contains("-processor") || attributes.plugins().hasProcessors();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,18 @@ public static JavaPluginInfoProvider empty() {

public abstract JavaPluginInfo apiGeneratingPlugins();

/** Returns true if the provider has no associated data. */
public boolean isEmpty() {
// apiGeneratingPlugins is a subset of plugins, so checking if plugins is empty is sufficient
return plugins().isEmpty();
}

/**
* Returns true if the provider has any associated annotation processors (regardless of whether it
* has a classpath or data).
*/
public boolean hasProcessors() {
// apiGeneratingPlugins is a subset of plugins, so checking if plugins is empty is sufficient
return !plugins().processorClasses().isEmpty();
}
}

0 comments on commit 1d96c7c

Please sign in to comment.