Package org.gradle.api.internal

Examples of org.gradle.api.internal.TaskInternal


        assertTrue(state.isUpToDate());
    }

    @Test
    public void artifactsAreUpToDateWhenTaskHasNoOutputs() {
        TaskInternal task = builder().withOutputFiles().task();
        execute(task);

        TaskArtifactState state = repository.getStateFor(task);
        assertTrue(state.isUpToDate());
    }
View Full Code Here


    @Test
    public void taskCanProduceIntoDifferentSetsOfOutputFiles() {
        TestFile outputDir2 = tmpDir.createDir("output-dir-2");
        TestFile outputDirFile2 = outputDir2.file("output-file-2");
        TaskInternal instance1 = builder().withOutputFiles(outputDir).createsFiles(outputDirFile).task();
        TaskInternal instance2 = builder().withOutputFiles(outputDir2).createsFiles(outputDirFile2).task();

        execute(instance1, instance2);

        TaskArtifactState state = repository.getStateFor(instance1);
        assertTrue(state.isUpToDate());
View Full Code Here

            inputProperties.put(name, value);
            return this;
        }

        TaskInternal task() {
            final TaskInternal task = HelperUtil.createTask(type, project, path);
            if (inputs != null) {
                task.getInputs().files(inputs);
            }
            if (inputProperties != null) {
                task.getInputs().properties(inputProperties);
            }
            if (outputs != null) {
                task.getOutputs().files(outputs);
            }
            task.doLast(new org.gradle.api.Action<Object>() {
                public void execute(Object o) {
                    for (TestFile file : create) {
                        file.createFile();
                    }
                }
View Full Code Here

            will(returnValue(task));
        }});
    }

    private TaskInternal task(final String name) {
        final TaskInternal task = context.mock(TaskInternal.class, "[task" + ++taskCount + "]");
        context.checking(new Expectations(){{
            allowing(task).getName();
            will(returnValue(name));
        }});
        return task;
View Full Code Here

    private final ITaskFactory delegate = context.mock(ITaskFactory.class);
    private final DependencyAutoWireTaskFactory factory = new DependencyAutoWireTaskFactory(delegate);

    @Test
    public void addsDependencyOnInputFiles() {
        final TaskInternal task = context.mock(TaskInternal.class);
        final ProjectInternal project = context.mock(ProjectInternal.class);
        final TaskInputs taskInputs = context.mock(TaskInputs.class);
        final FileCollection inputFiles = context.mock(FileCollection.class);

        context.checking(new Expectations() {{
View Full Code Here

            throw new InvalidUserDataException("The task name must be provided.");
        }

        Class<? extends TaskInternal> type = (Class) actualArgs.get(Task.TASK_TYPE);
        Boolean generateSubclass = Boolean.valueOf(actualArgs.get(GENERATE_SUBCLASS).toString());
        TaskInternal task = createTaskObject(project, type, name, generateSubclass);

        Object dependsOnTasks = actualArgs.get(Task.TASK_DEPENDS_ON);
        if (dependsOnTasks != null) {
            task.dependsOn(dependsOnTasks);
        }
        Object description = actualArgs.get(Task.TASK_DESCRIPTION);
        if (description != null) {
            task.setDescription(description.toString());
        }
        Object group = actualArgs.get(Task.TASK_GROUP);
        if (group != null) {
            task.setGroup(group.toString());
        }
        Object action = actualArgs.get(Task.TASK_ACTION);
        if (action instanceof Action) {
            Action<? super Task> taskAction = (Action<? super Task>) action;
            task.doFirst(taskAction);
        } else if (action != null) {
            Closure closure = (Closure) action;
            task.doFirst(closure);
        }

        return task;
    }
View Full Code Here

    public ITaskFactory createChild(ProjectInternal project, Instantiator instantiator) {
        return new AnnotationProcessingTaskFactory(classInfos, taskFactory.createChild(project, instantiator));
    }

    public TaskInternal createTask(Map<String, ?> args) {
        TaskInternal task = taskFactory.createTask(args);
        TaskClassInfo taskClassInfo = getTaskClassInfo(task.getClass());

        if (taskClassInfo.incremental) {
            // Add a dummy upToDateWhen spec: this will for TaskOutputs.hasOutputs() to be true.
            task.getOutputs().upToDateWhen(new Spec<Task>() {
                public boolean isSatisfiedBy(Task element) {
                    return true;
                }
            });
        }

        for (Factory<Action<Task>> actionFactory : taskClassInfo.taskActions) {
            task.doFirst(actionFactory.create());
        }

        if (taskClassInfo.validator != null) {
            task.doFirst(taskClassInfo.validator);
            taskClassInfo.validator.addInputsAndOutputs(task);
        }

        return task;
    }
View Full Code Here

        }

        // TODO:PARALLEL It would be good to move this logic into a TaskExecuter wrapper, but we'd need a way to give it a TaskExecutionListener that
        // is wired to the various add/remove listener methods on TaskExecutionGraph
        private void executeTask(TaskInfo taskInfo) {
            TaskInternal task = taskInfo.getTask();
            synchronized (lock) {
                taskListener.beforeExecute(task);
            }
            try {
                task.executeWithoutThrowingTaskFailure();
            } finally {
                synchronized (lock) {
                    taskListener.afterExecute(task, task.getState());
                }
            }
        }
View Full Code Here

                // Have already visited this task - skip it
                queue.remove(0);
                continue;
            }

            TaskInternal task = node.getTask();
            boolean filtered = !filter.isSatisfiedBy(task);
            if (filtered) {
                // Task is not required - skip it
                queue.remove(0);
                node.dependenciesProcessed();
                node.doNotRequire();
                continue;
            }

            if (visiting.add(node)) {
                // Have not seen this task before - add its dependencies to the head of the queue and leave this
                // task in the queue
                Set<? extends Task> dependsOnTasks = context.getDependencies(task);
                for (Task dependsOnTask : dependsOnTasks) {
                    TaskInfo targetNode = graph.addNode(dependsOnTask);
                    node.addDependencySuccessor(targetNode);
                    if (!visiting.contains(targetNode)) {
                        queue.add(0, targetNode);
                    }
                }
                for (Task finalizerTask : task.getFinalizedBy().getDependencies(task)) {
                    TaskInfo targetNode = graph.addNode(finalizerTask);
                    addFinalizerNode(node, targetNode);
                    if (!visiting.contains(targetNode)) {
                        queue.add(0, targetNode);
                    }
                }
                for (Task mustRunAfter : task.getMustRunAfter().getDependencies(task)) {
                    TaskInfo targetNode = graph.addNode(mustRunAfter);
                    node.addMustSuccessor(targetNode);
                }
                for (Task shouldRunAfter : task.getShouldRunAfter().getDependencies(task)) {
                    TaskInfo targetNode = graph.addNode(shouldRunAfter);
                    node.addShouldSuccessor(targetNode);
                }
                if (node.isRequired()) {
                    for (TaskInfo successor : node.getDependencySuccessors()) {
View Full Code Here

    private final ITaskFactory delegate = context.mock(ITaskFactory.class);
    private final DependencyAutoWireTaskFactory factory = new DependencyAutoWireTaskFactory(delegate);

    @Test
    public void addsDependencyOnInputFiles() {
        final TaskInternal task = context.mock(TaskInternal.class);
        final TaskInputs taskInputs = context.mock(TaskInputs.class);
        final FileCollection inputFiles = context.mock(FileCollection.class);

        context.checking(new Expectations() {{
            one(delegate).createTask(map());
View Full Code Here

TOP

Related Classes of org.gradle.api.internal.TaskInternal

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.