Search in sources :

Example 1 with BuildClientMetaData

use of org.gradle.initialization.BuildClientMetaData in project gradle by gradle.

the class Help method displayHelp.

@TaskAction
void displayHelp() {
    StyledTextOutput output = getTextOutputFactory().create(Help.class);
    BuildClientMetaData metaData = getClientMetaData();
    if (taskPath != null) {
        printTaskHelp(output);
    } else {
        printDefaultHelp(output, metaData);
    }
}
Also used : BuildClientMetaData(org.gradle.initialization.BuildClientMetaData) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with BuildClientMetaData

use of org.gradle.initialization.BuildClientMetaData in project gradle by gradle.

the class AbstractReportTaskTest method passesEachProjectToRenderer.

@Test
public void passesEachProjectToRenderer() throws IOException {
    final Project child1 = createChildProject(project, "child1");
    final Project child2 = createChildProject(project, "child2");
    task.setProjects(project.getAllprojects());
    context.checking(new Expectations() {

        {
            Sequence sequence = context.sequence("seq");
            one(renderer).setClientMetaData((BuildClientMetaData) with(notNullValue()));
            inSequence(sequence);
            one(renderer).setOutput((StyledTextOutput) with(notNullValue()));
            inSequence(sequence);
            one(renderer).startProject(project);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(project);
            inSequence(sequence);
            one(renderer).startProject(child1);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(child1);
            inSequence(sequence);
            one(renderer).startProject(child2);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(child2);
            inSequence(sequence);
            one(renderer).complete();
            inSequence(sequence);
        }
    });
    task.generate();
}
Also used : Expectations(org.jmock.Expectations) BuildClientMetaData(org.gradle.initialization.BuildClientMetaData) Project(org.gradle.api.Project) TestUtil.createChildProject(org.gradle.util.TestUtil.createChildProject) Sequence(org.jmock.Sequence) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) Test(org.junit.Test)

Example 3 with BuildClientMetaData

use of org.gradle.initialization.BuildClientMetaData in project gradle by gradle.

the class AbstractReportTaskTest method setsOutputFileNameOnRendererBeforeGeneration.

@Test
public void setsOutputFileNameOnRendererBeforeGeneration() throws IOException {
    final File file = tmpDir.getTestDirectory().file("report.txt");
    context.checking(new Expectations() {

        {
            Sequence sequence = context.sequence("sequence");
            one(renderer).setClientMetaData((BuildClientMetaData) with(notNullValue()));
            inSequence(sequence);
            one(renderer).setOutputFile(file);
            inSequence(sequence);
            one(renderer).startProject(project);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(project);
            inSequence(sequence);
            one(renderer).complete();
            inSequence(sequence);
        }
    });
    task.setOutputFile(file);
    task.generate();
}
Also used : Expectations(org.jmock.Expectations) BuildClientMetaData(org.gradle.initialization.BuildClientMetaData) Sequence(org.jmock.Sequence) File(java.io.File) Test(org.junit.Test)

Example 4 with BuildClientMetaData

use of org.gradle.initialization.BuildClientMetaData in project gradle by gradle.

the class AbstractReportTaskTest method completesRendererAtEndOfGeneration.

@Test
public void completesRendererAtEndOfGeneration() throws IOException {
    context.checking(new Expectations() {

        {
            Sequence sequence = context.sequence("sequence");
            one(renderer).setClientMetaData((BuildClientMetaData) with(notNullValue()));
            inSequence(sequence);
            one(renderer).setOutput((StyledTextOutput) with(notNullValue()));
            inSequence(sequence);
            one(renderer).startProject(project);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(project);
            inSequence(sequence);
            one(renderer).complete();
            inSequence(sequence);
        }
    });
    task.generate();
}
Also used : Expectations(org.jmock.Expectations) BuildClientMetaData(org.gradle.initialization.BuildClientMetaData) Sequence(org.jmock.Sequence) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) Test(org.junit.Test)

Example 5 with BuildClientMetaData

use of org.gradle.initialization.BuildClientMetaData in project gradle by gradle.

the class ProjectReportTask method generate.

@Override
protected void generate(Project project) throws IOException {
    BuildClientMetaData metaData = getClientMetaData();
    StyledTextOutput textOutput = getRenderer().getTextOutput();
    render(project, new GraphRenderer(textOutput), true, textOutput);
    if (project.getChildProjects().isEmpty()) {
        textOutput.withStyle(Info).text("No sub-projects");
        textOutput.println();
    }
    textOutput.println();
    textOutput.text("To see a list of the tasks of a project, run ");
    metaData.describeCommand(textOutput.withStyle(UserInput), "<project-path>:" + ProjectInternal.TASKS_TASK);
    textOutput.println();
    textOutput.text("For example, try running ");
    Project exampleProject = project.getChildProjects().isEmpty() ? project : getChildren(project).get(0);
    metaData.describeCommand(textOutput.withStyle(UserInput), exampleProject.absoluteProjectPath(ProjectInternal.TASKS_TASK));
    textOutput.println();
    if (project != project.getRootProject()) {
        textOutput.println();
        textOutput.text("To see a list of all the projects in this build, run ");
        metaData.describeCommand(textOutput.withStyle(UserInput), project.getRootProject().absoluteProjectPath(ProjectInternal.PROJECTS_TASK));
        textOutput.println();
    }
}
Also used : BuildClientMetaData(org.gradle.initialization.BuildClientMetaData) Project(org.gradle.api.Project) GraphRenderer(org.gradle.internal.graph.GraphRenderer) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput)

Aggregations

BuildClientMetaData (org.gradle.initialization.BuildClientMetaData)6 StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)5 Expectations (org.jmock.Expectations)3 Sequence (org.jmock.Sequence)3 Test (org.junit.Test)3 Project (org.gradle.api.Project)2 File (java.io.File)1 TaskAction (org.gradle.api.tasks.TaskAction)1 GraphRenderer (org.gradle.internal.graph.GraphRenderer)1 TestUtil.createChildProject (org.gradle.util.TestUtil.createChildProject)1