use of com.android.tools.klint.client.api.CircularDependencyException in project kotlin by JetBrains.
the class Project method initialize.
protected void initialize() {
// Default initialization: Use ADT/ant style project.properties file
try {
// Read properties file and initialize library state
Properties properties = new Properties();
File propFile = new File(mDir, PROJECT_PROPERTIES);
if (propFile.exists()) {
BufferedInputStream is = new BufferedInputStream(new FileInputStream(propFile));
try {
properties.load(is);
String value = properties.getProperty(ANDROID_LIBRARY);
mLibrary = VALUE_TRUE.equals(value);
String proguardPath = properties.getProperty(PROGUARD_CONFIG);
if (proguardPath != null) {
mProguardPath = proguardPath;
}
mMergeManifests = VALUE_TRUE.equals(properties.getProperty(//$NON-NLS-1$
"manifestmerger.enabled"));
//$NON-NLS-1$
String target = properties.getProperty("target");
if (target != null) {
int index = target.lastIndexOf('-');
if (index == -1) {
index = target.lastIndexOf(':');
}
if (index != -1) {
String versionString = target.substring(index + 1);
try {
mBuildSdk = Integer.parseInt(versionString);
} catch (NumberFormatException nufe) {
mClient.log(Severity.WARNING, null, "Unexpected build target format: %1$s", target);
}
}
}
for (int i = 1; i < 1000; i++) {
String key = String.format(ANDROID_LIBRARY_REFERENCE_FORMAT, i);
String library = properties.getProperty(key);
if (library == null || library.isEmpty()) {
// No holes in the numbering sequence is allowed
break;
}
File libraryDir = new File(mDir, library).getCanonicalFile();
if (mDirectLibraries == null) {
mDirectLibraries = new ArrayList<Project>();
}
// Adjust the reference dir to be a proper prefix path of the
// library dir
File libraryReferenceDir = mReferenceDir;
if (!libraryDir.getPath().startsWith(mReferenceDir.getPath())) {
// Symlinks etc might have been resolved, so do those to
// the reference dir as well
libraryReferenceDir = libraryReferenceDir.getCanonicalFile();
if (!libraryDir.getPath().startsWith(mReferenceDir.getPath())) {
File file = libraryReferenceDir;
while (file != null && !file.getPath().isEmpty()) {
if (libraryDir.getPath().startsWith(file.getPath())) {
libraryReferenceDir = file;
break;
}
file = file.getParentFile();
}
}
}
try {
Project libraryPrj = mClient.getProject(libraryDir, libraryReferenceDir);
mDirectLibraries.add(libraryPrj);
// By default, we don't report issues in inferred library projects.
// The driver will set report = true for those library explicitly
// requested.
libraryPrj.setReportIssues(false);
} catch (CircularDependencyException e) {
e.setProject(this);
e.setLocation(Location.create(propFile));
throw e;
}
}
} finally {
try {
Closeables.close(is, true);
} catch (IOException e) {
// cannot happen
}
}
}
} catch (IOException ioe) {
mClient.log(ioe, "Initializing project state");
}
if (mDirectLibraries != null) {
mDirectLibraries = Collections.unmodifiableList(mDirectLibraries);
} else {
mDirectLibraries = Collections.emptyList();
}
if (isAospBuildEnvironment()) {
if (isAospFrameworksRelatedProject(mDir)) {
// No manifest file for this project: just init the manifest values here
mManifestMinSdk = mManifestTargetSdk = new AndroidVersion(HIGHEST_KNOWN_API, null);
} else if (mBuildSdk == -1) {
// only set BuildSdk for projects other than frameworks and
// the ones that don't have one set in project.properties.
mBuildSdk = getClient().getHighestKnownApiLevel();
}
}
}
Aggregations