Java 类org.gradle.api.Task 实例源码

项目:Reer    文件:TaskSelector.java   
public Spec<Task> getFilter(String path) {
    final ResolvedTaskPath taskPath = taskPathResolver.resolvePath(path, gradle.getDefaultProject());
    if (!taskPath.isQualified()) {
        ProjectInternal targetProject = taskPath.getProject();
        configurer.configure(targetProject);
        if (taskNameResolver.tryFindUnqualifiedTaskCheaply(taskPath.getTaskName(), taskPath.getProject())) {
            // An exact match in the target project - can just filter tasks by path to avoid configuring sub-projects at this point
            return new TaskPathSpec(targetProject, taskPath.getTaskName());
        }
    }

    final Set<Task> selectedTasks = getSelection(path, gradle.getDefaultProject()).getTasks();
    return new Spec<Task>() {
        public boolean isSatisfiedBy(Task element) {
            return !selectedTasks.contains(element);
        }
    };
}
项目:Reer    文件:CleanRule.java   
@Override
public void apply(String taskName) {
    if (!taskName.startsWith(CLEAN) || taskName.equals(CLEAN)) {
        return;
    }
    String targetTaskName = taskName.substring(CLEAN.length());
    if (Character.isLowerCase(targetTaskName.charAt(0))) {
        return;
    }

    Task task = tasks.findByName(StringUtils.uncapitalize(targetTaskName));
    if (task == null) {
        return;
    }

    Delete clean = tasks.create(taskName, Delete.class);
    clean.delete(task.getOutputs().getFiles());
}
项目:atlas    文件:MtlTaskInjector.java   
protected List<Task> findTask(Class<Task> clazz, String variantName) {
    Task[] androidTasks = project.getTasks().withType(clazz).toArray(new Task[0]);
    List<Task> taskList = new ArrayList();
    for (Task task : androidTasks) {
        if (task.getName().endsWith("TestJavaWithJavac")){
            continue;
        }
        if (task instanceof DefaultAndroidTask) {
            if (variantName.equals(((DefaultAndroidTask)task).getVariantName())) {
                taskList.add(task);
            }
        } else {

            String name = task.getName();
            if (name.toLowerCase().contains(variantName)) {
                taskList.add(task);
            }
        }

    }
    return taskList;
}
项目:Reer    文件:ComponentModelBasePlugin.java   
@Override
public void execute(Task task) {
    Set<? extends Task> taskDependencies = task.getTaskDependencies().getDependencies(task);

    if (taskDependencies.isEmpty()) {
        TreeFormatter formatter = new TreeFormatter();
        formatter.node("No buildable binaries found");
        formatter.startChildren();
        for (BinarySpecInternal binary : notBuildable) {
            formatter.node(binary.getDisplayName());
            formatter.startChildren();
            binary.getBuildAbility().explain(formatter);
            formatter.endChildren();
        }
        formatter.endChildren();
        throw new GradleException(formatter.toString());
    }
}
项目:gradle-java-modules    文件:JigsawPlugin.java   
private void configureRunTask(final Project project) {
    final JavaExec run = (JavaExec) project.getTasks().findByName(ApplicationPlugin.TASK_RUN_NAME);
    final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
    run.getInputs().property("moduleName", module.geName());
    run.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            List<String> args = new ArrayList<>();
            args.add("--module-path");
            args.add(run.getClasspath().getAsPath());
            args.add("--module");
            args.add(module.geName() + "/" + run.getMain());
            run.setJvmArgs(args);
            run.setClasspath(project.files());
        }
    });
}
项目:Reer    文件:DefaultCacheScopeMapping.java   
@Override
public File getRootDirectory(@Nullable Object scope) {
    if (scope == null) {
        return globalCacheDir;
    }
    if (scope instanceof Gradle) {
        Gradle gradle = (Gradle) scope;
        return getBuildCacheDir(gradle.getRootProject());
    }
    if (scope instanceof Project) {
        Project project = (Project) scope;
        return getBuildCacheDir(project.getRootProject());
    }
    if (scope instanceof Task) {
        Task task = (Task) scope;
        return getBuildCacheDir(task.getProject().getRootProject());
    }
    throw new IllegalArgumentException(String.format("Don't know how to determine the cache directory for scope of type %s.", scope.getClass().getSimpleName()));
}
项目:gradle-java-modules    文件:JigsawPlugin.java   
private void configureCompileTestJavaTask(final Project project) {
    final JavaCompile compileTestJava = (JavaCompile) project.getTasks()
            .findByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME);
    final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test");
    final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
    compileTestJava.getInputs().property("moduleName", module.geName());
    compileTestJava.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            List<String> args = new ArrayList<>();
            args.add("--module-path");
            args.add(compileTestJava.getClasspath().getAsPath());
            args.add("--add-modules");
            args.add("junit");
            args.add("--add-reads");
            args.add(module.geName() + "=junit");
            args.add("--patch-module");
            args.add(module.geName() + "=" + test.getJava().getSourceDirectories().getAsPath());
            compileTestJava.getOptions().setCompilerArgs(args);
            compileTestJava.setClasspath(project.files());
        }
    });
}
项目:ossindex-gradle-plugin    文件:OssIndexPlugin.java   
private void doAudit(Task task) {
    ArtifactGatherer gatherer = new ArtifactGatherer();
    Set<GradleArtifact> gradleArtifacts = gatherer.gatherResolvedArtifacts(task.getProject());
    DependencyAuditor auditor = new DependencyAuditor(gradleArtifacts);

    AuditResultReporter reporter = new AuditResultReporter(gradleArtifacts, getAuditExtensions(task.getProject()));

    logger.info(String.format("Found %s gradleArtifacts to audit", gradleArtifacts.size()));

    Collection<MavenPackageDescriptor> packagesWithVulnerabilities = auditor.runAudit();

    try {
        reporter.reportResult(packagesWithVulnerabilities);
    } catch (GradleException e) {
        if (shouldFailOnError(task.getProject())) {
            throw e;
        }
    } finally {
        PackageTreeReporter treeReporter = new PackageTreeReporter(getAuditExtensions(task.getProject()));
        treeReporter.reportDependencyTree(gradleArtifacts, packagesWithVulnerabilities);
    }

}
项目:Reer    文件:DefaultCacheScopeMapping.java   
public File getBaseDirectory(Object scope, String key, VersionStrategy versionStrategy) {
    if (key.equalsIgnoreCase("projects") || key.equalsIgnoreCase("tasks") || !key.matches("\\p{Alpha}+[-//.\\w]*")) {
        throw new IllegalArgumentException(String.format("Unsupported cache key '%s'.", key));
    }
    File cacheRootDir = getRootDirectory(scope);
    String subDir = key;
    if (scope instanceof Project) {
        Project project = (Project) scope;
        subDir = "projects/" + project.getPath().replace(':', '_') + "/" + key;
    }
    if (scope instanceof Task) {
        Task task = (Task) scope;
        subDir = "tasks/" + task.getPath().replace(':', '_') + "/" + key;
    }
    return getCacheDir(cacheRootDir, versionStrategy, subDir);
}
项目:Reer    文件:JacocoReport.java   
public JacocoReport() {
    reports = getInstantiator().newInstance(JacocoReportsContainerImpl.class, this);
    onlyIf(new Spec<Task>() {
        @Override
        public boolean isSatisfiedBy(Task element) {
            //TODO SF it should be 'any' instead of 'all'
            return Iterables.all(getExecutionData(), new Predicate<File>() {
                @Override
                public boolean apply(File file) {
                    return file.exists();
                }

            });
        }

    });
}
项目:Reer    文件:TaskMutator.java   
public ContextAwareTaskAction leftShift(final ContextAwareTaskAction action) {
    return new ContextAwareTaskAction() {
        public void execute(Task task) {
            executingleftShiftAction = true;
            try {
                action.execute(task);
            } finally {
                executingleftShiftAction = false;
            }
        }

        public void contextualise(TaskExecutionContext context) {
            action.contextualise(context);
        }

        @Override
        public ClassLoader getClassLoader() {
            return action.getClassLoader();
        }
    };
}
项目:Reer    文件:AbstractTask.java   
public void execute(Task task) {
    closure.setDelegate(task);
    closure.setResolveStrategy(Closure.DELEGATE_FIRST);
    ClassLoader original = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(closure.getClass().getClassLoader());
    try {
        if (closure.getMaximumNumberOfParameters() == 0) {
            closure.call();
        } else {
            closure.call(task);
        }
    } catch (InvokerInvocationException e) {
        Throwable cause = e.getCause();
        if (cause instanceof RuntimeException) {
            throw (RuntimeException) cause;
        }
        throw e;
    } finally {
        Thread.currentThread().setContextClassLoader(original);
    }
}
项目:Reer    文件:NativeComponentModelPlugin.java   
@Mutate
void configurePreCompiledHeaderCompileTasks(final TaskContainer tasks, BinaryContainer binaries, final LanguageTransformContainer languageTransforms, final ServiceRegistry serviceRegistry) {
    for (final NativeBinarySpecInternal nativeBinarySpec : binaries.withType(NativeBinarySpecInternal.class)) {
        for (final PchEnabledLanguageTransform<?> transform : languageTransforms.withType(PchEnabledLanguageTransform.class)) {
            nativeBinarySpec.getInputs().withType(transform.getSourceSetType(), new Action<LanguageSourceSet>() {
                @Override
                public void execute(final LanguageSourceSet languageSourceSet) {
                    final DependentSourceSet dependentSourceSet = (DependentSourceSet) languageSourceSet;
                    if (dependentSourceSet.getPreCompiledHeader() != null) {
                        nativeBinarySpec.addPreCompiledHeaderFor(dependentSourceSet);
                        final SourceTransformTaskConfig pchTransformTaskConfig = transform.getPchTransformTask();
                        String pchTaskName = pchTransformTaskConfig.getTaskPrefix() + StringUtils.capitalize(nativeBinarySpec.getProjectScopedName()) + StringUtils.capitalize(dependentSourceSet.getName()) + "PreCompiledHeader";
                        Task pchTask = tasks.create(pchTaskName, pchTransformTaskConfig.getTaskType(), new Action<DefaultTask>() {
                            @Override
                            public void execute(DefaultTask task) {
                                pchTransformTaskConfig.configureTask(task, nativeBinarySpec, dependentSourceSet, serviceRegistry);
                            }
                        });
                        nativeBinarySpec.getTasks().add(pchTask);
                    }
                }
            });
        }
    }
}
项目:atlas    文件:TaskQueryHelper.java   
public static <T extends Task> List<T> findTask(Project project, Class<T> clazz, BaseVariantData vod) {

        Task[] androidTasks = project.getTasks().withType(clazz).toArray(new Task[0]);

        String variantName = vod.getName();

        List<Task> taskList = new ArrayList();
        for (Task task : androidTasks) {
            if (task instanceof DefaultAndroidTask) {
                if (variantName.equals(((DefaultAndroidTask)task).getVariantName())) {
                    taskList.add(task);
                }
            } else {

                String name = task.getName();
                if (name.toLowerCase().contains(variantName)) {
                    taskList.add(task);
                }
            }

        }
        return (List<T>)taskList;
    }
