@Beta
public class Project
extends java.lang.Object
NOTE: This is not a public or final API; if you rely on this be prepared to adjust your code for the next tools release.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<Project> |
allLibraries |
protected java.lang.Boolean |
appCompat |
protected java.util.List<java.io.File> |
assetFolders |
protected int |
buildSdk |
protected java.lang.String |
buildTargetHash |
protected com.android.tools.lint.client.api.LintClient |
client |
protected com.android.tools.lint.client.api.Configuration |
configuration |
protected java.io.File |
dir |
protected java.util.List<Project> |
directLibraries |
protected boolean |
externalLibrary |
protected java.util.List<java.io.File> |
files
If non null, specifies a non-empty list of specific files under this project which should be
checked.
|
protected java.util.List<java.io.File> |
generatedResourceFolders |
protected java.util.List<java.io.File> |
generatedSourceFolders |
protected java.util.List<java.io.File> |
gradleFiles |
protected java.lang.Boolean |
gradleProject |
protected com.android.ide.common.repository.GradleVersion |
gradleVersion |
protected java.util.List<java.io.File> |
javaClassFolders |
protected java.util.List<java.io.File> |
javaLibraries |
protected java.util.List<java.io.File> |
javaSourceFolders |
protected java.lang.Boolean |
leanback |
protected boolean |
library |
protected java.util.List<java.io.File> |
manifestFiles |
protected com.android.sdklib.AndroidVersion |
manifestMinSdk |
protected com.android.sdklib.AndroidVersion |
manifestTargetSdk |
protected com.android.builder.model.MavenCoordinates |
mavenCoordinates |
protected boolean |
mergeManifests |
protected java.lang.String |
name |
protected java.util.List<java.io.File> |
nonProvidedJavaLibraries |
protected java.lang.String |
pkg |
protected java.util.List<java.io.File> |
proguardFiles |
protected java.lang.String |
proguardPath |
protected java.io.File |
referenceDir |
protected boolean |
reportIssues |
protected java.util.List<java.io.File> |
resourceFolders |
protected com.android.tools.lint.client.api.SdkInfo |
sdkInfo
The SDK info, if any
|
protected java.lang.Boolean |
supportLib |
protected com.android.sdklib.IAndroidTarget |
target |
protected java.util.List<java.io.File> |
testLibraries |
protected java.util.List<java.io.File> |
testSourceFolders |
| Modifier | Constructor and Description |
|---|---|
protected |
Project(com.android.tools.lint.client.api.LintClient client,
java.io.File dir,
java.io.File referenceDir)
Creates a new Project.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFile(java.io.File file)
Adds the given file to the list of files which should be checked in this project.
|
static Project |
create(com.android.tools.lint.client.api.LintClient client,
java.io.File dir,
java.io.File referenceDir)
Creates a new
Project for the given directory. |
java.lang.Boolean |
dependsOn(java.lang.String artifact)
Returns true if this project depends on the given artifact.
|
boolean |
equals(java.lang.Object obj) |
java.util.Set<java.lang.String> |
getAllApplicationIds()
Returns all application ids, if known
|
java.util.List<Project> |
getAllLibraries()
Returns the transitive closure of the library projects for this project
|
java.util.List<java.lang.String> |
getApplicableDensities()
Returns the set of applicable densities for this project.
|
java.lang.String |
getApplicationId()
Returns the application id, if known
|
java.util.List<java.io.File> |
getAssetFolders()
Returns the asset folders.
|
int |
getBuildSdk()
Returns the compile SDK version used to build the project, or null if not known.
|
com.android.sdklib.IAndroidTarget |
getBuildTarget()
Returns the target used to build the project, or null if not known
|
java.lang.String |
getBuildTargetHash()
Returns the target API used to build the project, or null if not known.
|
com.android.sdklib.BuildToolInfo |
getBuildTools()
Returns the specific version of the build tools being used, if known
|
com.android.tools.lint.client.api.LintClient |
getClient()
Returns the associated client
|
com.android.tools.lint.client.api.Configuration |
getConfiguration(com.android.tools.lint.client.api.LintDriver driver)
Gets the configuration associated with this project
|
com.android.builder.model.Variant |
getCurrentVariant()
Returns the current selected variant, if any (and if the current project is a Gradle
project).
|
java.io.File |
getDir()
Returns the project root directory
|
java.util.List<Project> |
getDirectLibraries()
Returns the list of library projects referenced by this project
|
java.lang.String |
getDisplayPath(java.io.File file)
Returns the relative path of a given file relative to the user specified directory (which is
often the project directory but sometimes a higher up directory when a directory tree is
being scanned
|
java.util.List<java.io.File> |
getGeneratedResourceFolders() |
java.util.List<java.io.File> |
getGeneratedSourceFolders() |
java.util.List<java.io.File> |
getGradleBuildScripts()
Returns the Gradle build script files configured for this project, if any
|
com.android.builder.model.AndroidLibrary |
getGradleLibraryModel()
Returns the project model for this project if it corresponds to a Gradle library.
|
com.android.ide.common.repository.GradleVersion |
getGradleModelVersion()
If this is a Gradle project with a valid Gradle model, return the version of the
model/plugin.
|
com.android.builder.model.AndroidProject |
getGradleProjectModel()
Returns the project model for this project if it corresponds to a Gradle project.
|
java.util.List<java.io.File> |
getJavaClassFolders()
Returns the list of output folders for class files
|
java.util.List<java.io.File> |
getJavaLibraries(boolean includeProvided)
Returns the list of Java libraries (typically .jar files) that this project depends on.
|
java.util.List<java.io.File> |
getJavaSourceFolders()
Returns the list of source folders for Java source files
|
java.util.List<java.io.File> |
getManifestFiles()
Gets the paths to the manifest files in this project, if any exists.
|
com.android.builder.model.MavenCoordinates |
getMavenCoordinates()
Returns the Maven coordinates of this project, if known.
|
org.w3c.dom.Document |
getMergedManifest()
Returns the merged manifest of this project.
|
int |
getMinSdk()
Returns the minimum API level requested by the manifest, or -1 if not specified.
|
com.android.sdklib.AndroidVersion |
getMinSdkVersion()
Returns the minimum API level for the project
|
java.lang.String |
getName()
Returns the name of the project
|
java.lang.String |
getPackage()
Returns the application package specified by the manifest
|
java.util.List<java.io.File> |
getProguardFiles()
Returns the proguard files configured for this project, if any
|
java.util.List<java.io.File> |
getPropertyFiles()
Returns the .properties files to be analyzed in the project
|
java.io.File |
getReferenceDir()
Returns the original user supplied directory where the lint search started.
|
java.lang.String |
getRelativePath(java.io.File file)
Returns the relative path of a given file within the current project.
|
boolean |
getReportIssues()
Returns whether lint should report issues in this project.
|
java.util.List<java.io.File> |
getResourceFolders()
Returns the resource folders.
|
com.android.ide.common.rendering.api.ResourceNamespace |
getResourceNamespace()
Returns the namespace for resources in this module/project
|
com.android.ide.common.repository.ResourceVisibilityLookup |
getResourceVisibility()
Returns a shared
ResourceVisibilityLookup |
com.android.tools.lint.client.api.SdkInfo |
getSdkInfo()
Gets the SDK info for the current project.
|
java.util.List<java.io.File> |
getSubset()
The list of files to be checked in this project.
|
java.util.Map<java.lang.String,java.lang.String> |
getSuperClassMap()
Returns a super class map for this project.
|
int |
getTargetSdk()
Returns the target API level specified by the manifest, or -1 if not specified.
|
com.android.sdklib.AndroidVersion |
getTargetSdkVersion()
Returns the target API level for the project
|
java.util.List<java.io.File> |
getTestLibraries()
Returns the list of source folders for Java test source files
|
java.util.List<java.io.File> |
getTestSourceFolders()
Returns the list of source folders for Java test source files
|
int |
hashCode() |
protected void |
initialize() |
boolean |
isAndroidProject()
Returns true if this project is an Android project.
|
static boolean |
isAospBuildEnvironment()
Is lint running in an AOSP build environment
|
static boolean |
isAospFrameworksProject(java.io.File dir)
Is this the actual frameworks project.
|
static boolean |
isAospFrameworksRelatedProject(java.io.File dir)
Is this the frameworks or related AOSP project? Needs some hardcoded support since it doesn't
have a manifest file, etc.
|
boolean |
isExternalLibrary()
Returns true if this project is an external library (typically an AAR library), as opposed to
a local library we have source for
|
boolean |
isGradleProject()
Returns true if this project is a Gradle-based Android project
|
boolean |
isLibrary()
Returns true if this project is an Android library project
|
boolean |
isMergingManifests()
Returns whether manifest merging is in effect
|
void |
readManifest(org.w3c.dom.Document document)
Initialized the manifest state from the given manifest model
|
void |
setBuildTargetHash(java.lang.String buildTargetHash)
Sets the build target hash to be used for this project.
|
void |
setName(java.lang.String name)
Sets the name of the project
|
void |
setReportIssues(boolean reportIssues)
Sets whether lint should report issues in this project.
|
java.lang.String |
toString() |
protected final com.android.tools.lint.client.api.LintClient client
protected final java.io.File dir
protected final java.io.File referenceDir
protected com.android.tools.lint.client.api.Configuration configuration
protected java.lang.String pkg
protected int buildSdk
protected java.lang.String buildTargetHash
protected com.android.sdklib.IAndroidTarget target
protected com.android.sdklib.AndroidVersion manifestMinSdk
protected com.android.sdklib.AndroidVersion manifestTargetSdk
protected boolean library
protected boolean externalLibrary
protected java.lang.String name
protected java.lang.String proguardPath
protected boolean mergeManifests
protected com.android.tools.lint.client.api.SdkInfo sdkInfo
protected java.util.List<java.io.File> files
protected java.util.List<java.io.File> proguardFiles
protected java.util.List<java.io.File> gradleFiles
protected java.util.List<java.io.File> manifestFiles
protected java.util.List<java.io.File> javaSourceFolders
protected java.util.List<java.io.File> generatedSourceFolders
protected java.util.List<java.io.File> javaClassFolders
protected java.util.List<java.io.File> nonProvidedJavaLibraries
protected java.util.List<java.io.File> javaLibraries
protected java.util.List<java.io.File> testSourceFolders
protected java.util.List<java.io.File> testLibraries
protected java.util.List<java.io.File> resourceFolders
protected java.util.List<java.io.File> generatedResourceFolders
protected java.util.List<java.io.File> assetFolders
protected java.util.List<Project> directLibraries
protected java.util.List<Project> allLibraries
protected boolean reportIssues
protected java.lang.Boolean gradleProject
protected java.lang.Boolean supportLib
protected java.lang.Boolean appCompat
protected java.lang.Boolean leanback
protected com.android.ide.common.repository.GradleVersion gradleVersion
protected com.android.builder.model.MavenCoordinates mavenCoordinates
protected Project(@NonNull
com.android.tools.lint.client.api.LintClient client,
@NonNull
java.io.File dir,
@NonNull
java.io.File referenceDir)
@NonNull public static Project create(@NonNull com.android.tools.lint.client.api.LintClient client, @NonNull java.io.File dir, @NonNull java.io.File referenceDir)
Project for the given directory.client - the tool running the lint checkdir - the root directory of the projectreferenceDir - See getReferenceDir().Projectpublic boolean isGradleProject()
public boolean isAndroidProject()
@Nullable public com.android.builder.model.AndroidProject getGradleProjectModel()
isGradleProject() is true and isLibrary() is false.@Nullable public com.android.ide.common.repository.GradleVersion getGradleModelVersion()
@Nullable public com.android.builder.model.AndroidLibrary getGradleLibraryModel()
isGradleProject() and isLibrary() return true.@Nullable public com.android.builder.model.Variant getCurrentVariant()
@Nullable public org.w3c.dom.Document getMergedManifest()
protected void initialize()
@NonNull public com.android.ide.common.rendering.api.ResourceNamespace getResourceNamespace()
public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(@Nullable
java.lang.Object obj)
equals in class java.lang.Objectpublic void addFile(@NonNull
java.io.File file)
file - the file to be checked@Nullable public java.util.List<java.io.File> getSubset()
@NonNull public java.util.List<java.io.File> getJavaSourceFolders()
@NonNull public java.util.List<java.io.File> getGeneratedSourceFolders()
@NonNull public java.util.List<java.io.File> getJavaClassFolders()
@NonNull public java.util.List<java.io.File> getJavaLibraries(boolean includeProvided)
includeProvided - If true, included provided libraries too (libraries that are not
packaged with the app, but are provided for compilation purposes and are assumed to be
present in the running environment)@NonNull public java.util.List<java.io.File> getTestSourceFolders()
@NonNull public java.util.List<java.io.File> getTestLibraries()
@NonNull public java.util.List<java.io.File> getResourceFolders()
@NonNull public java.util.List<java.io.File> getGeneratedResourceFolders()
@NonNull public java.util.List<java.io.File> getAssetFolders()
@NonNull
public java.lang.String getDisplayPath(@NonNull
java.io.File file)
file - the file under this project to check@NonNull
public java.lang.String getRelativePath(@NonNull
java.io.File file)
file - the file under this project to check@NonNull public java.io.File getDir()
@NonNull public java.io.File getReferenceDir()
/tmp/foo, and it finds a project to lint in /tmp/foo/dev/src/project1, then the dir is /tmp/foo/dev/src/project1 and the
referenceDir is /tmp/foo/.@NonNull
public com.android.tools.lint.client.api.Configuration getConfiguration(@Nullable
com.android.tools.lint.client.api.LintDriver driver)
driver - the current driver, if any@Nullable public java.lang.String getPackage()
@Nullable public java.lang.String getApplicationId()
@NonNull public java.util.Set<java.lang.String> getAllApplicationIds()
@NonNull public com.android.sdklib.AndroidVersion getMinSdkVersion()
AndroidVersion.DEFAULT if unknownpublic int getMinSdk()
getMinSdkVersion() to get a full version if you need to check if the platform is a
preview platform etc.@NonNull public com.android.sdklib.AndroidVersion getTargetSdkVersion()
AndroidVersion.DEFAULT if unknownpublic int getTargetSdk()
getTargetSdkVersion() to get a full version if you need to check if the platform is
a preview platform etc.public int getBuildSdk()
getBuildTargetHash() instead, or to get the actual@Nullable public java.lang.String getBuildTargetHash()
AndroidVersion since it may refer to either a AndroidTargetHash for a platform or for an add-on, and AndroidVersion can only
express platform versions.public void setBuildTargetHash(java.lang.String buildTargetHash)
buildTargetHash - the target hash@Nullable public com.android.sdklib.BuildToolInfo getBuildTools()
@Nullable public com.android.sdklib.IAndroidTarget getBuildTarget()
public void readManifest(@NonNull
org.w3c.dom.Document document)
document - the DOM document for the manifest XML documentpublic boolean isLibrary()
public boolean isExternalLibrary()
@Nullable public com.android.builder.model.MavenCoordinates getMavenCoordinates()
@NonNull public java.util.List<Project> getDirectLibraries()
@NonNull public java.util.List<Project> getAllLibraries()
@NonNull public com.android.tools.lint.client.api.SdkInfo getSdkInfo()
@NonNull public java.util.List<java.io.File> getManifestFiles()
@NonNull public java.util.List<java.io.File> getProguardFiles()
@NonNull public java.util.List<java.io.File> getPropertyFiles()
@NonNull public java.util.List<java.io.File> getGradleBuildScripts()
@NonNull public java.lang.String getName()
public void setName(@NonNull
java.lang.String name)
name - the name of the project, never nullpublic void setReportIssues(boolean reportIssues)
getReportIssues() for a
full description of what that means.reportIssues - whether lint should report issues in this projectpublic boolean getReportIssues()
If a user specifies a project and its library projects for analysis, then those library
projects are all "included", and all errors found in all the projects are reported. But if
the user is only running lint on the main project, we shouldn't report errors in any of the
library projects. We still need to consider them for certain types of checks, such as
determining whether resources found in the main project are unused, so the detectors must
still get a chance to look at these projects. The #getReportIssues() attribute is
used for this purpose.
public boolean isMergingManifests()
public static boolean isAospBuildEnvironment()
public static boolean isAospFrameworksRelatedProject(@NonNull
java.io.File dir)
A frameworks AOSP projects can be any directory under "frameworks" that 1. Is not the "support" directory (which uses the public support annotations) 2. Doesn't have an AndroidManifest.xml (it's an app instead)
dir - the project directory to checkpublic static boolean isAospFrameworksProject(@NonNull
java.io.File dir)
dir - the project directory to check.@Nullable
public java.lang.Boolean dependsOn(@NonNull
java.lang.String artifact)
artifact - the Gradle/Maven name of a library@Nullable public java.util.List<java.lang.String> getApplicableDensities()
@NonNull public java.util.Map<java.lang.String,java.lang.String> getSuperClassMap()
@NonNull public com.android.ide.common.repository.ResourceVisibilityLookup getResourceVisibility()
ResourceVisibilityLookup@NonNull public com.android.tools.lint.client.api.LintClient getClient()