use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class AppResourceRepository method getResourceVisibility.
@NotNull
public ResourceVisibilityLookup getResourceVisibility(@NotNull AndroidFacet facet) {
// TODO: b/23032391
AndroidModuleModel androidModel = AndroidModuleModel.get(facet);
if (androidModel != null) {
ResourceVisibilityLookup.Provider provider = getResourceVisibilityProvider();
if (provider != null) {
AndroidProject androidProject = androidModel.getAndroidProject();
Variant variant = androidModel.getSelectedVariant();
return provider.get(androidProject, variant);
}
}
return ResourceVisibilityLookup.NONE;
}
use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class DependenciesModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull AndroidModuleModel androidModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
AndroidProject androidProject = androidModel.getAndroidProject();
DependencySet dependencies = myDependenciesExtractor.extractFrom(androidModel);
for (LibraryDependency dependency : dependencies.onLibraries()) {
updateLibraryDependency(module, ideModelsProvider, dependency, androidProject);
}
for (ModuleDependency dependency : dependencies.onModules()) {
updateModuleDependency(module, ideModelsProvider, dependency, androidProject);
}
addExtraSdkLibrariesAsDependencies(module, ideModelsProvider, androidProject);
Collection<SyncIssue> syncIssues = androidModel.getSyncIssues();
if (syncIssues != null) {
SyncIssuesReporter.getInstance().report(syncIssues, module);
} else {
//noinspection deprecation
Collection<String> unresolvedDependencies = androidProject.getUnresolvedDependencies();
UnresolvedDependenciesReporter.getInstance().report(unresolvedDependencies, module);
}
}
use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class JdkModuleSetupStep method setUpInAndroidStudio.
@VisibleForTesting
void setUpInAndroidStudio(@NotNull Module module, @NotNull AndroidModuleModel androidModel) {
AndroidProject androidProject = androidModel.getAndroidProject();
String compileTarget = androidProject.getCompileTarget();
AndroidVersion version = AndroidTargetHash.getPlatformVersion(compileTarget);
if (version != null && version.getFeatureLevel() >= 21) {
Sdk jdk = myIdeSdks.getJdk();
if (jdk != null && !myJdks.isApplicableJdk(jdk, JDK_1_7)) {
Project project = module.getProject();
SyncMessage msg;
String text = "compileSdkVersion " + compileTarget + " requires compiling with JDK 7 or newer.";
VirtualFile buildFile = getGradleBuildFile(module);
if (buildFile != null) {
msg = reportWrongJdkError(project, text, buildFile);
} else {
msg = reportWrongJdkError(project, text);
}
SyncMessages.getInstance(project).report(msg);
GradleSyncState.getInstance(project).getSummary().setWrongJdkFound(true);
}
}
}
use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class SdkModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull AndroidModuleModel androidModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
File androidSdkHomePath = IdeSdks.getInstance().getAndroidSdkPath();
// Android SDK may be not configured in IntelliJ
if (androidSdkHomePath == null) {
assert !IdeInfo.getInstance().isAndroidStudio();
logAndroidSdkHomeNotFound();
return;
}
ModifiableRootModel moduleModel = ideModelsProvider.getModifiableRootModel(module);
LanguageLevel languageLevel = androidModel.getJavaLanguageLevel();
if (languageLevel != null) {
moduleModel.getModuleExtension(LanguageLevelModuleExtensionImpl.class).setLanguageLevel(languageLevel);
}
AndroidProject androidProject = androidModel.getAndroidProject();
String compileTarget = androidProject.getCompileTarget();
Sdk sdk = myAndroidSdks.findSuitableAndroidSdk(compileTarget);
if (sdk == null) {
sdk = myAndroidSdks.tryToCreate(androidSdkHomePath, compileTarget);
if (sdk == null) {
// If SDK was not created, this might be an add-on.
sdk = findMatchingSdkForAddon(androidProject);
}
}
if (sdk == null) {
showPlatformNotFoundError(module, compileTarget);
return;
}
moduleModel.setSdk(sdk);
String sdkPath = sdk.getHomePath();
if (sdkPath == null) {
sdkPath = "<path not set>";
}
getLog().info(String.format("Set Android SDK '%1$s' (%2$s) to module '%3$s'", sdk.getName(), sdkPath, module.getName()));
}
use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class AndroidGradleProjectResolver method createModule.
@Override
@NotNull
public DataNode<ModuleData> createModule(@NotNull IdeaModule gradleModule, @NotNull DataNode<ProjectData> projectDataNode) {
AndroidProject androidProject = resolverCtx.getExtraProject(gradleModule, AndroidProject.class);
if (androidProject != null && !isSupportedVersion(androidProject)) {
AndroidStudioEvent.Builder event = AndroidStudioEvent.newBuilder();
// @formatter:off
event.setCategory(GRADLE_SYNC).setKind(GRADLE_SYNC_FAILURE).setGradleSyncFailure(UNSUPPORTED_ANDROID_MODEL_VERSION).setGradleVersion(androidProject.getModelVersion());
// @formatter:on
UsageTracker.getInstance().log(event);
String msg = getUnsupportedModelVersionErrorMsg(getModelVersion(androidProject));
throw new IllegalStateException(msg);
}
if (isAndroidGradleProject()) {
return doCreateModule(gradleModule, projectDataNode);
} else {
return nextResolver.createModule(gradleModule, projectDataNode);
}
}
Aggregations