当前位置: 首页>>代码示例>>Java>>正文


Java Task类代码示例

本文整理汇总了Java中org.gradle.api.Task的典型用法代码示例。如果您正苦于以下问题:Java Task类的具体用法?Java Task怎么用?Java Task使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Task类属于org.gradle.api包,在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFilter

import org.gradle.api.Task; //导入依赖的package包/类
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);
        }
    };
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:TaskSelector.java

示例2: apply

import org.gradle.api.Task; //导入依赖的package包/类
@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());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:CleanRule.java

示例3: findTask

import org.gradle.api.Task; //导入依赖的package包/类
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;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:23,代码来源:MtlTaskInjector.java

示例4: execute

import org.gradle.api.Task; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:ComponentModelBasePlugin.java

示例5: configureRunTask

import org.gradle.api.Task; //导入依赖的package包/类
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());
        }
    });
}
 
开发者ID:gradle,项目名称:gradle-java-modules,代码行数:18,代码来源:JigsawPlugin.java

示例6: getRootDirectory

import org.gradle.api.Task; //导入依赖的package包/类
@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()));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:DefaultCacheScopeMapping.java

示例7: configureCompileTestJavaTask

import org.gradle.api.Task; //导入依赖的package包/类
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());
        }
    });
}
 
开发者ID:gradle,项目名称:gradle-java-modules,代码行数:24,代码来源:JigsawPlugin.java

示例8: doAudit

import org.gradle.api.Task; //导入依赖的package包/类
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);
    }

}
 
开发者ID:OSSIndex,项目名称:ossindex-gradle-plugin,代码行数:24,代码来源:OssIndexPlugin.java

示例9: getBaseDirectory

import org.gradle.api.Task; //导入依赖的package包/类
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);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:DefaultCacheScopeMapping.java

示例10: JacocoReport

import org.gradle.api.Task; //导入依赖的package包/类
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();
                }

            });
        }

    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:JacocoReport.java

示例11: leftShift

import org.gradle.api.Task; //导入依赖的package包/类
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();
        }
    };
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:22,代码来源:TaskMutator.java

示例12: execute

import org.gradle.api.Task; //导入依赖的package包/类
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);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:22,代码来源:AbstractTask.java

示例13: configurePreCompiledHeaderCompileTasks

import org.gradle.api.Task; //导入依赖的package包/类
@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);
                    }
                }
            });
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:26,代码来源:NativeComponentModelPlugin.java

示例14: findTask

import org.gradle.api.Task; //导入依赖的package包/类
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;
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:24,代码来源:TaskQueryHelper.java

示例15: prepareForExecution

import org.gradle.api.Task; //导入依赖的package包/类
@Override
public void prepareForExecution(Task task) {
    assert task.getProject() == project;
    if (modelNode.hasLink(task.getName())) {
        realizeTask(MODEL_PATH.child(task.getName()), ModelNode.State.GraphClosed);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:DefaultTaskContainer.java


注:本文中的org.gradle.api.Task类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。