GradleExec { public ProcessResult executeTask(String task) throws Exception { BaseArgs args = _blade.getArgs(); File baseDir = args.getBase(); return executeTask(task, baseDir, true); } GradleExec(BladeCLI blade); ProcessResult executeTask(String task); ProcessResult executeTask(String task, boolean captureOutput); ProcessResult executeTask(String task, File baseDir); ProcessResult executeTask(String task, File baseDir, boolean captureOutput);  }
@Test public void testGradleWrapper() throws Exception { File workspace70 = new File(_rootPath.toFile(), "workspace70"); _makeWorkspaceVersion(workspace70, BladeTest.PRODUCT_VERSION_PORTAL_70); String[] args = {"--base", workspace70.toString(), "create", "-t", "api", "foo"}; _getBladeTest().run(args); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); BladeTest.BladeTestBuilder bladeTestBuilder = BladeTest.builder(); bladeTestBuilder.setExtensionsDir(_extensionsPath); bladeTestBuilder.setSettingsDir(_rootPath); bladeTestBuilder.setStdOut(ps); BladeCLI bladeCLI = bladeTestBuilder.build(); GradleExec gradleExec = new GradleExec(bladeCLI); ProcessResult result = gradleExec.executeTask("tasks"); int resultCode = result.getResultCode(); String output = result.get(); if (resultCode > 0) { Assert.assertEquals( "Gradle command returned error code " + resultCode + System.lineSeparator() + output, 0, resultCode); } else { Assert.assertFalse( "Gradle build failed " + System.lineSeparator() + output, output.contains("BUILD FAILED")); } }