Gradle: getGradlePath util by ModuleData

This commit is contained in:
Vladislav.Soroka
2019-03-29 18:51:39 +03:00
parent 9dd23c0392
commit 9bf70561c1
3 changed files with 17 additions and 19 deletions
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.gradle.action.GradleExecuteTaskAction;
import org.jetbrains.plugins.gradle.service.execution.cmd.GradleCommandLineOptionsProvider;
import org.jetbrains.plugins.gradle.service.project.GradleProjectResolverUtil;
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings;
import org.jetbrains.plugins.gradle.settings.GradleSettings;
import org.jetbrains.plugins.gradle.util.GradleConstants;
@@ -225,15 +226,7 @@ public class GradleRunAnythingProvider extends RunAnythingProviderBase<String> {
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;
}
String gradlePath = GradleProjectResolverUtil.getGradlePath(moduleDataNode.getData());
for (DataNode<TaskData> node : getChildren(moduleDataNode, ProjectKeys.TASK)) {
TaskData taskData = node.getData();
String taskName = taskData.getName();
@@ -302,6 +302,20 @@ public class GradleProjectResolverUtil {
return join.isEmpty() ? ":" : ":" + join;
}
@NotNull
public static String getGradlePath(@NotNull ModuleData moduleData) {
String gradlePath;
String moduleId = moduleData.getId();
if (moduleId.charAt(0) != ':') {
int colonIndex = moduleId.indexOf(':');
gradlePath = colonIndex > 0 ? moduleId.substring(colonIndex) : ":";
}
else {
gradlePath = moduleId;
}
return gradlePath;
}
@NotNull
public static DependencyScope getDependencyScope(@Nullable String scope) {
return scope != null ? DependencyScope.valueOf(scope) : DependencyScope.COMPILE;
@@ -75,16 +75,7 @@ public class GradleExtensionsSettings {
DataNode<?> parent = node.getParent();
if (parent == null) continue;
if (!(parent.getData() instanceof ModuleData)) continue;
ModuleData moduleData = (ModuleData)parent.getData();
String gradlePath;
String moduleId = moduleData.getId();
if (moduleId.charAt(0) != ':') {
int colonIndex = moduleId.indexOf(':');
gradlePath = colonIndex > 0 ? moduleId.substring(colonIndex) : ":";
}
else {
gradlePath = moduleId;
}
String gradlePath = GradleProjectResolverUtil.getGradlePath((ModuleData)parent.getData());
extensionMap.put(gradlePath, node.getData());
}