Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 519994074
Change-Id: I3d4edb4557d8d780b1b90b5f539c6b29d10404b1
  • Loading branch information
Googler authored and copybara-github committed Mar 28, 2023
1 parent a691e97 commit e69aad7
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ public ImportDepsCheckActionBuilder transitiveDeps(NestedSet<Artifact> transitiv
return this;
}

@CanIgnoreReturnValue
public ImportDepsCheckActionBuilder importDepsChecker(Artifact importDepsChecker) {
checkState(this.importDepsChecker == null);
this.importDepsChecker = checkNotNull(importDepsChecker);
return this;
}

public void buildAndRegister(RuleContext ruleContext) {
checkNotNull(jarsToCheck);
checkNotNull(bootclasspath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Streams;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.AnalysisUtils;
import com.google.devtools.build.lib.analysis.FileProvider;
import com.google.devtools.build.lib.analysis.OutputGroupInfo;
import com.google.devtools.build.lib.analysis.PrerequisiteArtifacts;
import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
Expand All @@ -49,8 +47,6 @@
import com.google.devtools.build.lib.rules.cpp.CcNativeLibraryInfo;
import com.google.devtools.build.lib.rules.cpp.LibraryToLink;
import com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider.ClasspathType;
import com.google.devtools.build.lib.rules.java.JavaPluginInfo.JavaPluginData;
import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider.JavaOutput;
import com.google.devtools.build.lib.util.FileTypeSet;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
Expand Down Expand Up @@ -171,28 +167,6 @@ public JavaSemantics getJavaSemantics() {
return semantics;
}

/**
* Creates an action to aggregate all metadata artifacts into a single
* &lt;target_name&gt;_instrumented.jar file.
*/
public static void createInstrumentedJarAction(
RuleContext ruleContext,
JavaSemantics semantics,
List<Artifact> metadataArtifacts,
Artifact instrumentedJar,
String mainClass)
throws InterruptedException {
// In Jacoco's setup, metadata artifacts are real jars.
new DeployArchiveBuilder(semantics, ruleContext)
.setOutputJar(instrumentedJar)
// We need to save the original mainClass because we're going to run inside CoverageRunner
.setJavaStartClass(mainClass)
.setAttributes(new JavaTargetAttributes.Builder(semantics).build())
.addRuntimeJars(ImmutableList.copyOf(metadataArtifacts))
.setCompression(DeployArchiveBuilder.Compression.UNCOMPRESSED)
.build();
}

public static ImmutableList<String> getConstraints(RuleContext ruleContext) {
return ruleContext.getRule().isAttrDefined("constraints", Type.STRING_LIST)
? ImmutableList.copyOf(ruleContext.attributes().get("constraints", Type.STRING_LIST))
Expand Down Expand Up @@ -365,11 +339,6 @@ public NestedSet<Artifact> collectTransitiveSourceJars(Iterable<Artifact> target
return builder.build();
}

public final void initializeJavacOpts() {
Preconditions.checkState(javacOpts == null);
javacOpts = computeJavacOpts(getCompatibleJavacOptions());
}

/** Computes javacopts for the current rule. */
private ImmutableList<String> computeJavacOpts(Collection<String> extraRuleJavacOpts) {
ImmutableList.Builder<String> javacOpts =
Expand Down Expand Up @@ -838,32 +807,6 @@ private static Iterable<JavaPluginInfo> getExportedJavaPluginInfoForAttribute(
return ImmutableList.of();
}

JavaPluginInfo createJavaPluginInfo(
RuleContext ruleContext, ImmutableList<JavaOutput> javaOutputs) {
NestedSet<String> processorClasses =
NestedSetBuilder.wrap(Order.NAIVE_LINK_ORDER, getProcessorClasses(ruleContext));
NestedSet<Artifact> processorClasspath = getRuntimeClasspath();
FileProvider dataProvider = ruleContext.getPrerequisite("data", FileProvider.class);
NestedSet<Artifact> data =
dataProvider != null
? dataProvider.getFilesToBuild()
: NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER);
return JavaPluginInfo.create(
JavaPluginData.create(processorClasses, processorClasspath, data),
ruleContext.attributes().get("generates_api", Type.BOOLEAN),
javaOutputs);
}

/**
* Returns the class that should be passed to javac in order to run the annotation processor this
* class represents.
*/
private static ImmutableSet<String> getProcessorClasses(RuleContext ruleContext) {
return ruleContext.getRule().isAttributeValueExplicitlySpecified("processor_class")
? ImmutableSet.of(ruleContext.attributes().get("processor_class", Type.STRING))
: ImmutableSet.of();
}

public static JavaPluginInfo getTransitivePlugins(RuleContext ruleContext) {
return JavaPluginInfo.mergeWithoutJavaOutputs(
Iterables.concat(
Expand Down Expand Up @@ -923,27 +866,6 @@ public final <P extends TransitiveInfoProvider> List<P> getDependencies(Class<P>
return JavaInfo.getProvidersFromListOfTargets(provider, getDependencies());
}

/**
* Returns a list of the current target's runtime jars and the first two levels of its direct
* dependencies.
*
* <p>This method is meant to aid the persistent test runner, which aims at avoiding loading all
* classes on the classpath for each test run. To that extent this method computes a small jars
* set of the most likely to be changed classes when writing code for a test. Their classes should
* be loaded in a separate classloader by the persistent test runner.
*/
public ImmutableSet<Artifact> getDirectRuntimeClasspath() {
ImmutableSet.Builder<Artifact> directDeps = new ImmutableSet.Builder<>();
directDeps.addAll(javaArtifacts.getRuntimeJars());
for (TransitiveInfoCollection dep : targetsTreatedAsDeps(ClasspathType.RUNTIME_ONLY)) {
JavaInfo javaInfo = JavaInfo.getJavaInfo(dep);
if (javaInfo != null) {
directDeps.addAll(javaInfo.getDirectRuntimeJars());
}
}
return directDeps.build();
}

/**
* Returns true if and only if this target has the neverlink attribute set to 1, or false if the
* neverlink attribute does not exist (for example, on *_binary targets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.devtools.build.lib.rules.java;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.FileProvider;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
Expand All @@ -27,7 +26,6 @@
import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;
import com.google.devtools.build.lib.util.FileType;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Collection;
import java.util.Iterator;

/** A collection of recursively collected Java build information. */
Expand Down Expand Up @@ -192,14 +190,6 @@ public static JavaCompilationArgsProvider merge(Iterable<JavaCompilationArgsProv
return javaCompilationArgs.build();
}

/**
* Returns a {@link JavaCompilationArgsProvider} that forwards the union of information from the
* inputs, see {@link #merge(Collection<JavaCompilationArgsProvider>)}.
*/
public static JavaCompilationArgsProvider merge(JavaCompilationArgsProvider... providers) {
return merge(ImmutableList.copyOf(providers));
}

/** Returns a new builder instance. */
public static final Builder builder() {
return new Builder();
Expand Down Expand Up @@ -240,14 +230,6 @@ public Builder merge(JavaCompilationArtifacts other, boolean isNeverLink) {
return this;
}

/**
* Legacy method for dealing with objects which construct {@link JavaCompilationArtifacts}
* objects.
*/
public Builder merge(JavaCompilationArtifacts other) {
return merge(other, /* isNeverLink= */ false);
}

@CanIgnoreReturnValue
public Builder addRuntimeJar(Artifact runtimeJar) {
this.runtimeJarsBuilder.add(runtimeJar);
Expand Down Expand Up @@ -281,20 +263,6 @@ public Builder addDirectCompileTimeJars(
return this;
}

/**
* Adds transitive interface compile-time jars.
*
* @deprecated this is necessary to support java_common.create_provider, which is also
* deprecated. It allows creating providers where the direct compile-time jars aren't a
* subset of the transitive jars, and it doesn't provide a way to associate the 'full' jars.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder addTransitiveCompileTimeJars(NestedSet<Artifact> transitiveCompileTimeJars) {
this.transitiveCompileTimeJarsBuilder.addTransitive(transitiveCompileTimeJars);
return this;
}

@CanIgnoreReturnValue
public Builder addCompileTimeJavaDependencyArtifacts(
NestedSet<Artifact> compileTimeJavaDependencyArtifacts) {
Expand All @@ -321,14 +289,6 @@ public Builder addExports(JavaCompilationArgsProvider args, ClasspathType type)
return addArgs(args, type, true);
}

/**
* Add the {@link JavaCompilationArgsProvider} for a dependency with dep-like semantics; see
* also {@link #addDeps(JavaCompilationArgsProvider, ClasspathType)}.
*/
public Builder addDeps(JavaCompilationArgsProvider args) {
return addDeps(args, ClasspathType.BOTH);
}

/*
* Add the {@link JavaCompilationArgsProvider} for a dependency with dep-like semantics:
* direct jars of the input are <em>not</em> direct jars of the output.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;
Expand Down Expand Up @@ -52,11 +51,6 @@ public abstract class JavaCompilationArtifacts {
@Nullable
public abstract Artifact getCompileTimeDependencyArtifact();

/** Returns a builder for a {@link JavaCompilationArtifacts}. */
public static Builder builder() {
return new Builder();
}

private static JavaCompilationArtifacts create(
ImmutableList<Artifact> runtimeJars,
ImmutableList<Artifact> compileTimeJars,
Expand Down Expand Up @@ -99,12 +93,6 @@ public Builder addRuntimeJar(Artifact jar) {
return this;
}

@CanIgnoreReturnValue
public Builder addRuntimeJars(Iterable<Artifact> jars) {
Iterables.addAll(this.runtimeJars, jars);
return this;
}

@CanIgnoreReturnValue
public Builder addInterfaceJarWithFullJar(Artifact ijar, Artifact fullJar) {
this.compileTimeJars.add(ijar);
Expand All @@ -119,15 +107,6 @@ public Builder addCompileTimeJarAsFullJar(Artifact jar) {
return this;
}

@CanIgnoreReturnValue
Builder addInterfaceJarsWithFullJars(
Iterable<Artifact> compileTimeJars, Iterable<Artifact> fullCompileTimeJars) {
Iterables.addAll(this.compileTimeJars, compileTimeJars);
Iterables.addAll(this.fullCompileTimeJars, fullCompileTimeJars);
validate();
return this;
}

@CanIgnoreReturnValue
public Builder setCompileTimeDependencies(@Nullable Artifact compileTimeDependencies) {
this.compileTimeDependencies = compileTimeDependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,14 +645,6 @@ private boolean generatesOutputDeps() {
return getJavaConfiguration().getGenerateJavaDeps() && attributes.hasSources();
}

/**
* Creates and registers an Action that packages all of the resources into a Jar. This includes
* the declared resources, the classpath resources and the translated messages.
*/
public void createResourceJarAction(Artifact resourceJar) {
createResourceJarAction(resourceJar, ImmutableList.<Artifact>of());
}

private void createResourceJarAction(Artifact resourceJar, ImmutableList<Artifact> extraJars) {
checkNotNull(resourceJar, "resource jar output must not be null");
JavaTargetAttributes attributes = getAttributes();
Expand Down Expand Up @@ -856,11 +848,6 @@ public StrictDepsMode getStrictJavaDeps() {
return strictJavaDeps;
}

/** Determines which tool to use when fixing dependency errors. */
public String getFixDepsTool() {
return fixDepsTool;
}

/**
* Gets the value of the "javacopts" attribute combining them with the default options. If the
* current rule has no javacopts attribute, this method only returns the default options.
Expand All @@ -879,13 +866,6 @@ private ImmutableList<Artifact> getTranslations() {
return ImmutableList.copyOf(translations);
}

/**
* Returns the javac bootclasspath artifacts from the given toolchain (if it has any) or the rule.
*/
public static BootClassPathInfo getBootClasspath(JavaToolchainProvider javaToolchain) {
return javaToolchain.getBootclasspath();
}

/**
* Creates the Action that creates ijars from Jar files.
*
Expand Down

0 comments on commit e69aad7

Please sign in to comment.