项目:Reer    文件:DefaultTaskContainer.java   
@Override
public void prepareForExecution(Task task) {
    assert task.getProject() == project;
    if (modelNode.hasLink(task.getName())) {
        realizeTask(MODEL_PATH.child(task.getName()), ModelNode.State.GraphClosed);
    }
}
项目:crnk-framework    文件:TSGeneratorPlugin.java   
private void setupRuntimeDependencies(Project project, Task generateTask) {
    TSGeneratorConfig config = project.getExtensions().getByType(TSGeneratorConfig.class);
    String runtimeConfiguration = config.getRuntime().getConfiguration();
    if (runtimeConfiguration != null) {
        String runtimeConfigurationFirstUpper =
                Character.toUpperCase(runtimeConfiguration.charAt(0)) + runtimeConfiguration.substring(1);

        // make sure applications is compiled in order to startup and extract meta information
        String processResourcesName = "process" + runtimeConfigurationFirstUpper + "Resources";
        String compileJavaName = "compile" + runtimeConfigurationFirstUpper + "Java";
        TaskContainer tasks = project.getTasks();
        Task processResourceTask = tasks.findByName(processResourcesName);
        Task compileJavaTask = tasks.findByName(compileJavaName);
        if (processResourceTask != null) {
            generateTask.dependsOn(processResourceTask);
        }
        if (compileJavaTask != null) {
            generateTask.dependsOn(compileJavaTask, compileJavaTask);
        }

        // setup up-to-date checking
        Configuration compileConfiguration = project.getConfigurations().findByName(runtimeConfiguration);
        if (compileConfiguration != null) {
            generateTask.getInputs().file(compileConfiguration.getFiles());
            generateTask.getOutputs().dir(config.getGenDir());
        }
    }
}
项目:Reer    文件:AbstractTask.java   
public Task doLast(final Action<? super Task> action) {
    hasCustomActions = true;
    if (action == null) {
        throw new InvalidUserDataException("Action must not be null!");
    }
    taskMutator.mutate("Task.doLast(Action)", new Runnable() {
        public void run() {
            actions.add(wrap(action));
        }
    });
    return this;
}
项目:Reer    文件:DefaultProject.java   
public Map<Project, Set<Task>> getAllTasks(boolean recursive) {
    final Map<Project, Set<Task>> foundTargets = new TreeMap<Project, Set<Task>>();
    Action<Project> action = new Action<Project>() {
        public void execute(Project project) {
            foundTargets.put(project, new TreeSet<Task>(project.getTasks()));
        }
    };
    if (recursive) {
        allprojects(action);
    } else {
        action.execute(this);
    }
    return foundTargets;
}
项目:Reer    文件:EclipseWtpPlugin.java   
private <T extends Task> void maybeAddTask(Project project, IdePlugin plugin, String taskName, Class<T> taskType, Action<T> action) {
    if (project.getTasks().findByName(taskName) != null) {
        return;

    }

    T task = project.getTasks().create(taskName, taskType);
    action.execute(task);
    plugin.addWorker(task);
}
项目:gradle-circle-style    文件:CircleStylePlugin.java   
private void configureCheckstyleTask(
        final Project project,
        final Checkstyle checkstyleTask,
        final String circleReportsDir,
        final StyleTaskTimer timer) {
    // Ensure XML output is enabled
    checkstyleTask.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            checkstyleTask.getReports().findByName("xml").setEnabled(true);
        }
    });

    // Configure the finalizer task
    CircleStyleFinalizer finalizer = createTask(
            project.getTasks(),
            checkstyleTask.getName() + "CircleFinalizer",
            CircleStyleFinalizer.class);
    if (finalizer == null) {
        // Already registered (happens if the user applies us to the root project and subprojects)
        return;
    }
    finalizer.setReportParser(CheckstyleReportHandler.PARSER);
    finalizer.setStyleTask(checkstyleTask);
    finalizer.setReporting(checkstyleTask);
    finalizer.setStyleTaskTimer(timer);
    finalizer.setTargetFile(new File(
            new File(circleReportsDir, "checkstyle"),
            project.getName() + "-" + checkstyleTask.getName() + ".xml"));

    checkstyleTask.finalizedBy(finalizer);
}
项目:Reer    文件:NativeComponentModelPlugin.java   
/**
 * Can't use @BinaryTasks because the binary is not _built-by_ the install task, but it is associated with it. Rule is called multiple times, so need to check for task existence before
 * creating.
 */
