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


Java GradleRunner类代码示例

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


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

示例1: findsUniqueBuildStepsReportFileName

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void findsUniqueBuildStepsReportFileName() throws IOException {
    assertTrue(new File(reportsDir, "gradle").mkdirs());
    assertTrue(new File(reportsDir, "gradle/build.xml").createNewFile());
    assertTrue(new File(reportsDir, "gradle/build2.xml").createNewFile());

    BuildResult result = GradleRunner.create()
            .withProjectDir(projectDir.getRoot())
            .withArguments("--stacktrace", "failingTask")
            .buildAndFail();
    assertThat(result.getOutput()).contains("This task will always fail");

    File report = new File(reportsDir, "gradle/build3.xml");
    assertThat(report).exists();
    String reportXml = Files.asCharSource(report, UTF_8).read();
    assertThat(reportXml).contains("message=\"RuntimeException: This task will always fail\"");
}
 
开发者ID:palantir,项目名称:gradle-circle-style,代码行数:18,代码来源:CircleStylePluginTests.java

示例2: testHelloWorldTask

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void testHelloWorldTask() throws IOException {
    String buildFileContent = "task helloWorld {" +
                              "    doLast {" +
                              "        println 'Hello world!'" +
                              "    }" +
                              "}";
    writeFile(buildFile, buildFileContent);

    BuildResult result = GradleRunner.create()
        .withProjectDir(testProjectDir.getRoot())
        .withArguments("helloWorld")
        .build();

    assertTrue(result.getOutput().contains("Hello world!"));
    assertEquals(result.task(":helloWorld").getOutcome(), SUCCESS);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:BuildLogicFunctionalTest.java

示例3: assertBuild

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
private void assertBuild(String project, String[] expectedGavtcs) throws IOException {
    SrcdepsCoreUtils.deleteDirectory(testProjectRootDir);
    SrcdepsCoreUtils.copyDirectory(quickstartsDir.resolve(project), testProjectRootDir);
    List<Path> expectedToExist = new ArrayList<>();
    for (String gavtcPattern : expectedGavtcs) {
        for (Gavtc gavtc : Gavtc.ofPattern(gavtcPattern)) {
            SrcdepsCoreUtils.deleteDirectory(mvnLocalRepo.resolveGroup(gavtc.getGroupId()));
            expectedToExist.add(mvnLocalRepo.resolve(gavtc));
        }
    }

    BuildResult result = GradleRunner.create() //
            .withProjectDir(testProjectRootDir.toFile()) //
            .withArguments("clean", "build", "install") //
            .build();

    Assert.assertEquals(result.task(":test").getOutcome(), SUCCESS);

    for (Path p : expectedToExist) {
        assertExists(p);
    }
}
 
开发者ID:srcdeps,项目名称:srcdeps-gradle-plugin,代码行数:23,代码来源:SrcdepsGradlePluginTest.java

示例4: testExplodeWar_withoutExtension

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void testExplodeWar_withoutExtension() throws IOException {
    loadBuildFileFromClasspath("exploded-archives_withoutExt.gradle");

    BuildResult result = GradleRunner.create()
            .withProjectDir(testProjectDir.getRoot())
            .withArguments("eW", "--stacktrace")
            .withPluginClasspath()
            .withDebug(true)
            .build();

    assertEquals(result.task(":explodeWar").getOutcome(), SUCCESS);

    String name = testProjectDir.getRoot().getName();

    File targetDir = new File(testProjectDir.getRoot(), "build/libs/exploded/" + name);

    assertThat(targetDir).exists();
    assertThat(targetDir).isDirectory();
}
 
开发者ID:freefair,项目名称:gradle-plugins,代码行数:21,代码来源:ExplodedArchivesPluginTest.java

示例5: testExplodeWar_withExtension

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void testExplodeWar_withExtension() throws IOException {
    loadBuildFileFromClasspath("exploded-archives_withExt.gradle");

    BuildResult result = GradleRunner.create()
            .withProjectDir(testProjectDir.getRoot())
            .withArguments("eW", "--stacktrace")
            .withPluginClasspath()
            .withDebug(true)
            .build();

    assertEquals(result.task(":explodeWar").getOutcome(), SUCCESS);

    String name = testProjectDir.getRoot().getName() + ".war";

    File targetDir = new File(testProjectDir.getRoot(), "build/libs/exploded/" + name);

    assertThat(targetDir).exists();
    assertThat(targetDir).isDirectory();
}
 
开发者ID:freefair,项目名称:gradle-plugins,代码行数:21,代码来源:ExplodedArchivesPluginTest.java

示例6: testExplodeWar_customDir

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void testExplodeWar_customDir() throws IOException {
    loadBuildFileFromClasspath("exploded-archives_customDir.gradle");

    BuildResult result = GradleRunner.create()
            .withProjectDir(testProjectDir.getRoot())
            .withArguments("eW", "--stacktrace")
            .withPluginClasspath()
            .withDebug(true)
            .build();

    assertEquals(result.task(":explodeWar").getOutcome(), SUCCESS);

    File targetDir = new File(testProjectDir.getRoot(), "build/foo");

    assertThat(targetDir).exists();
    assertThat(targetDir).isDirectory();
}
 
开发者ID:freefair,项目名称:gradle-plugins,代码行数:19,代码来源:ExplodedArchivesPluginTest.java

示例7: testDeploy

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void testDeploy() throws ProcessRunnerException, IOException {
  BuildResult buildResult =
      GradleRunner.create()
          .withProjectDir(testProjectDir.getRoot())
          .withPluginClasspath()
          .withDebug(true)
          .withArguments("appengineDeploy")
          .build();

  Assert.assertThat(
      buildResult.getOutput(),
      CoreMatchers.containsString("Deployed service [standard-project]"));

  CloudSdk cloudSdk =
      new CloudSdk.Builder().exitListener(new NonZeroExceptionExitListener()).build();
  cloudSdk.runAppCommand(Arrays.asList("services", "delete", "standard-project"));
}
 
开发者ID:GoogleCloudPlatform,项目名称:app-gradle-plugin,代码行数:19,代码来源:AppEngineStandardPluginIntegrationTest.java

示例8: testDeploy

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void testDeploy() throws ProcessRunnerException {

  BuildResult buildResult =
      GradleRunner.create()
          .withProjectDir(testProjectDir.getRoot())
          .withPluginClasspath()
          .withDebug(true)
          .withArguments("appengineDeploy")
          .build();

  Assert.assertThat(
      buildResult.getOutput(),
      CoreMatchers.containsString("Deployed service [flexible-project]"));

  CloudSdk cloudSdk =
      new CloudSdk.Builder().exitListener(new NonZeroExceptionExitListener()).build();
  cloudSdk.runAppCommand(Arrays.asList("services", "delete", "flexible-project"));
}
 
开发者ID:GoogleCloudPlatform,项目名称:app-gradle-plugin,代码行数:20,代码来源:AppEngineFlexiblePluginIntegrationTest.java

示例9: testCreateSourceContextViaAssemble_taskTree

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void testCreateSourceContextViaAssemble_taskTree() throws IOException {
  setUpTestProject();
  BuildResult buildResult =
      GradleRunner.create()
          .withProjectDir(testProjectDir.getRoot())
          .withPluginClasspath()
          .withArguments("assemble", "--dry-run")
          .build();

  final List<String> expected =
      Arrays.asList(
          ":_createSourceContext",
          ":compileJava",
          ":processResources",
          ":classes",
          ":war",
          ":explodeWar",
          ":assemble");

  Assert.assertEquals(expected, BuildResultFilter.extractTasks(buildResult));
}
 
开发者ID:GoogleCloudPlatform,项目名称:app-gradle-plugin,代码行数:23,代码来源:SourceContextPluginTest.java

示例10: executeGradleRunner

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
public static BuildTask executeGradleRunner(
	File projectDir, String... taskPath) {

	GradleRunner runner = GradleRunner.create().withProjectDir(projectDir);

	GradleRunner runnerWithArguments = runner.withArguments(taskPath);

	BuildResult buildResult = runnerWithArguments.build();

	BuildTask buildtask = null;

	for (BuildTask task : buildResult.getTasks()) {
		if (task.getPath().endsWith(taskPath[taskPath.length - 1])) {
			buildtask = task;
			break;
		}
	}

	return buildtask;
}
 
开发者ID:liferay,项目名称:liferay-blade-samples,代码行数:21,代码来源:GradleRunnerUtil.java

示例11: build

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
/** Copy project and run gradle build. */
public BuildResult build() throws URISyntaxException, IOException {
  FileUtils.copyDirectory(
      new File(getClass().getClassLoader().getResource(projectPathInResources).toURI()), testDir);
  if (application != null) {
    injectApplicationId(testDir, application);
  }
  if (hostname != null) {
    injectHostname(hostname);
  }
  if (basePath != null) {
    injectBasePath(basePath);
  }
  return GradleRunner.create()
      .withProjectDir(testDir)
      .withPluginClasspath()
      .withArguments(gradleRunnerArgs)
      .build();
}
 
开发者ID:GoogleCloudPlatform,项目名称:endpoints-framework-gradle-plugin,代码行数:20,代码来源:TestProject.java

示例12: javafxProguardGradleJfxJar

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void javafxProguardGradleJfxJar() {
    GRADLE_VERSIONS_TO_TEST_AGAINST.forEach(gradleVersion -> {
        GradleRunner runner = GradleRunner.create().withGradleVersion(gradleVersion).forwardOutput();

        try{
            Path targetFolder = Files.createTempDirectory("javafx-gradle-plugin-tests-" + this.getClass().getSimpleName() + "-javafxProguardGradle");
            Path sourceFolder = new File("examples/javafx-proguard-gradle").toPath();
            // create copyto work on
            copyFolderRecursive(sourceFolder, targetFolder);

            writePluginVersionIntoBuildScript(targetFolder);

            // run build
            BuildResult buildResult = runner.withProjectDir(targetFolder.toAbsolutePath().toFile())
                    .withArguments("clean", "jfxJar", "--stacktrace")
                    .withDebug(true)
                    .build();
        } catch(IOException e){

        }
    });
}
 
开发者ID:FibreFoX,项目名称:javafx-gradle-plugin,代码行数:24,代码来源:JavaFXProguardGradleExample.java

示例13: additionalBundlerFilesJfxNative

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void additionalBundlerFilesJfxNative() {
    GRADLE_VERSIONS_TO_TEST_AGAINST.forEach(gradleVersion -> {
        GradleRunner runner = GradleRunner.create().withGradleVersion(gradleVersion).forwardOutput();

        try{
            Path targetFolder = Files.createTempDirectory("javafx-gradle-plugin-tests-" + this.getClass().getSimpleName() + "-additionalBundlerFiles");
            Path sourceFolder = new File("examples/additional-bundler-files").toPath();
            // create copyto work on
            copyFolderRecursive(sourceFolder, targetFolder);

            writePluginVersionIntoBuildScript(targetFolder);

            // run build
            BuildResult buildResult = runner.withProjectDir(targetFolder.toAbsolutePath().toFile())
                    .withArguments("clean", "jfxNative", "--stacktrace")
                    .withDebug(true)
                    .build();
        } catch(IOException e){

        }
    });
}
 
开发者ID:FibreFoX,项目名称:javafx-gradle-plugin,代码行数:24,代码来源:AdditionalBundlerFiles.java

示例14: minimalSetupJfxNative

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void minimalSetupJfxNative() {
    GRADLE_VERSIONS_TO_TEST_AGAINST.forEach(gradleVersion -> {
        GradleRunner runner = GradleRunner.create().withGradleVersion(gradleVersion).forwardOutput();

        try{
            Path targetFolder = Files.createTempDirectory("javafx-gradle-plugin-tests-" + this.getClass().getSimpleName() + "-minimalSetupJfxNative");
            Path sourceFolder = new File("examples/minimal-setup-jfxnative").toPath();
            // create copyto work on
            copyFolderRecursive(sourceFolder, targetFolder);

            writePluginVersionIntoBuildScript(targetFolder);

            // run build
            BuildResult buildResult = runner.withProjectDir(targetFolder.toAbsolutePath().toFile())
                    .withArguments("clean", "jfxNative", "--stacktrace")
                    .withDebug(true)
                    .build();
            // TODO check result (currently this is only a "runs without problems"-test)
        } catch(IOException e){

        }
    });
}
 
开发者ID:FibreFoX,项目名称:javafx-gradle-plugin,代码行数:25,代码来源:MinimalProjectJfxNative.java

示例15: minimalSetupJfxNative

import org.gradle.testkit.runner.GradleRunner; //导入依赖的package包/类
@Test
public void minimalSetupJfxNative() {
    GRADLE_VERSIONS_TO_TEST_AGAINST.forEach(gradleVersion -> {
        GradleRunner runner = GradleRunner.create().withGradleVersion(gradleVersion).forwardOutput();

        try{
            Path targetFolder = Files.createTempDirectory("javafx-gradle-plugin-tests-" + this.getClass().getSimpleName() + "-minimalSetupWithoutJre");
            Path sourceFolder = new File("examples/minimal-setup-without-bundled-jre").toPath();
            // create copyto work on
            copyFolderRecursive(sourceFolder, targetFolder);

            writePluginVersionIntoBuildScript(targetFolder);

            // run build
            BuildResult buildResult = runner.withProjectDir(targetFolder.toAbsolutePath().toFile())
                    .withArguments("clean", "jfxNative", "--stacktrace")
                    .withDebug(true)
                    .build();
            // TODO check result (currently this is only a "runs without problems"-test)
        } catch(IOException e){

        }
    });
}
 
开发者ID:FibreFoX,项目名称:javafx-gradle-plugin,代码行数:25,代码来源:MinimalProjectWithoutJre.java


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