当前位置: 首页>>代码示例>>Java>>正文


Java AndroidFacet.isGradleProject方法代码示例

本文整理汇总了Java中org.jetbrains.android.facet.AndroidFacet.isGradleProject方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidFacet.isGradleProject方法的具体用法?Java AndroidFacet.isGradleProject怎么用?Java AndroidFacet.isGradleProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jetbrains.android.facet.AndroidFacet的用法示例。


在下文中一共展示了AndroidFacet.isGradleProject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: moduleRootsChanged

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
/**
 * Called when module roots have changed in the given module. Locates the
 * {@linkplain ProjectResourceRepository} instance (but only if it has
 * already been initialized) and updates its roots, if necessary.
 * <p>
 * TODO: Currently, this method is only called during a Gradle project import.
 * We should call it for non-Gradle projects after modules are changed in the
 * project structure dialog etc. with
 *   project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { ... }
 *
 * @param module the module whose roots changed
 */
private static void moduleRootsChanged(@NotNull Module module) {
  AndroidFacet facet = AndroidFacet.getInstance(module);
  if (facet != null) {
    if (facet.isGradleProject() && facet.getIdeaAndroidProject() == null) {
      // Project not yet fully initialized; no need to do a sync now because our
      // GradleProjectAvailableListener will be called as soon as it is and do a proper sync
      return;
    }
    ProjectResourceRepository projectResources = getProjectResources(facet, false);
    if (projectResources != null) {
      projectResources.updateRoots();

      AppResourceRepository appResources = AppResourceRepository.getAppResources(facet, false);
      if (appResources != null) {
        appResources.invalidateCache(projectResources);
        appResources.updateRoots();
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ProjectResourceRepository.java

示例2: getLocalXmlNamespace

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Nullable
public static String getLocalXmlNamespace(@NotNull AndroidFacet facet) {
  if (facet.isLibraryProject() || facet.isGradleProject()) {
    return SdkConstants.AUTO_URI;
  }
  final Manifest manifest = facet.getManifest();
  if (manifest != null) {
    String aPackage = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
      @Override
      @Nullable
      public String compute() {
        return manifest.getPackage().getValue();
      }
    });
    if (aPackage != null && aPackage.length() != 0) {
      return SdkConstants.URI_PREFIX + aPackage;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AndroidXmlSchemaProvider.java

示例3: updateSourceSetCombo

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public static void updateSourceSetCombo(@NotNull JComponent label, @NotNull JComboBox combo, @Nullable AndroidFacet facet,
                                        @SuppressWarnings("UnusedParameters") @Nullable PsiDirectory resDirectory) {
  // Ideally, if we're in the Project View and you select a file under main/res, we already know that
  // the resource folder is "res" and we pass it in here -- and we shouldn't ask the user for a source set.
  // However, in the Android Project view there is only a single "res" node, shared by multiple possible source
  // sets, so we *always* want to ask for the target source set there. We don't have a way to know which view
  // we're in here, so we default to always including the source set combo (if it's a Gradle project that is.)
  if (/*resDirectory == null && */ facet != null && facet.isGradleProject() && facet.getIdeaAndroidProject() != null) {
    List<SourceProvider> providers = IdeaSourceProvider.getAllSourceProviders(facet);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (SourceProvider sourceProvider : providers) {
      //noinspection unchecked
      model.addElement(new ComboBoxItem(sourceProvider, sourceProvider.getName(), 0, 0));
    }
    combo.setModel(model);

    label.setVisible(true);
    combo.setVisible(true);
  } else {
    label.setVisible(false);
    combo.setVisible(false);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CreateResourceActionBase.java

示例4: isAvailable

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
private static boolean isAvailable(DataContext dataContext) {
  final Module module = LangDataKeys.MODULE.getData(dataContext);
  final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);

  if (module == null ||
      view == null ||
      view.getDirectories().length == 0) {
    return false;
  }
  final AndroidFacet facet = AndroidFacet.getInstance(module);

  if (facet == null || facet.isGradleProject()) {
    return false;
  }
  final ProjectFileIndex projectIndex = ProjectRootManager.getInstance(module.getProject()).getFileIndex();
  final JavaDirectoryService dirService = JavaDirectoryService.getInstance();

  for (PsiDirectory dir : view.getDirectories()) {
    if (projectIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) &&
        dirService.getPackage(dir) != null) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:LegacyNewAndroidComponentAction.java

示例5: supportsRunningLibraryProjects

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Override
protected Pair<Boolean, String> supportsRunningLibraryProjects(@NotNull AndroidFacet facet) {
  if (!facet.isGradleProject()) {
    // Non Gradle projects always require an application
    return Pair.create(Boolean.FALSE, AndroidBundle.message("android.cannot.run.library.project.error"));
  }

  final IdeaAndroidProject project = facet.getIdeaAndroidProject();
  if (project == null) {
    return Pair.create(Boolean.FALSE, AndroidBundle.message("android.cannot.run.library.project.error"));
  }

  // Gradle only supports testing against a single build type (which could be anything, but is "debug" build type by default)
  // Currently, the only information the model exports that we can use to detect whether the current build type
  // is testable is by looking at the test task name and checking whether it is null.
  BaseArtifact testArtifact = project.findSelectedTestArtifactInSelectedVariant();
  String testTask = testArtifact != null ? testArtifact.getAssembleTaskName() : null;
  return new Pair<Boolean, String>(testTask != null, AndroidBundle.message("android.cannot.run.library.project.in.this.buildtype"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidTestRunConfiguration.java

示例6: getModulesIfProjectSupportsUnitTests

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@NotNull
private List<Module> getModulesIfProjectSupportsUnitTests() {
  FullRevision minimumSupportedVersion = new PreciseRevision(1, 1, 0);

  List<Module> modules = Lists.newArrayList();
  for (Module module : ModuleManager.getInstance(myProject).getModules()) {
    AndroidFacet androidFacet = AndroidFacet.getInstance(module);
    if (androidFacet != null && androidFacet.isGradleProject()) {
      IdeaAndroidProject ideaAndroidProject = androidFacet.getIdeaAndroidProject();
      if (ideaAndroidProject != null) {
        if (!supportsUnitTests(ideaAndroidProject.getDelegate(), minimumSupportedVersion)) {
          return Collections.emptyList();
        }
        modules.add(module);
      }
    }
  }
  return modules;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:BuildVariantView.java

示例7: getGradleModulesWithAndroidProjects

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@NotNull
private List<Module> getGradleModulesWithAndroidProjects() {
  List<Module> gradleModules = Lists.newArrayList();
  for (Module module : ModuleManager.getInstance(myProject).getModules()) {
    AndroidFacet androidFacet = AndroidFacet.getInstance(module);
    if (androidFacet != null && androidFacet.isGradleProject() && androidFacet.getIdeaAndroidProject() != null) {
      gradleModules.add(module);
    }
  }

  if (!gradleModules.isEmpty()) {
    Collections.sort(gradleModules, ModuleTypeComparator.INSTANCE);
    return gradleModules;
  }
  return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BuildVariantView.java

示例8: ensureXposedBridgeDependency

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public boolean ensureXposedBridgeDependency() {
    AndroidFacet androidFacet = AndroidFacet.getInstance(mModule);
    if (androidFacet == null) {
        LOG.error("No Android facet found in module");
        return false;
    }

    if (androidFacet.isGradleProject()) {
        return addGradleBuildDependency();
    } else {
        return addIdeaLibraryDependency(androidFacet);
    }
}
 
开发者ID:apsun,项目名称:XposedPlugin,代码行数:14,代码来源:XposedBridgeDependencyManager.java

示例9: isGradleProject

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Override
public boolean isGradleProject(com.android.tools.lint.detector.api.Project project) {
  Module module = getModule();
  if (module != null) {
    AndroidFacet facet = AndroidFacet.getInstance(module);
    return facet != null && facet.isGradleProject();
  }
  return Projects.isGradleProject(myProject);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:IntellijLintClient.java

示例10: getAndroidProjectForModule

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@NotNull
public IdeaAndroidProject getAndroidProjectForModule(@NotNull String name) {
  Module module = getModule(name);
  AndroidFacet facet = AndroidFacet.getInstance(module);
  if (facet != null && facet.isGradleProject()) {
    IdeaAndroidProject androidProject = facet.getIdeaAndroidProject();
    if (androidProject != null) {
      return androidProject;
    }
  }
  throw new AssertionError("Unable to find IdeaAndroidProject for module " + quote(name));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:IdeFrameFixture.java

示例11: getState

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Override
public AndroidRunningState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  final AndroidRunningState state = super.getState(executor, env);

  if (state == null) {
    return null;
  }

  final AndroidFacet facet = state.getFacet();
  final AndroidFacetConfiguration configuration = facet.getConfiguration();

  if (!facet.isGradleProject() && !configuration.getState().PACK_TEST_CODE) {
    final Module module = facet.getModule();
    final int count = getTestSourceRootCount(module);
    
    if (count > 0) {
      final String message = "Code and resources under test source " + (count > 1 ? "roots" : "root") +
                             " aren't included into debug APK.\nWould you like to include them and recompile " +
                             module.getName() + " module?" + "\n(You may change this option in Android facet settings later)";
      final int result =
        Messages.showYesNoCancelDialog(getProject(), message, "Test code not included into APK", Messages.getQuestionIcon());
      
      if (result == Messages.YES) {
        configuration.getState().PACK_TEST_CODE = true;
      }
      else if (result == Messages.CANCEL) {
        return null;
      }
    }
  }
  return state;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:AndroidTestRunConfiguration.java

示例12: getAndroidProject

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Nullable
private static IdeaAndroidProject getAndroidProject(@NotNull Module module) {
  AndroidFacet facet = AndroidFacet.getInstance(module);
  if (facet == null || !facet.isGradleProject()) {
    return null;
  }
  return facet.getIdeaAndroidProject();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ConflictSet.java

示例13: solveSelectionConflict

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
private static boolean solveSelectionConflict(@NotNull Conflict conflict, boolean showConflictResolutionDialog) {
  AndroidFacet facet = AndroidFacet.getInstance(conflict.getSource());
  if (facet == null || !facet.isGradleProject()) {
    // project structure may have changed and the conflict is not longer applicable.
    return true;
  }
  IdeaAndroidProject source = facet.getIdeaAndroidProject();
  if (source == null) {
    return false;
  }
  Collection<String> variants = conflict.getVariants();
  if (variants.size() == 1) {
    String expectedVariant = ContainerUtil.getFirstItem(variants);
    if (StringUtil.isNotEmpty(expectedVariant)) {
      source.setSelectedVariantName(expectedVariant);
      facet.syncSelectedVariantAndTestArtifact();
      return true;
    }
  }
  else if (showConflictResolutionDialog) {
    ConflictResolutionDialog dialog = new ConflictResolutionDialog(conflict);
    if (dialog.showAndGet()) {
      String selectedVariant = dialog.getSelectedVariant();
      if (StringUtil.isNotEmpty(selectedVariant)) {
        source.setSelectedVariantName(selectedVariant);
        facet.syncSelectedVariantAndTestArtifact();
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ConflictResolution.java

示例14: isManifestFile

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public static boolean isManifestFile(@NotNull XmlFile file, @NotNull AndroidFacet facet) {
  return file.getName().equals(FN_ANDROID_MANIFEST_XML) ||
         facet.isGradleProject() && IdeaSourceProvider.isManifestFile(facet, file.getVirtualFile());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:ManifestDomFileDescription.java

示例15: loadClassFromModule

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Nullable
private Class<?> loadClassFromModule(Module module, String name) {
  final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
  if (extension == null) {
    return null;
  }

  VirtualFile vOutFolder = extension.getCompilerOutputPath();
  if (vOutFolder == null) {
    AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet != null && facet.isGradleProject()) {
      // Try a bit harder; we don't have a compiler module extension or mechanism
      // to query this yet, so just hardcode it (ugh!)
      IdeaAndroidProject gradleProject = facet.getIdeaAndroidProject();
      if (gradleProject != null) {
        Variant variant = gradleProject.getSelectedVariant();
        String variantName = variant.getName();
        AndroidArtifact mainArtifactInfo = variant.getMainArtifact();
        File classesFolder = mainArtifactInfo.getClassesFolder();

        // Older models may not supply it; in that case, we rely on looking relative
        // to the .APK file location:
        //noinspection ConstantConditions
        if (classesFolder == null) {
          @SuppressWarnings("deprecation")  // For getOutput()
          AndroidArtifactOutput output = GradleUtil.getOutput(mainArtifactInfo);
          File file = output.getMainOutputFile().getOutputFile();
          File buildFolder = file.getParentFile().getParentFile();
          classesFolder = new File(buildFolder, "classes"); // See AndroidContentRoot
        }

        File outFolder = new File(classesFolder,
                                  // Change variant name variant-release into variant/release directories
                                  variantName.replace('-', File.separatorChar));
        if (outFolder.exists()) {
          vOutFolder = LocalFileSystem.getInstance().findFileByIoFile(outFolder);
          if (vOutFolder != null) {
            Class<?> localClass = loadClassFromClassPath(name, VfsUtilCore.virtualToIoFile(vOutFolder));
            if (localClass != null) {
              return localClass;
            }
          }
        }
      }
    }
    return null;
  }

  return loadClassFromClassPath(name, VfsUtilCore.virtualToIoFile(vOutFolder));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:51,代码来源:ModuleClassLoader.java


注:本文中的org.jetbrains.android.facet.AndroidFacet.isGradleProject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。