public class DefaultJavaLibrary extends PipelinedModernBuildRule<JavacPipelineState,com.facebook.buck.jvm.java.DefaultJavaLibraryBuildable> implements JavaLibrary, ExportDependencies, InitializableFromDisk<JavaLibrary.Data>, AndroidPackageable, MaybeRequiredForSourceOnlyAbi, SupportsDependencyFileRuleKey, JavaLibraryWithTests
src/com/facebook/feed/BUCK:
java_library(
name = 'feed',
srcs = [
'FeedStoryRenderer.java',
],
deps = [
'//src/com/facebook/feed/model:model',
'//third-party/java/guava:guava',
],
)
Then this would compile FeedStoryRenderer.java against Guava and the classes generated
from the //src/com/facebook/feed/model:model rule.JavaLibrary.DataGWT_MODULE_FLAVOR, MAVEN_JAR, SRC_JAR| Modifier | Constructor and Description |
|---|---|
protected |
DefaultJavaLibrary(BuildTarget buildTarget,
ProjectFilesystem projectFilesystem,
JarBuildStepsFactory jarBuildStepsFactory,
SourcePathRuleFinder ruleFinder,
Optional<SourcePath> proguardConfig,
SortedSet<BuildRule> firstOrderPackageableDeps,
com.google.common.collect.ImmutableSortedSet<BuildRule> fullJarExportedDeps,
com.google.common.collect.ImmutableSortedSet<BuildRule> fullJarProvidedDeps,
com.google.common.collect.ImmutableSortedSet<BuildRule> fullJarExportedProvidedDeps,
com.google.common.collect.ImmutableSortedSet<BuildRule> runtimeDeps,
BuildTarget abiJar,
BuildTarget sourceOnlyAbiJar,
Optional<String> mavenCoords,
com.google.common.collect.ImmutableSortedSet<BuildTarget> tests,
boolean requiredForSourceOnlyAbi,
JavaBuckConfig.UnusedDependenciesAction unusedDependenciesAction,
Optional<UnusedDependenciesFinderFactory> unusedDependenciesFinderFactory,
CalculateSourceAbi sourceAbi,
boolean isDesugarEnabled,
boolean isInterfaceMethodsDesugarEnabled,
boolean neverMarkAsUnusedDependency) |
getPipelinedBuildStepscompareTo, getBuildable, getBuildCellPathFactory, getBuildDeps, getBuildSteps, getOutputPathResolver, getSetupStepsForBuildable, getSourcePath, getSourcePaths, injectFieldsIfNecessary, inputBasedRuleKeyIsEnabled, recordOutputs, recordOutputs, recordOutputs, stepsForBuildable, stepsForBuildable, updateBuildRuleResolverequals, getBuildTarget, getDependencies, getProjectFilesystem, getSourcePathOutputs, getType, hasBuildSteps, hashCode, injectFields, isCacheable, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitisMavenCoordsPresentcompareTo, getBuildDeps, getBuildSteps, getBuildTarget, getFullyQualifiedName, getProjectFilesystem, hasBuildSteps, isCacheable, outputFileCanBeCopied, shouldRespectInputSizeLimitForRemoteExecution, toString, updateBuildRuleResolvergetDependencies, getSourcePathOutputsgetTypeisSupportedisSupportedprotected DefaultJavaLibrary(BuildTarget buildTarget, ProjectFilesystem projectFilesystem, JarBuildStepsFactory jarBuildStepsFactory, SourcePathRuleFinder ruleFinder, Optional<SourcePath> proguardConfig, SortedSet<BuildRule> firstOrderPackageableDeps, com.google.common.collect.ImmutableSortedSet<BuildRule> fullJarExportedDeps, com.google.common.collect.ImmutableSortedSet<BuildRule> fullJarProvidedDeps, com.google.common.collect.ImmutableSortedSet<BuildRule> fullJarExportedProvidedDeps, com.google.common.collect.ImmutableSortedSet<BuildRule> runtimeDeps, @Nullable BuildTarget abiJar, @Nullable BuildTarget sourceOnlyAbiJar, Optional<String> mavenCoords, com.google.common.collect.ImmutableSortedSet<BuildTarget> tests, boolean requiredForSourceOnlyAbi, JavaBuckConfig.UnusedDependenciesAction unusedDependenciesAction, Optional<UnusedDependenciesFinderFactory> unusedDependenciesFinderFactory, @Nullable CalculateSourceAbi sourceAbi, boolean isDesugarEnabled, boolean isInterfaceMethodsDesugarEnabled, boolean neverMarkAsUnusedDependency)
public static DefaultJavaLibraryRules.Builder rulesBuilder(BuildTarget buildTarget, ProjectFilesystem projectFilesystem, ToolchainProvider toolchainProvider, BuildRuleParams params, ActionGraphBuilder graphBuilder, ConfiguredCompilerFactory compilerFactory, @Nullable JavaBuckConfig javaBuckConfig, @Nullable JavaLibraryDescription.CoreArg args)
public com.google.common.collect.ImmutableSortedSet<BuildTarget> getTests()
getTests in interface JavaLibraryWithTestspublic boolean isDesugarEnabled()
HasDesugarSupportSuch as Lambda expressions, Method references, Repeating annotations
isDesugarEnabled in interface HasDesugarSupportpublic boolean isInterfaceMethodsDesugarEnabled()
HasDesugarSupportisInterfaceMethodsDesugarEnabled in interface HasDesugarSupportpublic boolean getRequiredForSourceOnlyAbi()
getRequiredForSourceOnlyAbi in interface MaybeRequiredForSourceOnlyAbipublic com.google.common.collect.ImmutableSortedSet<SourcePath> getJavaSrcs()
getJavaSrcs in interface JavaLibrarypublic com.google.common.collect.ImmutableSortedSet<SourcePath> getSources()
getSources in interface HasSourcespublic com.google.common.collect.ImmutableSortedSet<SourcePath> getResources()
getResources in interface JavaLibrarypublic Optional<String> getResourcesRoot()
getResourcesRoot in interface JavaLibrarypublic boolean hasAnnotationProcessing()
hasAnnotationProcessing in interface JavaLibrarypublic Set<BuildRule> getDepsForTransitiveClasspathEntries()
getDepsForTransitiveClasspathEntries in interface HasClasspathDepspublic com.google.common.collect.ImmutableSet<SourcePath> getTransitiveClasspaths()
getTransitiveClasspaths in interface HasClasspathEntriesjavac's -classpath flag
in order to build a jar associated with this rule.public com.google.common.collect.ImmutableSet<JavaLibrary> getTransitiveClasspathDeps()
getTransitiveClasspathDeps in interface HasClasspathEntriespublic com.google.common.collect.ImmutableSet<SourcePath> getImmediateClasspaths()
HasClasspathEntriesUsed to generate the value of HasClasspathEntries.getTransitiveClasspaths().
getImmediateClasspaths in interface HasClasspathEntriespublic com.google.common.collect.ImmutableSet<SourcePath> getOutputClasspaths()
getOutputClasspaths in interface HasClasspathEntriesjavac's
-classpath flag in order to compile rules that depend on this rule. This is a
superset of getImmediateClasspaths which also contains the classpath entries of any
exported deps.public com.google.common.collect.ImmutableSortedSet<SourcePath> getCompileTimeClasspathSourcePaths()
public Optional<SourcePath> getGeneratedAnnotationSourcePath()
getGeneratedAnnotationSourcePath in interface JavaLibrarypublic SortedSet<BuildRule> getExportedDeps()
getExportedDeps in interface ExportDependenciespublic SortedSet<BuildRule> getExportedProvidedDeps()
getExportedProvidedDeps in interface ExportDependenciespublic void invalidateInitializeFromDiskState()
invalidateInitializeFromDiskState in interface InitializableFromDisk<JavaLibrary.Data>public JavaLibrary.Data initializeFromDisk(SourcePathResolverAdapter pathResolver) throws IOException
initializeFromDisk in interface InitializableFromDisk<JavaLibrary.Data>pathResolver - IOExceptionpublic BuildOutputInitializer<JavaLibrary.Data> getBuildOutputInitializer()
getBuildOutputInitializer in interface InitializableFromDisk<JavaLibrary.Data>public final Optional<BuildTarget> getAbiJar()
getAbiJar in interface HasJavaAbiSourcePath representing the ABI Jar for this rule.public Optional<BuildTarget> getSourceOnlyAbiJar()
getSourceOnlyAbiJar in interface HasJavaAbipublic JavaAbiInfo getAbiInfo()
getAbiInfo in interface HasJavaAbipublic com.google.common.collect.ImmutableSortedMap<String,com.google.common.hash.HashCode> getClassNamesToHashes()
getClassNamesToHashes in interface HasJavaClassHashes.class files in the output of this rule to
SHA-1 hashes of their contents.@Nullable public SourcePath getSourcePathToOutput()
getSourcePathToOutput in interface BuildRulegetSourcePathToOutput in class ModernBuildRule<com.facebook.buck.jvm.java.DefaultJavaLibraryBuildable>public Iterable<AndroidPackageable> getRequiredPackageables(BuildRuleResolver ruleResolver)
AndroidPackageableFor example, an android_library will need all of its Java deps (except provided_deps), its resource deps, and its native library deps (even though it doesn't need the native library as a build-time dependency). An android_resource might need an android_library that declares a custom view that it references, as well as other android_resource rules that it references directly.
TODO(natthu): Once build rules and buildables are merged, replace this method with another
interface that lets an AndroidPackageable override the default set which is all deps of
the type AndroidPackageable.
getRequiredPackageables in interface AndroidPackageableAndroidPackageables that must be included along with this one.public java.util.stream.Stream<BuildTarget> getRuntimeDeps(BuildRuleResolver buildRuleResolver)
getRuntimeDeps in interface HasRuntimeDepspublic Optional<String> getMavenCoords()
HasMavenCoordinatesgetMavenCoords in interface HasMavenCoordinatespublic void addToCollector(AndroidPackageableCollector collector)
AndroidPackageableImplementations should call methods on the collector specify what concrete content must be included in an Android package that includes this object. For example, an android_library will add Java classes, an ndk_library will add native libraries, and android_resource will add resource directories.
addToCollector in interface AndroidPackageablecollector - The AndroidPackageableCollector that will receive the content.public boolean useDependencyFileRuleKeys()
useDependencyFileRuleKeys in interface SupportsDependencyFileRuleKeypublic java.util.function.Predicate<SourcePath> getCoveredByDepFilePredicate(SourcePathResolverAdapter pathResolver)
SupportsDependencyFileRuleKeyI.e. this predicate should return true only for source paths that *may* be returned from
SupportsDependencyFileRuleKey.getInputsAfterBuildingLocally(BuildContext, CellPathResolver). This information is
used by the rule key builder to infer that inputs *not* in this list should be included
unconditionally in the rule key. Inputs that *are* in this list should be included in the rule
key if and only if they are actually being used for the rule. I.e. if they are present in the
dep-file listed by SupportsDependencyFileRuleKey.getInputsAfterBuildingLocally(BuildContext, CellPathResolver).
getCoveredByDepFilePredicate in interface SupportsDependencyFileRuleKeypublic java.util.function.Predicate<SourcePath> getExistenceOfInterestPredicate(SourcePathResolverAdapter pathResolver)
SupportsDependencyFileRuleKeyThe main purpose of this predicate is to support scenarios where compiler decides whether to use a file or not solely based on its path. Of course, if compiler decides to use the file, it should list it in the dep-file in which case both the path and the content will be included in the rule key. However, relying only on presence in the dep-file for such paths is not sufficient. The problem occurs when a new such file just gets added, in which case it won't be present in the dep-file produced in the previous build, and yet if we run a local build now the compiler may decide to use it. For that reason rule key needs to reflect existence of all such files and change when a such a file gets added or removed.
getExistenceOfInterestPredicate in interface SupportsDependencyFileRuleKeypublic com.google.common.collect.ImmutableList<SourcePath> getInputsAfterBuildingLocally(BuildContext context, CellPathResolver cellPathResolver)
SupportsDependencyFileRuleKeygetInputsAfterBuildingLocally in interface SupportsDependencyFileRuleKeypublic boolean useRulePipelining()
useRulePipelining in interface SupportsPipelining<JavacPipelineState>public RulePipelineStateFactory<JavacPipelineState> getPipelineStateFactory()
getPipelineStateFactory in interface SupportsPipelining<JavacPipelineState>@Nullable public SupportsPipelining<JavacPipelineState> getPreviousRuleInPipeline()
getPreviousRuleInPipeline in interface SupportsPipelining<JavacPipelineState>public JavaClassHashesProvider getClassHashesProvider()
getClassHashesProvider in interface HasJavaClassHashespublic void setJavaClassHashesProvider(JavaClassHashesProvider javaClassHashesProvider)
public boolean neverMarkAsUnusedDependency()
neverMarkAsUnusedDependency in interface JavaLibrary