Search in sources :

Example 1 with AdtImportBuilder

use of com.android.tools.idea.gradle.eclipse.AdtImportBuilder in project android by JetBrains.

the class AdtModuleImporter method importProjects.

@Override
public void importProjects(Map<String, VirtualFile> projects) {
    Project project = myContext.getProject();
    assert project != null;
    AdtImportBuilder builder = AdtImportBuilder.getBuilder(myContext);
    assert builder != null;
    GradleImport importer = getGradleImport();
    ImmutableMap.Builder<File, String> modules = ImmutableMap.builder();
    for (Map.Entry<String, VirtualFile> entry : projects.entrySet()) {
        modules.put(virtualToIoFile(entry.getValue()), getDefaultPhysicalPathFromGradlePath(entry.getKey()));
    }
    importer.setImportModuleNames(modules.build());
    if (builder.validate(null, project)) {
        builder.commit(project, null, ModulesProvider.EMPTY_MODULES_PROVIDER, null);
        builder.cleanup();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) AdtImportBuilder(com.android.tools.idea.gradle.eclipse.AdtImportBuilder) GradleImport(com.android.tools.idea.gradle.eclipse.GradleImport) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) VfsUtil.findFileByIoFile(com.intellij.openapi.vfs.VfsUtil.findFileByIoFile) File(java.io.File) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with AdtImportBuilder

use of com.android.tools.idea.gradle.eclipse.AdtImportBuilder in project android by JetBrains.

the class AdtModuleImporter method findModules.

@Override
@NotNull
public Set<ModuleToImport> findModules(@NotNull VirtualFile importSource) throws IOException {
    final AdtImportBuilder builder = (AdtImportBuilder) myContext.getProjectBuilder();
    assert builder != null;
    builder.setSelectedProject(virtualToIoFile(importSource));
    final GradleImport gradleImport = getGradleImport();
    gradleImport.importProjects(Collections.singletonList(virtualToIoFile(importSource)));
    Map<String, File> adtProjects = gradleImport.getDetectedModuleLocations();
    Set<ModuleToImport> modules = Sets.newHashSet();
    for (final Map.Entry<String, File> entry : adtProjects.entrySet()) {
        VirtualFile location = findFileByIoFile(entry.getValue(), false);
        modules.add(new ModuleToImport(entry.getKey(), location, new Supplier<Iterable<String>>() {

            @Override
            public Iterable<String> get() {
                return gradleImport.getProjectDependencies(entry.getKey());
            }
        }));
    }
    return modules;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AdtImportBuilder(com.android.tools.idea.gradle.eclipse.AdtImportBuilder) GradleImport(com.android.tools.idea.gradle.eclipse.GradleImport) Supplier(com.google.common.base.Supplier) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) VfsUtil.findFileByIoFile(com.intellij.openapi.vfs.VfsUtil.findFileByIoFile) File(java.io.File) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with AdtImportBuilder

use of com.android.tools.idea.gradle.eclipse.AdtImportBuilder in project android by JetBrains.

the class AdtModuleImporter method getGradleImport.

@NotNull
private GradleImport getGradleImport() {
    AdtImportBuilder builder = AdtImportBuilder.getBuilder(myContext);
    assert builder != null;
    GradleImport importer = builder.getImporter();
    assert importer != null;
    return importer;
}
Also used : AdtImportBuilder(com.android.tools.idea.gradle.eclipse.AdtImportBuilder) GradleImport(com.android.tools.idea.gradle.eclipse.GradleImport) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AdtImportBuilder (com.android.tools.idea.gradle.eclipse.AdtImportBuilder)3 GradleImport (com.android.tools.idea.gradle.eclipse.GradleImport)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 Map (java.util.Map)2 NotNull (org.jetbrains.annotations.NotNull)2 Supplier (com.google.common.base.Supplier)1 Project (com.intellij.openapi.project.Project)1