Class GenruleAndroidTools

  • All Implemented Interfaces:

    public abstract class GenruleAndroidTools
    extends Object
    implements AddsToRuleKey
    Immutable class for holding Android paths and tools, for use in GenruleBuildable.

    Note that, despite implementing AddsToRuleKey, GenruleAndroidTools does not actually contribute to rule keys. The reason for this is that all of the Path objects contained in this object are paths outside of the repository. GenruleAndroidTools is never serialized due to other logic in GenruleBuildable that prevents it from happening; it is a logic error to serialize this class across a ModernBuildRule boundary.

    This class still must implement AddsToRuleKey because ModernBuildRule requires that all fields in a Buildable must implement AddsToRuleKey so that a serializer can be derived.

    • Constructor Detail

      • GenruleAndroidTools

        public GenruleAndroidTools()
    • Method Detail

      • getAndroidSdkLocation

        public abstract Path getAndroidSdkLocation()
      • getAndroidPathToDx

        public abstract Path getAndroidPathToDx()
      • getAndroidPathToZipalign

        public abstract Path getAndroidPathToZipalign()
      • getAaptTool

        public abstract Tool getAaptTool()
      • getAapt2Tool

        public abstract Tool getAapt2Tool()
      • getAndroidNdkLocation

        public abstract Optional<Path> getAndroidNdkLocation()
      • of

        public static GenruleAndroidTools of​(AndroidTools tools,
                                             BuildTarget target,
                                             BuildRuleResolver ruleResolver)
        Extracts a set of Android tools for a particular build using that build's target and rule resolver. This is done here is instead of within the GenruleBuildable because Buildables don't have access to rule resolvers, and one is used here to look up the Tool for aapt2. In general Genrule probably shouldn't know about Android, but for the moment it does.
        tools - Tools reference for Android
        target - The BuildTarget to retrieve tools for
        ruleResolver - Rule resolver for resolving tool referenves