use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class ContentRootsModuleSetupStep method findContentEntries.
@NotNull
private static List<ContentEntry> findContentEntries(@NotNull ModifiableRootModel moduleModel, @NotNull AndroidModuleModel androidModel, boolean hasNativeModel) {
if (!hasNativeModel) {
removeExistingContentEntries(moduleModel);
}
List<ContentEntry> contentEntries = new ArrayList<>();
ContentEntry contentEntry = moduleModel.addContentEntry(androidModel.getRootDir());
contentEntries.add(contentEntry);
File buildFolderPath = androidModel.getAndroidProject().getBuildFolder();
if (!isAncestor(androidModel.getRootDirPath(), buildFolderPath, false)) {
contentEntries.add(moduleModel.addContentEntry(pathToIdeaUrl(buildFolderPath)));
}
return contentEntries;
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class DependenciesModuleSetupStep method updateLibraryDependency.
public void updateLibraryDependency(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull LibraryDependency dependency, @NotNull AndroidProject androidProject) {
String name = dependency.getName();
DependencyScope scope = dependency.getScope();
myDependenciesSetup.setUpLibraryDependency(module, modelsProvider, name, scope, dependency.getArtifactPath(), dependency.getPaths(BINARY), dependency.getPaths(DOCUMENTATION));
File buildFolder = androidProject.getBuildFolder();
// Exclude jar files that are in "jars" folder in "build" folder.
// see https://code.google.com/p/android/issues/detail?id=123788
ContentEntry[] contentEntries = modelsProvider.getModifiableRootModel(module).getContentEntries();
if (contentEntries.length > 0) {
for (File binaryPath : dependency.getPaths(BINARY)) {
File parent = binaryPath.getParentFile();
if (parent != null && FD_JARS.equals(parent.getName()) && isAncestor(buildFolder, parent, true)) {
ContentEntry parentContentEntry = findParentContentEntry(parent, contentEntries);
if (parentContentEntry != null) {
parentContentEntry.addExcludeFolder(pathToIdeaUrl(parent));
}
}
}
}
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class AndroidContentEntriesSetup method addExcludedOutputFolders.
private void addExcludedOutputFolders(@NotNull List<ContentEntry> contentEntries) {
File buildFolderPath = getAndroidProject().getBuildFolder();
ContentEntry parentContentEntry = findParentContentEntry(buildFolderPath, contentEntries);
if (parentContentEntry != null) {
List<File> excludedFolderPaths = myAndroidModel.getExcludedFolderPaths();
for (File folderPath : excludedFolderPaths) {
addExcludedFolder(parentContentEntry, folderPath);
}
}
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class JavaContentEntriesSetup method execute.
@Override
public void execute(@NotNull List<ContentEntry> contentEntries) {
boolean isTopLevelJavaModule = isGradleProjectModule(getModule());
File buildFolderPath = myJavaModuleModel.getBuildFolderPath();
boolean buildFolderExcluded = buildFolderPath != null;
for (JavaModuleContentRoot contentRoot : myJavaModuleModel.getContentRoots()) {
if (contentRoot == null) {
continue;
}
addSourceFolders(contentRoot.getSourceDirPaths(), contentEntries, SOURCE, false);
addSourceFolders(contentRoot.getGenSourceDirPaths(), contentEntries, SOURCE, true);
addSourceFolders(contentRoot.getResourceDirPaths(), contentEntries, RESOURCE, false);
addSourceFolders(contentRoot.getTestDirPaths(), contentEntries, TEST_SOURCE, false);
addSourceFolders(contentRoot.getGenTestDirPaths(), contentEntries, TEST_SOURCE, true);
addSourceFolders(contentRoot.getTestResourceDirPaths(), contentEntries, TEST_RESOURCE, false);
for (File excluded : contentRoot.getExcludeDirPaths()) {
ContentEntry contentEntry = findParentContentEntry(excluded, contentEntries);
if (contentEntry != null) {
if (isTopLevelJavaModule && buildFolderExcluded) {
// We need to "undo" the implicit exclusion of "build" folder for top-level module.
if (filesEqual(excluded, buildFolderPath)) {
buildFolderExcluded = true;
continue;
}
}
addExcludedFolder(contentEntry, excluded);
}
}
}
addOrphans();
}
use of com.intellij.openapi.roots.ContentEntry 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