@Defaults
void createInstallTasks(ModelMap<Task> tasks, BinaryContainer binaries) {
    for (NativeExecutableBinarySpecInternal binary : binaries.withType(NativeExecutableBinarySpecInternal.class).values()) {
        NativeComponents.createInstallTask(binary, binary.getInstallation(), binary.getExecutable(), binary.getNamingScheme());
    }
}
项目:Reer    文件:DefaultTaskGraphExecuter.java   
public void beforeTask(final Action<Task> action) {
    taskListeners.add(new TaskExecutionAdapter() {
        @Override
        public void beforeExecute(Task task) {
            action.execute(task);
        }
    });
}
项目:Reer    文件:DefaultTaskClassValidatorExtractor.java   
@Override
public TaskClassValidator extractValidator(Class<? extends Task> type) {
    ImmutableSet.Builder<TaskPropertyInfo> validatedPropertiesBuilder = ImmutableSet.builder();
    ImmutableSet.Builder<String> nonAnnotatedPropertiesBuilder = ImmutableSortedSet.naturalOrder();
    Queue<TypeEntry> queue = new ArrayDeque<TypeEntry>();
    queue.add(new TypeEntry(null, type));
    while (!queue.isEmpty()) {
        TypeEntry entry = queue.remove();
        parseProperties(entry.parent, entry.type, validatedPropertiesBuilder, nonAnnotatedPropertiesBuilder, queue);
    }
    return new TaskClassValidator(validatedPropertiesBuilder.build(), nonAnnotatedPropertiesBuilder.build());
}
项目:Reer    文件:AbstractTask.java   
public void setOnlyIf(final Spec<? super Task> spec) {
    taskMutator.mutate("Task.setOnlyIf(Spec)", new Runnable() {
        public void run() {
            onlyIfSpec = createNewOnlyIfSpec().and(spec);
        }
    });
}
项目:Reer    文件:DefaultTaskGraphExecuter.java   
public void addTasks(Iterable<? extends Task> tasks) {
    assert tasks != null;

    final Timer clock = Timers.startTimer();

    Set<Task> taskSet = new LinkedHashSet<Task>();
    for (Task task : tasks) {
        taskSet.add(task);
    }
    taskExecutionPlan.addToTaskGraph(taskSet);
    taskGraphState = TaskGraphState.DIRTY;

    LOGGER.debug("Timing: Creating the DAG took " + clock.getElapsed());
}
项目:Reer    文件:CharSourceBackedTextResource.java   
@Override
public TaskDependency getBuildDependencies() {
    return new TaskDependency() {
        @Override
        public Set<? extends Task> getDependencies(Task task) {
            return Collections.emptySet();
        }
    };
}
项目:Reer    文件:DistributionPlugin.java   
@Override
public void apply(final ProjectInternal project) {
    project.getPluginManager().apply(BasePlugin.class);
    DefaultDistributionContainer distributions = project.getExtensions().create("distributions", DefaultDistributionContainer.class, Distribution.class, instantiator, fileOperations);

    // TODO - refactor this action out so it can be unit tested
    distributions.all(new Action<Distribution>() {
        @Override
        public void execute(final Distribution dist) {
            ((IConventionAware) dist).getConventionMapping().map("baseName", new Callable<Object>() {
                @Override
                public Object call() throws Exception {
                    return dist.getName().equals(MAIN_DISTRIBUTION_NAME) ? project.getName() : String.format("%s-%s", project.getName(), dist.getName());
                }
            });

            dist.getContents().from("src/" + dist.getName() + "/dist");
            String zipTaskName = MAIN_DISTRIBUTION_NAME.equals(dist.getName()) ? TASK_DIST_ZIP_NAME : dist.getName() + "DistZip";
            Task zipTask = configureArchiveTask(project, zipTaskName, dist, Zip.class);
            String tarTaskName = MAIN_DISTRIBUTION_NAME.equals(dist.getName()) ? TASK_DIST_TAR_NAME : dist.getName() + "DistTar";
            Task tarTask = configureArchiveTask(project, tarTaskName, dist, Tar.class);
            addAssembleTask(project, dist, zipTask, tarTask);
            addInstallTask(project, dist);
        }
    });
    distributions.create(MAIN_DISTRIBUTION_NAME);
}
项目:Reer    文件:EclipsePlugin.java   
private static LocalComponentArtifactMetadata createArtifact(String extension, ProjectComponentIdentifier projectId, String projectName, Project project) {
    File projectFile = new File(project.getProjectDir(), "." + extension);
    Task byName = project.getTasks().getByName("eclipseProject");
    String type = "eclipse." + extension;
    PublishArtifact publishArtifact = new DefaultPublishArtifact(projectName, extension, type, null, null, projectFile, byName);
    return new PublishArtifactLocalArtifactMetadata(projectId, publishArtifact);
}
项目:Reer    文件:DefaultTaskContainer.java   
public Task getByPath(String path) throws UnknownTaskException {
    Task task = findByPath(path);
    if (task == null) {
        throw new UnknownTaskException(String.format("Task with path '%s' not found in %s.", path, project));
    }
    return task;
}
项目:Reer    文件:AbstractTask.java   
public Task finalizedBy(final Object... paths) {
    taskMutator.mutate("Task.finalizedBy(Object...)", new Runnable() {
        public void run() {
            finalizedBy.add(paths);
        }
    });
    return this;
}
项目:Reer    文件:TaskSelector.java   
public boolean isSatisfiedBy(Task element) {
    if (!element.getName().equals(taskName)) {
        return true;
    }
    for (Project current = element.getProject(); current != null; current = current.getParent()) {
        if (current.equals(targetProject)) {
            return false;
        }
    }
    return true;
}
项目:Reer    文件:JavaGradlePluginPlugin.java   
public void execute(Task task) {
    if (descriptors == null || descriptors.isEmpty()) {
        LOGGER.warn(String.format(NO_DESCRIPTOR_WARNING_MESSAGE, task.getPath()));
    } else {
        Set<String> pluginFileNames = Sets.newHashSet();
        for (PluginDescriptor descriptor : descriptors) {
            URI descriptorURI = null;
            try {
                descriptorURI = descriptor.getPropertiesFileUrl().toURI();
            } catch (URISyntaxException e) {
                // Do nothing since the only side effect is that we wouldn't
                // be able to log the plugin descriptor file name.  Shouldn't
                // be a reasonable scenario where this occurs since these
                // descriptors should be generated from real files.
            }
            String pluginFileName = descriptorURI != null ? new File(descriptorURI).getName() : "UNKNOWN";
            pluginFileNames.add(pluginFileName);
            String pluginImplementation = descriptor.getImplementationClassName();
            if (pluginImplementation.length() == 0) {
                LOGGER.warn(String.format(INVALID_DESCRIPTOR_WARNING_MESSAGE, task.getPath(), pluginFileName));
            } else if (!hasFullyQualifiedClass(pluginImplementation)) {
                LOGGER.warn(String.format(BAD_IMPL_CLASS_WARNING_MESSAGE, task.getPath(), pluginFileName, pluginImplementation));
            }
        }
        for (PluginDeclaration declaration : plugins) {
            if (!pluginFileNames.contains(declaration.getId() + ".properties")) {
                LOGGER.warn(String.format(DECLARED_PLUGIN_MISSING_MESSAGE, task.getPath(), declaration.getName(), declaration.getId()));
            }
        }
    }
}
项目:Reer    文件:JavaBasePlugin.java   
private void configureBuildDependents(Project project) {
    DefaultTask buildTask = project.getTasks().create(BUILD_DEPENDENTS_TASK_NAME, DefaultTask.class);
    buildTask.setDescription("Assembles and tests this project and all projects that depend on it.");
    buildTask.setGroup(BasePlugin.BUILD_GROUP);
    buildTask.dependsOn(BUILD_TASK_NAME);
    buildTask.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            if (!task.getProject().getGradle().getIncludedBuilds().isEmpty()) {
                task.getProject().getLogger().warn("[composite-build] Warning: `" + task.getPath() + "` task does not build included builds.");
            }
        }
    });
}
项目:junit-reporter    文件:TestHTMLReporterPluginTest.java   
@Test
public void taskIsAppliedToProject() {
    try {
        addExceptionType(NoClassDefFoundError.class);
        Project project = builder().build();
        project.getPlugins().apply(JavaPlugin.class);
        project.getPlugins().apply(TestHTMLReporterPlugin.class);

        Task task = project.getTasks().getByName("junitHtmlReport");
        assertNotNull(task);
    } catch (NoClassDefFoundError e) {
        //suppressed for Maven :(
    }
}
项目:Reer    文件:FindBugsReportsImpl.java   
public FindBugsReportsImpl(Task task) {
    super(SingleFileReport.class, task);

    add(FindBugsXmlReportImpl.class, "xml", task);
    add(CustomizableHtmlReportImpl.class, "html", task);
    add(TaskGeneratedSingleFileReport.class, "text", task);
    add(TaskGeneratedSingleFileReport.class, "emacs", task);
}
项目:Reer    文件:DefaultTaskClassInfoStore.java   
private Factory<Action<Task>> createActionFactory(final Method method, final Class<?>[] parameterTypes) {
    return new Factory<Action<Task>>() {
        public Action<Task> create() {
            if (parameterTypes.length == 1) {
                return new IncrementalTaskAction(method);
            } else {
                return new StandardTaskAction(method);
            }
        }
    };
}
项目:atlas    文件:MtlBaseTaskAction.java   
protected void setFieldValueByReflection(Task task, String fieldName, Object value) {
    Field field = FieldUtils.getField(task.getClass(), fieldName, true);
    if (null == field) {
        throw new StopExecutionException("The field with name:" +
                                                 fieldName +
                                                 " does not existed in class:" +
                                                 task.getClass().getName());
    }
    try {
        FieldUtils.writeField(field, task, value, true);
    } catch (IllegalAccessException e) {
        throw new StopExecutionException(e.getMessage());
    }
}
项目:Reer    文件:Sign.java   
/**
 * Configures the task to sign the archive produced for each of the given tasks (which must be archive tasks).
 */
public void sign(Task... tasks) {
    for (Task task : tasks) {
        if (!(task instanceof AbstractArchiveTask)) {
            throw new InvalidUserDataException("You cannot sign tasks that are not \'archive\' tasks, such as \'jar\', \'zip\' etc. (you tried to sign " + String.valueOf(task) + ")");
        }

        signTask((AbstractArchiveTask) task);
    }

}
项目:Reer    文件:ProjectConverter.java   
/**
 * Adds the tasks from the project to the GradleProject.
 *
 * @param project the source parent project. Where we get the sub projects from.
 * @param projectView the destination of the tasks from project.
 */
private void addTasks(Project project, ProjectView projectView) {
    List<String> defaultTasks = project.getDefaultTasks();
    for (Task task : taskLister.listProjectTasks(project)) {
        String taskName = task.getName();

        boolean isDefault = defaultTasks.contains(taskName);

        projectView.createTask(taskName, task.getDescription(), isDefault);
    }
}
项目:Reer    文件:AbstractReportTask.java   
protected AbstractReportTask() {
    getOutputs().upToDateWhen(new Spec<Task>() {
        public boolean isSatisfiedBy(Task element) {
            return false;
        }
    });
    projects = new HashSet<Project>();
    projects.add(getProject());
}