org.jetbrains.plugins.gradle.settings.GradleProjectSettings Java Examples

The following examples show how to use org.jetbrains.plugins.gradle.settings.GradleProjectSettings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectBuildModel.java    From ok-gradle with Apache License 2.0 6 votes vote down vote up
/**
 * This method returns a list of all participating {@link ProjectBuildModel} from a given {@link Project}. This includes any included
 * builds. No ordering is guaranteed.
 * <p>
 * This method should never be called on the UI thread, it will cause the parsing of Gradle build files which can take a long time.
 * The returned {@link ProjectBuildModel} is not thread safe.
 *
 * @param project the project to obtain all the {@link ProjectBuildModel}s for
 * @return a list of all {@link ProjectBuildModel}s
 */
@NotNull
static List<ProjectBuildModel> getForIncludedBuilds(@NotNull Project project) {
  List<ProjectBuildModel> result = new ArrayList<>();
  result.add(get(project));

  String basePath = project.getBasePath();
  if (basePath == null) {
    return result;
  }

  GradleProjectSettings settings = GradleSettings.getInstance(project).getLinkedProjectSettings(basePath);
  if (settings == null) {
    return result;
  }

  GradleProjectSettings.CompositeBuild compositeBuild = settings.getCompositeBuild();
  if (compositeBuild == null) {
    return result;
  }

  compositeBuild.getCompositeParticipants().stream().map(build -> build.getRootPath())
    .forEach(path -> result.add(getForCompositeBuild(project, path)));
  return result;
}
 
Example #2
Source File: GradleImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
  assumeThat(gradleVersion, versionMatcherRule.getMatcher());
  myJdkHome = IdeaTestUtil.requireRealJdkHome();
  super.setUp();
  WriteAction.runAndWait(() -> {
    Sdk oldJdk = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME);
    if (oldJdk != null) {
      ProjectJdkTable.getInstance().removeJdk(oldJdk);
    }
    VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome));
    JavaSdk javaSdk = JavaSdk.getInstance();
    SdkType javaSdkType = javaSdk == null ? SimpleJavaSdkType.getInstance() : javaSdk;
    Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, javaSdkType, true, null, GRADLE_JDK_NAME);
    assertNotNull("Cannot create JDK for " + myJdkHome, jdk);
    ProjectJdkTable.getInstance().addJdk(jdk);
  });
  myProjectSettings = new GradleProjectSettings().withQualifiedModuleNames();
  System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS));
  PathAssembler.LocalDistribution distribution = configureWrapper();

  List<String> allowedRoots = new ArrayList<>();
  collectAllowedRoots(allowedRoots, distribution);
  if (!allowedRoots.isEmpty()) {
    VfsRootAccess.allowRootAccess(myTestFixture.getTestRootDisposable(), ArrayUtil.toStringArray(allowedRoots));
  }
}
 
Example #3
Source File: GradleImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void importProject() {
  ExternalSystemApiUtil.subscribe(myProject, GradleConstants.SYSTEM_ID, new ExternalSystemSettingsListenerAdapter() {
    @Override
    public void onProjectsLinked(@NotNull Collection settings) {
      final Object item = ContainerUtil.getFirstItem(settings);
      if (item instanceof GradleProjectSettings) {
        ((GradleProjectSettings)item).setGradleJvm(GRADLE_JDK_NAME);
      }
    }
  });
  super.importProject();
}
 
Example #4
Source File: IdeaFrameFixture.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
public IdeaFrameFixture useLocalGradleDistribution(@NotNull String gradleHome) {
  GradleProjectSettings settings = getGradleSettings();
  settings.setDistributionType(LOCAL);
  settings.setGradleHome(gradleHome);
  return this;
}
 
Example #5
Source File: AndroidUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@SuppressWarnings("DuplicatedCode")
private static Map<ProjectData, MultiMap<String, String>> getTasksMap(Project project) {
  Map<ProjectData, MultiMap<String, String>> tasks = new LinkedHashMap<>();
  for (GradleProjectSettings setting : GradleSettings.getInstance(project).getLinkedProjectsSettings()) {
    final ExternalProjectInfo projectData =
      ProjectDataManager.getInstance().getExternalProjectData(project, GradleConstants.SYSTEM_ID, setting.getExternalProjectPath());
    if (projectData == null || projectData.getExternalProjectStructure() == null) continue;

    MultiMap<String, String> projectTasks = MultiMap.createOrderedSet();
    for (DataNode<ModuleData> moduleDataNode : getChildren(projectData.getExternalProjectStructure(), ProjectKeys.MODULE)) {
      String gradlePath;
      String moduleId = moduleDataNode.getData().getId();
      if (moduleId.charAt(0) != ':') {
        int colonIndex = moduleId.indexOf(':');
        gradlePath = colonIndex > 0 ? moduleId.substring(colonIndex) : ":";
      }
      else {
        gradlePath = moduleId;
      }
      for (DataNode<TaskData> node : getChildren(moduleDataNode, ProjectKeys.TASK)) {
        TaskData taskData = node.getData();
        String taskName = taskData.getName();
        if (isNotEmpty(taskName)) {
          String taskPathPrefix = ":".equals(gradlePath) || taskName.startsWith(gradlePath) ? "" : (gradlePath + ':');
          projectTasks.putValue(taskPathPrefix, taskName);
        }
      }
    }
    tasks.put(projectData.getExternalProjectStructure().getData(), projectTasks);
  }
  return tasks;
}
 
Example #6
Source File: AndroidUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@SuppressWarnings("DuplicatedCode")
private static Map<ProjectData, MultiMap<String, String>> getTasksMap(Project project) {
  Map<ProjectData, MultiMap<String, String>> tasks = new LinkedHashMap<>();
  for (GradleProjectSettings setting : GradleSettings.getInstance(project).getLinkedProjectsSettings()) {
    final ExternalProjectInfo projectData =
      ProjectDataManager.getInstance().getExternalProjectData(project, GradleConstants.SYSTEM_ID, setting.getExternalProjectPath());
    if (projectData == null || projectData.getExternalProjectStructure() == null) continue;

    MultiMap<String, String> projectTasks = MultiMap.createOrderedSet();
    for (DataNode<ModuleData> moduleDataNode : getChildren(projectData.getExternalProjectStructure(), ProjectKeys.MODULE)) {
      String gradlePath;
      String moduleId = moduleDataNode.getData().getId();
      if (moduleId.charAt(0) != ':') {
        int colonIndex = moduleId.indexOf(':');
        gradlePath = colonIndex > 0 ? moduleId.substring(colonIndex) : ":";
      }
      else {
        gradlePath = moduleId;
      }
      for (DataNode<TaskData> node : getChildren(moduleDataNode, ProjectKeys.TASK)) {
        TaskData taskData = node.getData();
        String taskName = taskData.getName();
        if (isNotEmpty(taskName)) {
          String taskPathPrefix = ":".equals(gradlePath) || taskName.startsWith(gradlePath) ? "" : (gradlePath + ':');
          projectTasks.putValue(taskPathPrefix, taskName);
        }
      }
    }
    tasks.put(projectData.getExternalProjectStructure().getData(), projectTasks);
  }
  return tasks;
}
 
Example #7
Source File: GradleImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected GradleProjectSettings getCurrentExternalProjectSettings() {
  return myProjectSettings;
}
 
Example #8
Source File: IdeaFrameFixture.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
public GradleProjectSettings getGradleSettings() {
  return GradleProjectSettingsFinder.getInstance().findGradleProjectSettings(getProject());
}