use of org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask in project gradle by gradle.
the class GradleProjectBuilder method tasks.
private static List<LaunchableGradleTask> tasks(DefaultGradleProject owner, TaskContainerInternal tasks, String projectOptions) {
if ("omit_all_tasks".equals(projectOptions)) {
return Collections.emptyList();
} else if ("skip_task_graph_realization".equals(projectOptions)) {
return tasks.getNames().stream().map(t -> buildFromTaskName(new LaunchableGradleProjectTask(), owner.getProjectIdentifier(), t)).collect(Collectors.toList());
}
tasks.discoverTasks();
tasks.realize();
SortedSet<String> taskNames = tasks.getNames();
List<LaunchableGradleTask> out = new ArrayList<LaunchableGradleTask>(taskNames.size());
for (String taskName : taskNames) {
Task t = tasks.findByName(taskName);
if (t != null) {
out.add(buildFromTask(new LaunchableGradleProjectTask(), owner.getProjectIdentifier(), t).setProject(owner));
}
}
return out;
}
use of org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask in project gradle by gradle.
the class GradleProjectBuilder method buildHierarchy.
private DefaultGradleProject buildHierarchy(Project project) {
List<DefaultGradleProject> children = new ArrayList<DefaultGradleProject>();
for (Project child : project.getChildProjects().values()) {
children.add(buildHierarchy(child));
}
DefaultGradleProject gradleProject = new DefaultGradleProject().setProjectIdentifier(new DefaultProjectIdentifier(project.getRootDir(), project.getPath())).setName(project.getName()).setDescription(project.getDescription()).setBuildDirectory(project.getBuildDir()).setProjectDirectory(project.getProjectDir()).setChildren(children);
gradleProject.getBuildScript().setSourceFile(project.getBuildFile());
/*
Internal system property to investigate model loading performance in IDEA/Android Studio.
The model loading can be altered with the following values:
- "omit_all_tasks": The model builder won't realize the task graph. The returned model will contain an empty task list.
- "skip_task_graph_realization": The model builder won't realize the task graph. The returned model will contain artificial tasks created from the task names.
- "skip_task_serialization": The model builder will realize the task graph but won't send it to the client.
- "unmodified" (or any other value): The model builder will run unchanged.
*/
String projectOptions = System.getProperty("org.gradle.internal.GradleProjectBuilderOptions", "unmodified");
List<LaunchableGradleTask> tasks = tasks(gradleProject, (TaskContainerInternal) project.getTasks(), projectOptions);
if (!"skip_task_serialization".equals(projectOptions)) {
gradleProject.setTasks(tasks);
}
for (DefaultGradleProject child : children) {
child.setParent(gradleProject);
}
return gradleProject;
}
use of org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask in project gradle by gradle.
the class BuildInvocationsBuilder method buildAll.
@Override
@SuppressWarnings("StringEquality")
public DefaultBuildInvocations buildAll(String modelName, Project project) {
if (!canBuild(modelName)) {
throw new GradleException("Unknown model name " + modelName);
}
DefaultProjectIdentifier projectIdentifier = getProjectIdentifier(project);
// construct task selectors
List<LaunchableGradleTaskSelector> selectors = Lists.newArrayList();
Map<String, LaunchableGradleTaskSelector> selectorsByName = Maps.newTreeMap(Ordering.natural());
Set<String> visibleTasks = Sets.newLinkedHashSet();
findTasks(project, selectorsByName, visibleTasks);
for (String selectorName : selectorsByName.keySet()) {
LaunchableGradleTaskSelector selector = selectorsByName.get(selectorName);
selectors.add(selector.setName(selectorName).setTaskName(selectorName).setProjectIdentifier(projectIdentifier).setDisplayName(selectorName + " in " + project + " and subprojects.").setPublic(visibleTasks.contains(selectorName)));
}
// construct project tasks
List<LaunchableGradleTask> projectTasks = tasks(project, projectIdentifier);
// construct build invocations from task selectors and project tasks
return new DefaultBuildInvocations().setSelectors(selectors).setTasks(projectTasks).setProjectIdentifier(projectIdentifier);
}
use of org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask in project gradle by gradle.
the class GradleProjectBuilder method tasks.
private static List<LaunchableGradleTask> tasks(DefaultGradleProject owner, TaskContainerInternal tasks) {
tasks.discoverTasks();
SortedSet<String> taskNames = tasks.getNames();
List<LaunchableGradleTask> out = new ArrayList<LaunchableGradleTask>(taskNames.size());
for (String taskName : taskNames) {
Task t = tasks.findByName(taskName);
if (t != null) {
out.add(buildFromTask(new LaunchableGradleProjectTask(), t).setProject(owner).setProjectIdentifier(owner.getProjectIdentifier()));
}
}
return out;
}
use of org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask in project gradle by gradle.
the class CppModelBuilder method binariesFor.
private List<DefaultCppBinaryModel> binariesFor(CppComponent component, Iterable<File> headerDirs, DefaultProjectIdentifier projectIdentifier, CompilerOutputFileNamingSchemeFactory namingSchemeFactory) {
List<File> headerDirsCopy = ImmutableList.copyOf(headerDirs);
List<DefaultCppBinaryModel> binaries = new ArrayList<DefaultCppBinaryModel>();
for (CppBinary binary : component.getBinaries().get()) {
DefaultCppBinary cppBinary = (DefaultCppBinary) binary;
PlatformToolProvider platformToolProvider = cppBinary.getPlatformToolProvider();
CppCompile compileTask = binary.getCompileTask().get();
List<DefaultSourceFile> sourceFiles = sourceFiles(namingSchemeFactory, platformToolProvider, compileTask.getObjectFileDir().get().getAsFile(), binary.getCppSource().getFiles());
List<File> systemIncludes = ImmutableList.copyOf(compileTask.getSystemIncludes().getFiles());
List<File> userIncludes = ImmutableList.copyOf(compileTask.getIncludes().getFiles());
List<DefaultMacroDirective> macroDefines = macroDefines(compileTask);
List<String> additionalArgs = args(compileTask.getCompilerArgs().get());
CommandLineToolSearchResult compilerLookup = platformToolProvider.locateTool(ToolType.CPP_COMPILER);
File compilerExe = compilerLookup.isAvailable() ? compilerLookup.getTool() : null;
LaunchableGradleTask compileTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, compileTask);
DefaultCompilationDetails compilationDetails = new DefaultCompilationDetails(compileTaskModel, compilerExe, compileTask.getObjectFileDir().get().getAsFile(), sourceFiles, headerDirsCopy, systemIncludes, userIncludes, macroDefines, additionalArgs);
if (binary instanceof CppExecutable || binary instanceof CppTestExecutable) {
ComponentWithExecutable componentWithExecutable = (ComponentWithExecutable) binary;
LinkExecutable linkTask = componentWithExecutable.getLinkTask().get();
LaunchableGradleTask linkTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, componentWithExecutable.getExecutableFileProducer().get());
DefaultLinkageDetails linkageDetails = new DefaultLinkageDetails(linkTaskModel, componentWithExecutable.getExecutableFile().get().getAsFile(), args(linkTask.getLinkerArgs().get()));
binaries.add(new DefaultCppExecutableModel(binary.getName(), cppBinary.getIdentity().getName(), binary.getBaseName().get(), compilationDetails, linkageDetails));
} else if (binary instanceof CppSharedLibrary) {
CppSharedLibrary sharedLibrary = (CppSharedLibrary) binary;
LinkSharedLibrary linkTask = sharedLibrary.getLinkTask().get();
LaunchableGradleTask linkTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, sharedLibrary.getLinkFileProducer().get());
DefaultLinkageDetails linkageDetails = new DefaultLinkageDetails(linkTaskModel, sharedLibrary.getLinkFile().get().getAsFile(), args(linkTask.getLinkerArgs().get()));
binaries.add(new DefaultCppSharedLibraryModel(binary.getName(), cppBinary.getIdentity().getName(), binary.getBaseName().get(), compilationDetails, linkageDetails));
} else if (binary instanceof CppStaticLibrary) {
CppStaticLibrary staticLibrary = (CppStaticLibrary) binary;
LaunchableGradleTask createTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, staticLibrary.getLinkFileProducer().get());
DefaultLinkageDetails linkageDetails = new DefaultLinkageDetails(createTaskModel, staticLibrary.getLinkFile().get().getAsFile(), Collections.<String>emptyList());
binaries.add(new DefaultCppStaticLibraryModel(binary.getName(), cppBinary.getIdentity().getName(), binary.getBaseName().get(), compilationDetails, linkageDetails));
}
}
return binaries;
}
Aggregations