|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.android.tools.lint.detector.api.Project
@Beta public class Project
A project contains information about an Android project being scanned for Lint errors.
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.
Field Summary | |
---|---|
protected java.util.List<Project> |
mAllLibraries
|
protected java.lang.Boolean |
mAppCompat
|
protected java.util.List<java.io.File> |
mAssetFolders
|
protected int |
mBuildSdk
|
protected LintClient |
mClient
|
protected Configuration |
mConfiguration
|
protected java.io.File |
mDir
|
protected java.util.List<Project> |
mDirectLibraries
|
protected java.util.List<java.io.File> |
mFiles
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> |
mGradleFiles
|
protected java.lang.Boolean |
mGradleProject
|
protected java.util.List<java.io.File> |
mJavaClassFolders
|
protected java.util.List<java.io.File> |
mJavaLibraries
|
protected java.util.List<java.io.File> |
mJavaSourceFolders
|
protected boolean |
mLibrary
|
protected java.util.List<java.io.File> |
mManifestFiles
|
protected com.android.sdklib.AndroidVersion |
mManifestMinSdk
|
protected com.android.sdklib.AndroidVersion |
mManifestTargetSdk
|
protected boolean |
mMergeManifests
|
protected java.lang.String |
mName
|
protected java.util.List<java.io.File> |
mNonProvidedJavaLibraries
|
protected java.lang.String |
mPackage
|
protected java.util.List<java.io.File> |
mProguardFiles
|
protected java.lang.String |
mProguardPath
|
protected java.io.File |
mReferenceDir
|
protected boolean |
mReportIssues
|
protected java.util.List<java.io.File> |
mResourceFolders
|
protected SdkInfo |
mSdkInfo
The SDK info, if any |
protected java.lang.Boolean |
mSupportLib
|
protected com.android.sdklib.IAndroidTarget |
mTarget
|
protected java.util.List<java.io.File> |
mTestSourceFolders
|
Constructor Summary | |
---|---|
protected |
Project(LintClient client,
java.io.File dir,
java.io.File referenceDir)
Creates a new Project. |
Method Summary | |
---|---|
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(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.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.util.List<java.io.File> |
getAssetFolders()
Returns the asset folders. |
int |
getBuildSdk()
Returns the target API used to build the project, or -1 if not known |
com.android.sdklib.IAndroidTarget |
getBuildTarget()
Returns the target 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 |
LintClient |
getClient()
Returns the associated client |
com.android.sdklib.IAndroidTarget |
getCompileTarget()
Returns the compile target to use for this project |
Configuration |
getConfiguration(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> |
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.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. |
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.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.repository.ResourceVisibilityLookup |
getResourceVisibility()
Returns a shared ResourceVisibilityLookup |
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> |
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 |
isAospFrameworksProject(java.io.File dir)
Is this the frameworks AOSP project? Needs some hardcoded support since it doesn't have a manifest file, etc. |
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 |
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()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final LintClient mClient
protected final java.io.File mDir
protected final java.io.File mReferenceDir
protected Configuration mConfiguration
protected java.lang.String mPackage
protected int mBuildSdk
protected com.android.sdklib.IAndroidTarget mTarget
protected com.android.sdklib.AndroidVersion mManifestMinSdk
protected com.android.sdklib.AndroidVersion mManifestTargetSdk
protected boolean mLibrary
protected java.lang.String mName
protected java.lang.String mProguardPath
protected boolean mMergeManifests
protected SdkInfo mSdkInfo
protected java.util.List<java.io.File> mFiles
protected java.util.List<java.io.File> mProguardFiles
protected java.util.List<java.io.File> mGradleFiles
protected java.util.List<java.io.File> mManifestFiles
protected java.util.List<java.io.File> mJavaSourceFolders
protected java.util.List<java.io.File> mJavaClassFolders
protected java.util.List<java.io.File> mNonProvidedJavaLibraries
protected java.util.List<java.io.File> mJavaLibraries
protected java.util.List<java.io.File> mTestSourceFolders
protected java.util.List<java.io.File> mResourceFolders
protected java.util.List<java.io.File> mAssetFolders
protected java.util.List<Project> mDirectLibraries
protected java.util.List<Project> mAllLibraries
protected boolean mReportIssues
protected java.lang.Boolean mGradleProject
protected java.lang.Boolean mSupportLib
protected java.lang.Boolean mAppCompat
Constructor Detail |
---|
protected Project(@NonNull LintClient client, @NonNull java.io.File dir, @NonNull java.io.File referenceDir)
Method Detail |
---|
@NonNull public static Project create(@NonNull 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()
.
Project
public boolean isGradleProject()
public boolean isAndroidProject()
@Nullable public com.android.builder.model.AndroidProject getGradleProjectModel()
isGradleProject()
is true and isLibrary()
is false.
@Nullable public com.android.builder.model.AndroidLibrary getGradleLibraryModel()
isGradleProject()
and isLibrary()
return true.
@Nullable public com.android.builder.model.Variant getCurrentVariant()
protected void initialize()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(@Nullable java.lang.Object obj)
equals
in class java.lang.Object
public 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> 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> getResourceFolders()
@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 Configuration getConfiguration(@Nullable LintDriver driver)
driver
- the current driver, if any
@Nullable public java.lang.String getPackage()
@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()
@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()
@NonNull public java.util.List<Project> getDirectLibraries()
@NonNull public java.util.List<Project> getAllLibraries()
@NonNull public 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> 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 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 LintClient getClient()
@Nullable public com.android.sdklib.IAndroidTarget getCompileTarget()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |