Search in sources :

Example 1 with LaunchableGradleTask

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;
}
Also used : LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) LaunchableGradleProjectTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleProjectTask) ToolingModelBuilderSupport.buildFromTask(org.gradle.plugins.ide.internal.tooling.ToolingModelBuilderSupport.buildFromTask) LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) LaunchableGradleProjectTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleProjectTask) Task(org.gradle.api.Task) ArrayList(java.util.ArrayList)

Example 2 with LaunchableGradleTask

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;
}
Also used : LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) Project(org.gradle.api.Project) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) ArrayList(java.util.ArrayList) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 3 with LaunchableGradleTask

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);
}
Also used : LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) DefaultBuildInvocations(org.gradle.plugins.ide.internal.tooling.model.DefaultBuildInvocations) GradleException(org.gradle.api.GradleException) LaunchableGradleTaskSelector(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTaskSelector) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 4 with LaunchableGradleTask

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;
}
Also used : LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) LaunchableGradleProjectTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleProjectTask) Task(org.gradle.api.Task) ToolingModelBuilderSupport.buildFromTask(org.gradle.plugins.ide.internal.tooling.ToolingModelBuilderSupport.buildFromTask) LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) LaunchableGradleProjectTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleProjectTask) ArrayList(java.util.ArrayList)

Example 5 with LaunchableGradleTask

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;
}
Also used : ArrayList(java.util.ArrayList) LinkSharedLibrary(org.gradle.nativeplatform.tasks.LinkSharedLibrary) CppStaticLibrary(org.gradle.language.cpp.CppStaticLibrary) CommandLineToolSearchResult(org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult) CppSharedLibrary(org.gradle.language.cpp.CppSharedLibrary) ComponentWithExecutable(org.gradle.language.nativeplatform.ComponentWithExecutable) DefaultCppBinary(org.gradle.language.cpp.internal.DefaultCppBinary) CppBinary(org.gradle.language.cpp.CppBinary) CppExecutable(org.gradle.language.cpp.CppExecutable) DefaultCppBinary(org.gradle.language.cpp.internal.DefaultCppBinary) LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) LinkExecutable(org.gradle.nativeplatform.tasks.LinkExecutable) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) CppCompile(org.gradle.language.cpp.tasks.CppCompile) File(java.io.File) CppTestExecutable(org.gradle.nativeplatform.test.cpp.CppTestExecutable)

Aggregations

LaunchableGradleTask (org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask)5 ArrayList (java.util.ArrayList)4 Task (org.gradle.api.Task)2 ToolingModelBuilderSupport.buildFromTask (org.gradle.plugins.ide.internal.tooling.ToolingModelBuilderSupport.buildFromTask)2 LaunchableGradleProjectTask (org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleProjectTask)2 DefaultProjectIdentifier (org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)2 File (java.io.File)1 GradleException (org.gradle.api.GradleException)1 Project (org.gradle.api.Project)1 CppBinary (org.gradle.language.cpp.CppBinary)1 CppExecutable (org.gradle.language.cpp.CppExecutable)1 CppSharedLibrary (org.gradle.language.cpp.CppSharedLibrary)1 CppStaticLibrary (org.gradle.language.cpp.CppStaticLibrary)1 DefaultCppBinary (org.gradle.language.cpp.internal.DefaultCppBinary)1 CppCompile (org.gradle.language.cpp.tasks.CppCompile)1 ComponentWithExecutable (org.gradle.language.nativeplatform.ComponentWithExecutable)1 LinkExecutable (org.gradle.nativeplatform.tasks.LinkExecutable)1 LinkSharedLibrary (org.gradle.nativeplatform.tasks.LinkSharedLibrary)1 CppTestExecutable (org.gradle.nativeplatform.test.cpp.CppTestExecutable)1 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)1