org.gradle.api.tasks.testing.Test.getClasspath()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(170)

本文整理了Java中org.gradle.api.tasks.testing.Test.getClasspath()方法的一些代码示例,展示了Test.getClasspath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Test.getClasspath()方法的具体详情如下:
包路径:org.gradle.api.tasks.testing.Test
类名称:Test
方法名:getClasspath

Test.getClasspath介绍

暂无

代码示例

代码示例来源:origin: gradle.plugin.org.gradle.java/experimental-jigsaw

@Override
  public void execute(Task task) {
    List<String> args = new ArrayList<>();
    args.add("--module-path");
    args.add(testTask.getClasspath().getAsPath());
    args.add("--add-modules");
    args.add("ALL-MODULE-PATH");
    args.add("--add-reads");
    args.add(module.geName() + "=junit");
    args.add("--patch-module");
    args.add(module.geName() + "=" + test.getJava().getOutputDir());
    testTask.setJvmArgs(args);
    testTask.setClasspath(project.files());
  }
});

代码示例来源:origin: typelead/gradle-eta

private void execute(Test test, TestResultProcessor resultProcessor) {
  execute(execSpec -> {
      test.copyTo(execSpec);
      execSpec.setClasspath(test.getClasspath());
    }, resultProcessor);
}

代码示例来源:origin: gradle.plugin.ru.javasaw/javasaw

@Override
public void configure(Task task) {
  LOGGER.info("running configurer for :" + task.getName());
  Test test = (Test) task;
  ModuleDefinition moduleDefinition = moduleInfoService.findModuleDefinition( task.getProject().getName()).orElse(null);
  if (moduleDefinition == null) {
    throw new IllegalStateException("Cant find module definition for " + task.getProject().getName() + " inside task " + task.getName());
  }
  test.doFirst(action -> {
    JavaSawExtension extension = (JavaSawExtension) project.getExtensions().getByName(JAVA_SAW_TEST_EXT_NAME);
    JavaCompileTaskArgs compilerArgs = argsPatcher.patch(test.getClasspath().getAsPath(), extension, moduleDefinition);
    CompileArg arg = compilerArgs.getArgByName(JavaCompileTaskArgs.MODULE_PATH);
    arg.getArguments().addAll(mainOutputDirsPath());
    List<String> compilerResultArgs = compilerArgs.getCompilerResultArgs();
    compilerResultArgs.add(ADD_READS);
    compilerResultArgs.add(moduleDefinition.getName() + "=" + "org.junit.jupiter.api"); // todo
    compilerResultArgs.add(PATCH_MODULE);
    compilerResultArgs.add(moduleDefinition.getName() + "=" + testOutputDirsPath());
    compilerResultArgs.add(ADD_MODULE);
    compilerResultArgs.add("ALL-MODULE-PATH"); // todo
    test.setJvmArgs(compilerResultArgs);
    LOGGER.debug("result jvm arguments is : " + test.getJvmArgs());
  });
}
private List<String> mainOutputDirsPath() {

代码示例来源:origin: gradle.plugin.org.javamodularity/moduleplugin

"--module-path", testJava.getClasspath().getAsPath(),
"--patch-module", moduleName + "=" + testSourceSet.getJava().getOutputDir().toPath(),
"--add-modules", "ALL-MODULE-PATH"

代码示例来源:origin: gradle.plugin.rgoldberg/java-modules

private void configureTestTask(final Test test, final ImmutableSet<String> moduleNameIset) {
  setModuleNamesInputProperty(test, moduleNameIset);
  test.doFirst(task -> {
    final Project project = test.getProject();
    final List<String> args = test.getJvmArgs();
    addModulePathArgument(args, test.getClasspath());
    args.add(OPTION_ADD_MODULES);
    args.add(ALL_MODULE_PATH);
    KnownTestFrameworkModuleInfo.from(test).configureTestTask(args, moduleNameIset);
    addPatchModuleArguments(args, moduleNameIset, project.files(getSourceSets(project).getByName(TEST_SOURCE_SET_NAME).getJava().getOutputDir()));
    test.setClasspath(project.files());
  });
}

代码示例来源:origin: gradle.plugin.de.monkeyworks.buildmonkey/gradle.pde

private List<String> collectTestNames(Test testTask) {
  ClassNameCollectingProcessor processor = new ClassNameCollectingProcessor();
  Runnable detector;
  final FileTree testClassFiles = testTask.getCandidateClassFiles();
  if (testTask.isScanForTestClasses()) {
    TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
    testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir());
    testFrameworkDetector.setTestClasspath(testTask.getClasspath());
    detector = new PluginTestClassScanner(testClassFiles, processor);
  } else {
    detector = new PluginTestClassScanner(testClassFiles, processor);
  }
  final Object testTaskOperationId = OperationIdGenerator.generateId(testTask);
  new TestMainAction(detector, processor, new NoOpTestResultProcessor(), new TrueTimeProvider(), testTaskOperationId, testTask.getPath(), String.format("Gradle Eclipse Test Run %s", testTask.getPath())).run();
  LOGGER.info("collected test class names: {}", processor.classNames);
  return processor.classNames;
}

相关文章