本文整理匯總了Java中org.gradle.api.Project.task方法的典型用法代碼示例。如果您正苦於以下問題:Java Project.task方法的具體用法?Java Project.task怎麽用?Java Project.task使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.gradle.api.Project
的用法示例。
在下文中一共展示了Project.task方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doesNothingIfTaskSkipped
import org.gradle.api.Project; //導入方法依賴的package包/類
@Test
public void doesNothingIfTaskSkipped() throws IOException, TransformerException {
Project project = ProjectBuilder.builder().withName("fooproject").withProjectDir(projectDir.getRoot()).build();
Checkstyle checkstyle = createCheckstyleTask(project);
checkstyle.setDidWork(false);
StyleTaskTimer timer = mock(StyleTaskTimer.class);
when(timer.getTaskTimeNanos(checkstyle)).thenReturn(FAILED_CHECKSTYLE_TIME_NANOS);
File targetFile = new File(projectDir.getRoot(), "reports/report.xml");
CircleStyleFinalizer finalizer = (CircleStyleFinalizer) project
.task(ImmutableMap.of("type", CircleStyleFinalizer.class), "checkstyleTestCircleFinalizer");
finalizer.setReportParser(CheckstyleReportHandler.PARSER);
finalizer.setStyleTask(checkstyle);
finalizer.setReporting(checkstyle);
finalizer.setStyleTaskTimer(timer);
finalizer.setTargetFile(targetFile);
finalizer.createCircleReport();
assertThat(targetFile).doesNotExist();
assertThat(finalizer.getDidWork()).isFalse();
}
示例2: translatesCheckstyleReport
import org.gradle.api.Project; //導入方法依賴的package包/類
@Test
public void translatesCheckstyleReport() throws IOException, TransformerException {
Project project = ProjectBuilder.builder().withName("fooproject").withProjectDir(projectDir.getRoot()).build();
Checkstyle checkstyle = createCheckstyleTask(project);
checkstyle.setDidWork(true);
StyleTaskTimer timer = mock(StyleTaskTimer.class);
when(timer.getTaskTimeNanos(checkstyle)).thenReturn(FAILED_CHECKSTYLE_TIME_NANOS);
File targetFile = new File(projectDir.getRoot(), "reports/report.xml");
CircleStyleFinalizer finalizer = (CircleStyleFinalizer) project
.task(ImmutableMap.of("type", CircleStyleFinalizer.class), "checkstyleTestCircleFinalizer");
finalizer.setReportParser(CheckstyleReportHandler.PARSER);
finalizer.setStyleTask(checkstyle);
finalizer.setReporting(checkstyle);
finalizer.setStyleTaskTimer(timer);
finalizer.setTargetFile(targetFile);
finalizer.createCircleReport();
String report = Resources.toString(targetFile.toURI().toURL(), UTF_8);
String expectedReport = Resources.toString(testFile("two-namecheck-failures-checkstyle-report.xml"), UTF_8);
assertThat(report).isEqualTo(expectedReport);
}
示例3: apply
import org.gradle.api.Project; //導入方法依賴的package包/類
@Override
public void apply(Project target) {
project = target;
String lifecycleTaskName = getLifecycleTaskName();
lifecycleTask = target.task(lifecycleTaskName);
lifecycleTask.setGroup("IDE");
cleanTask = target.task(cleanName(lifecycleTaskName));
cleanTask.setGroup("IDE");
onApply(target);
}
示例4: createBinaryLifecycleTask
import org.gradle.api.Project; //導入方法依賴的package包/類
private void createBinaryLifecycleTask(SourceSet sourceSet, Project target) {
sourceSet.compiledBy(sourceSet.getClassesTaskName());
Task binaryLifecycleTask = target.task(sourceSet.getClassesTaskName());
binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP);
binaryLifecycleTask.setDescription("Assembles " + sourceSet.getOutput() + ".");
binaryLifecycleTask.dependsOn(sourceSet.getOutput().getDirs());
binaryLifecycleTask.dependsOn(sourceSet.getCompileJavaTaskName());
binaryLifecycleTask.dependsOn(sourceSet.getProcessResourcesTaskName());
}
示例5: apply
import org.gradle.api.Project; //導入方法依賴的package包/類
@Override
public void apply(Project project) {
project.getExtensions().create("audit", AuditExtensions.class);
Task audit = project.task("audit");
audit.doLast(this::doAudit);
}