Package org.gradle.api

Examples of org.gradle.api.Task$Namer


    public Task createTask(Project project, String name) {
        return createTask(getTask().getClass(), project, name);
    }

    public <T extends AbstractTask> T createTask(Class<T> type, Project project, String name) {
        Task task = TASK_FACTORY.createTask((ProjectInternal) project,
                GUtil.map(Task.TASK_TYPE, type,
                        Task.TASK_NAME, name));
        assertTrue(type.isAssignableFrom(task.getClass()));
        return type.cast(task);
    }
View Full Code Here


        DefaultProject childProject = HelperUtil.createChildProject(rootProject, "child");
        childProject.getProjectDir().mkdirs();
        DefaultProject childchildProject = HelperUtil.createChildProject(childProject, "childchild");
        childchildProject.getProjectDir().mkdirs();

        Task task = createTask(rootProject, TEST_TASK_NAME);
        assertEquals(Project.PATH_SEPARATOR + TEST_TASK_NAME, task.getPath());
        task = createTask(childProject, TEST_TASK_NAME);
        assertEquals(Project.PATH_SEPARATOR + "child" + Project.PATH_SEPARATOR + TEST_TASK_NAME, task.getPath());
        task = createTask(childchildProject, TEST_TASK_NAME);
        assertEquals(Project.PATH_SEPARATOR + "child" + Project.PATH_SEPARATOR + "childchild" + Project.PATH_SEPARATOR + TEST_TASK_NAME, task.getPath());
    }
View Full Code Here

        assertEquals(Project.PATH_SEPARATOR + "child" + Project.PATH_SEPARATOR + "childchild" + Project.PATH_SEPARATOR + TEST_TASK_NAME, task.getPath());
    }

    @Test
    public void testDependsOn() {
        Task dependsOnTask = createTask(project, "somename");
        Task task = createTask(project, TEST_TASK_NAME);
        project.getTasks().add("path1");
        project.getTasks().add("path2");

        task.dependsOn(Project.PATH_SEPARATOR + "path1");
        assertThat(task, dependsOn("path1"));
        task.dependsOn("path2", dependsOnTask);
        assertThat(task, dependsOn("path1", "path2", "somename"));
    }
View Full Code Here

        assertTrue(task.getOnlyIf().isSatisfiedBy(task));
    }

    @Test
    public void testDependentTaskDidWork() {
        final Task task1 = context.mock(Task.class, "task1");
        final Task task2 = context.mock(Task.class, "task2");
        final TaskDependency dependencyMock = context.mock(TaskDependency.class);
        getTask().dependsOn(dependencyMock);
        context.checking(new Expectations() {{
            allowing(dependencyMock).getDependencies(getTask()); will(returnValue(WrapUtil.toSet(task1, task2)));
View Full Code Here

    @Before
    public void setUp() throws Exception {
        context = new JUnit4Mockery();

        Task subsubCompileTask = TestUtility.createTask(context, "compile", "compile description");
        Task subsubLibTask = TestUtility.createTask(context, "lib", "lib description");
        Task subsubDocTask = TestUtility.createTask(context, "doc", "doc description");
        Project subsubProject = TestUtility.createMockProject(context, "mysubsubproject", "filepath3", 2, null,
                new Task[]{subsubCompileTask, subsubLibTask, subsubDocTask}, null, (Project[]) null);

        Task subCompileTask1 = TestUtility.createTask(context, "compile", "compile description");
        Task subLibTask1 = TestUtility.createTask(context, "lib", "lib description");
        Task subDocTask1 = TestUtility.createTask(context, "doc", "doc description");
        Project subProject1 = TestUtility.createMockProject(context, "mysubproject1", "filepath2a", 1,
                new Project[]{subsubProject}, new Task[]{subCompileTask1, subLibTask1, subDocTask1}, null,
                (Project[]) null);

        Task subCompileTask2 = TestUtility.createTask(context, "compile", "compile description");
        Task subLibTask2 = TestUtility.createTask(context, "lib", "lib description");
        Task subDocTask2 = TestUtility.createTask(context, "doc", "doc description");
        Project subProject2 = TestUtility.createMockProject(context, "mysubproject2", "filepath2b", 1, null,
                new Task[]{subCompileTask2, subLibTask2, subDocTask2}, null, (Project[]) null);

        Project rootProject = TestUtility.createMockProject(context, "myrootproject", "filepath1", 0,
                new Project[]{subProject1, subProject2}, null, null, (Project[]) null);
View Full Code Here

        assertTrue(testTask.executed);
    }

    @Test
    public void dependsOnTargetDependencies() {
        Task a = project.getTasks().add("a");
        Task b = project.getTasks().add("b");
        antTarget.setDepends("a, b");

        task.setTarget(antTarget);
        Set dependencies = task.getTaskDependencies().getDependencies(task);
        assertThat(dependencies, equalTo((Set) toSet(a, b)));
View Full Code Here

    public static final String PROPERTIES_TASK = "properties";

    public void execute(ProjectInternal project) {
        TaskContainerInternal tasks = project.getImplicitTasks();

        Task task = tasks.add(HELP_TASK, Help.class);
        task.setDescription("Displays a help message");
        task.setGroup(HELP_GROUP);

        task = tasks.add(PROJECTS_TASK, ProjectReportTask.class);
        task.setDescription(String.format("Displays the sub-projects of %s.", project));
        task.setGroup(HELP_GROUP);

        task = tasks.add(TASKS_TASK, TaskReportTask.class);
        task.setDescription(String.format("Displays the tasks in %s.", project));
        task.setGroup(HELP_GROUP);

        task = tasks.add(DEPENDENCIES_TASK, DependencyReportTask.class);
        task.setDescription(String.format("Displays the dependencies of %s.", project));
        task.setGroup(HELP_GROUP);

        task = tasks.add(PROPERTIES_TASK, PropertyReportTask.class);
        task.setDescription(String.format("Displays the properties of %s.", project));
        task.setGroup(HELP_GROUP);
    }
View Full Code Here

        projectDependency.setTransitive(false);
        projectDependency.resolve(resolveContext);
    }

    private Task taskInTargetProject(final String name) {
        final Task task = context.mock(Task.class, name);
        context.checking(new Expectations(){{
            allowing(dependencyProjectTaskContainerStub).getByName(name);
            will(returnValue(task));
        }});
        return task;
View Full Code Here

        return task;
    }

    @Test
    public void dependsOnTargetConfigurationAndArtifactsOfTargetConfiguration() {
        Task a = taskInTargetProject("a");
        Task b = taskInTargetProject("b");
        Task c = taskInTargetProject("c");
        expectTargetConfigurationHasDependencies(a, b);
        expectTargetConfigurationHasArtifacts(c);

        assertThat(projectDependency.getBuildDependencies().getDependencies(null), equalTo((Set) toSet(a, b, c)));
    }
View Full Code Here

    @Test
    public void dependsOnAdditionalTasksFromTargetProject() {
        expectTargetConfigurationHasNoDependencies();

        Task a = taskInTargetProject("a");
        Task b = taskInTargetProject("b");

        DefaultProjectDependency dependency = new DefaultProjectDependency(dependencyProjectStub,
                new ProjectDependenciesBuildInstruction(toList("a", "b")));
        assertThat(dependency.getBuildDependencies().getDependencies(null), equalTo((Set) toSet(a, b)));
    }
View Full Code Here

TOP

Related Classes of org.gradle.api.Task$Namer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.