org.jetbrains.plugins.gradle.util.GradleConstants Java Examples

The following examples show how to use org.jetbrains.plugins.gradle.util.GradleConstants. 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: 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 #2
Source File: FlutterExternalSystemTaskNotificationListener.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onSuccess(@NotNull ExternalSystemTaskId id) {
  if (id.getType() == ExternalSystemTaskType.RESOLVE_PROJECT && id.getProjectSystemId() == GradleConstants.SYSTEM_ID) {
    Project project = id.findProject();
    if (project != null) {
      AndroidUtils.checkDartSupport(project);
    }
  }
}
 
Example #3
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 #4
Source File: FlutterExternalSystemTaskNotificationListener.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onSuccess(@NotNull ExternalSystemTaskId id) {
  if (id.getType() == ExternalSystemTaskType.RESOLVE_PROJECT && id.getProjectSystemId() == GradleConstants.SYSTEM_ID) {
    Project project = id.findProject();
    if (project != null) {
      AndroidUtils.checkDartSupport(project);
    }
  }
}
 
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: GradleImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected ProjectSystemId getExternalSystemId() {
  return GradleConstants.SYSTEM_ID;
}
 
Example #7
Source File: AbstractModelBuilderTest.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  assumeThat(gradleVersion, versionMatcherRule.getMatcher());

  ensureTempDirCreated();

  String methodName = name.getMethodName();
  Matcher m = TEST_METHOD_NAME_PATTERN.matcher(methodName);
  if (m.matches()) {
    methodName = m.group(1);
  }

  testDir = new File(ourTempDir, methodName);
  FileUtil.ensureExists(testDir);

  final InputStream buildScriptStream = getClass().getResourceAsStream("/" + methodName + "/" + GradleConstants.DEFAULT_SCRIPT_NAME);
  try {
    FileUtil.writeToFile(
      new File(testDir, GradleConstants.DEFAULT_SCRIPT_NAME),
      FileUtil.loadTextAndClose(buildScriptStream)
    );
  }
  finally {
    StreamUtil.closeStream(buildScriptStream);
  }

  final InputStream settingsStream = getClass().getResourceAsStream("/" + methodName + "/" + GradleConstants.SETTINGS_FILE_NAME);
  try {
    if(settingsStream != null) {
      FileUtil.writeToFile(
        new File(testDir, GradleConstants.SETTINGS_FILE_NAME),
        FileUtil.loadTextAndClose(settingsStream)
      );
    }
  } finally {
    StreamUtil.closeStream(settingsStream);
  }

  GradleConnector connector = GradleConnector.newConnector();

  GradleVersion _gradleVersion = GradleVersion.version(gradleVersion);
  final URI distributionUri = new DistributionLocator().getDistributionFor(_gradleVersion);
  connector.useDistribution(distributionUri);
  connector.forProjectDirectory(testDir);
  int daemonMaxIdleTime = 10;
  try {
    daemonMaxIdleTime = Integer.parseInt(System.getProperty("gradleDaemonMaxIdleTime", "10"));
  }
  catch (NumberFormatException ignore) {}

  ((DefaultGradleConnector)connector).daemonMaxIdleTime(daemonMaxIdleTime, TimeUnit.SECONDS);
  ProjectConnection connection = connector.connect();

  try {
    boolean isGradleProjectDirSupported = _gradleVersion.compareTo(GradleVersion.version("2.4")) >= 0;
    boolean isCompositeBuildsSupported = isGradleProjectDirSupported && _gradleVersion.compareTo(GradleVersion.version("3.1")) >= 0;
    final ProjectImportAction projectImportAction = new ProjectImportAction(false, isGradleProjectDirSupported,
                                                                            isCompositeBuildsSupported);
    projectImportAction.addProjectImportExtraModelProvider(new ClassSetProjectImportExtraModelProvider(getModels()));
    BuildActionExecuter<ProjectImportAction.AllModels> buildActionExecutor = connection.action(projectImportAction);
    File initScript = GradleExecutionHelper.generateInitScript(false, getToolingExtensionClasses());
    assertNotNull(initScript);
    String jdkHome = IdeaTestUtil.requireRealJdkHome();
    buildActionExecutor.setJavaHome(new File(jdkHome));
    buildActionExecutor.setJvmArguments("-Xmx128m", "-XX:MaxPermSize=64m");
    buildActionExecutor.withArguments("--info", GradleConstants.INIT_SCRIPT_CMD_OPTION, initScript.getAbsolutePath());
    allModels = buildActionExecutor.run();
    assertNotNull(allModels);
  } finally {
    connection.close();
  }
}
 
Example #8
Source File: GradleToolDelegate.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public boolean isValid(Module module) {
    return ExternalSystemApiUtil.isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, module);
}
 
Example #9
Source File: GradleMonitor.java    From spring-javaformat with Apache License 2.0 4 votes vote down vote up
private void check() {
	ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
	boolean hasFormatPlugin = hasFormatPlugin(
			projectDataManager.getExternalProjectsData(getProject(), GradleConstants.SYSTEM_ID));
	getTrigger().updateState(hasFormatPlugin ? State.ACTIVE : State.NOT_ACTIVE);
}
 
Example #10
Source File: OpenAndroidModule.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static boolean canImportAsGradleProject(@NotNull VirtualFile importSource) {
  VirtualFile target = findGradleTarget(importSource);
  return target != null && GradleConstants.EXTENSION.equals(target.getExtension());
}
 
Example #11
Source File: OpenAndroidModule.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static boolean canImportAsGradleProject(@NotNull VirtualFile importSource) {
  VirtualFile target = findGradleTarget(importSource);
  return target != null && GradleConstants.EXTENSION.equals(target.getExtension());
}
 
Example #12
Source File: GradleUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * 查找所有的build.gradle文件
 *
 * @param project
 * @return
 */
public static Collection<VirtualFile> getAllGradleFile(Project project) {
    Collection<VirtualFile> collection = FilenameIndex.getVirtualFilesByName(project,
            GradleConstants.DEFAULT_SCRIPT_NAME, GlobalSearchScope.allScope(project));
    return collection == null ? Collections.EMPTY_LIST : collection;
}