use of com.intellij.openapi.roots.ModifiableRootModel in project android by JetBrains.
the class ContentRootModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull NdkModuleModel ndkModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
ModifiableRootModel moduleModel = ideModelsProvider.getModifiableRootModel(module);
NdkContentEntriesSetup setup = new NdkContentEntriesSetup(ndkModuleModel, moduleModel);
List<ContentEntry> contentEntries = findContentEntries(moduleModel, ndkModuleModel);
setup.execute(contentEntries);
}
use of com.intellij.openapi.roots.ModifiableRootModel 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.intellij.openapi.roots.ModifiableRootModel in project android by JetBrains.
the class CompilerOutputModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull AndroidModuleModel androidModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
GradleVersion modelVersion = androidModel.getModelVersion();
if (modelVersion == null) {
// We are dealing with old model that does not have the 'class' folder.
return;
}
Variant selectedVariant = androidModel.getSelectedVariant();
File mainClassesFolder = selectedVariant.getMainArtifact().getClassesFolder();
JavaArtifact testArtifact = androidModel.getUnitTestArtifactInSelectedVariant();
File testClassesFolder = testArtifact == null ? null : testArtifact.getClassesFolder();
ModifiableRootModel rootModel = ideModelsProvider.getModifiableRootModel(module);
myCompilerSettingsSetup.setOutputPaths(rootModel, mainClassesFolder, testClassesFolder);
}
use of com.intellij.openapi.roots.ModifiableRootModel in project android by JetBrains.
the class ArtifactsByConfigurationModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull JavaModuleModel javaModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
ModifiableRootModel moduleModel = ideModelsProvider.getModifiableRootModel(module);
for (Map.Entry<String, Set<File>> entry : javaModuleModel.getArtifactsByConfiguration().entrySet()) {
Set<File> artifacts = entry.getValue();
if (artifacts != null && !artifacts.isEmpty()) {
for (File artifact : artifacts) {
if (!artifact.isFile() || !endsWithIgnoreCase(artifact.getName(), DOT_JAR)) {
// We only expose artifacts that are jar files.
continue;
}
File buildFolderPath = javaModuleModel.getBuildFolderPath();
String artifactName = getNameWithoutExtension(artifact);
if (buildFolderPath != null && buildFolderPath.isDirectory() && isAncestor(buildFolderPath, artifact, true) && module.getName().equals(artifactName)) {
// This is the jar obtained by compiling the module, no need to add it as dependency.
continue;
}
String libraryName = module.getName() + "." + artifactName;
Library library = ideModelsProvider.getLibraryByName(libraryName);
if (library == null) {
// Create library.
library = ideModelsProvider.createLibrary(libraryName);
Library.ModifiableModel libraryModel = ideModelsProvider.getModifiableLibraryModel(library);
String url = pathToIdeaUrl(artifact);
libraryModel.addRoot(url, CLASSES);
} else {
SyncLibraryRegistry.getInstance(module.getProject()).markAsUsed(library, artifact);
}
LibraryOrderEntry orderEntry = moduleModel.addLibraryEntry(library);
orderEntry.setScope(COMPILE);
orderEntry.setExported(true);
}
}
}
}
use of com.intellij.openapi.roots.ModifiableRootModel in project android by JetBrains.
the class JavaModuleSetup method cleanUpAndroidModuleWithoutVariants.
private static void cleanUpAndroidModuleWithoutVariants(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider) {
// Remove Android facet, otherwise the IDE will try to build the module, and fail. The facet may have been added in a previous
// successful commit.
removeAllFacets(ideModelsProvider.getModifiableFacetModel(module), AndroidFacet.ID);
// Clear all source and exclude folders.
ModifiableRootModel rootModel = ideModelsProvider.getModifiableRootModel(module);
for (ContentEntry contentEntry : rootModel.getContentEntries()) {
contentEntry.clearSourceFolders();
contentEntry.clearExcludeFolders();
}
}
Aggregations