use of org.gradle.api.tasks.TaskAction in project cayenne by apache.
the class DbGenerateTask method generateDb.
@TaskAction
public void generateDb() throws GradleException {
dataSource.validate();
getLogger().info("connection settings - [driver: {}, url: {}, username: {}]", dataSource.getDriver(), dataSource.getUrl(), dataSource.getUsername());
getLogger().info("generator options - " + "[dropTables: {}, dropPK: {}, createTables: {}, createPK: {}, createFK: {}]", dropTables, dropPK, createTables, createPK, createFK);
Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(getLogger()));
try {
DbGenerator generator = createGenerator(loadDataMap(injector));
generator.runGenerator(createDataSource());
} catch (Exception ex) {
Throwable th = Util.unwindException(ex);
String message = "Error generating database";
if (th.getLocalizedMessage() != null) {
message += ": " + th.getLocalizedMessage();
}
getLogger().error(message);
throw new GradleException(message, th);
}
}
use of org.gradle.api.tasks.TaskAction in project cayenne by apache.
the class DbImportTask method runImport.
@TaskAction
public void runImport() {
dataSource.validate();
DbImportConfiguration config = createConfig();
Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(getLogger()), new DbImportModule());
DbImportConfigurationValidator validator = new DbImportConfigurationValidator(reverseEngineering, config, injector);
try {
validator.validate();
} catch (Exception ex) {
throw new TaskExecutionException(this, ex);
}
try {
injector.getInstance(DbImportAction.class).execute(config);
} catch (Exception ex) {
Throwable th = Util.unwindException(ex);
String message = "Error importing database schema";
if (th.getLocalizedMessage() != null) {
message += ": " + th.getLocalizedMessage();
}
getLogger().error(message);
throw new TaskExecutionException(this, th);
}
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class InstallXCTestBundle method install.
@TaskAction
void install() throws IOException {
File bundleFile = bundleBinaryFile.get().getAsFile();
File bundleDir = installDirectory.get().file(bundleFile.getName() + ".xctest").getAsFile();
installToDir(bundleDir, bundleFile);
File runScript = getRunScriptFile().get().getAsFile();
String runScriptText = "#!/bin/sh" + "\nAPP_BASE_NAME=`dirname \"$0\"`" + "\nXCTEST_LOCATION=`xcrun --find xctest`" + "\nexec \"$XCTEST_LOCATION\" \"$@\" \"$APP_BASE_NAME/" + bundleDir.getName() + "\"" + "\n";
GFileUtils.writeFile(runScriptText, runScript);
getFileSystem().chmod(runScript, 0755);
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class AbstractTestTask method executeTests.
@TaskAction
public void executeTests() {
if (getFilter().isFailOnNoMatchingTests() && (!getFilter().getIncludePatterns().isEmpty() || !filter.getCommandLineIncludePatterns().isEmpty())) {
addTestListener(new NoMatchingTestsReporter(createNoMatchingTestErrorMessage()));
}
LogLevel currentLevel = determineCurrentLogLevel();
TestLogging levelLogging = getTestLogging().get(currentLevel);
TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
TestEventLogger eventLogger = new TestEventLogger(getTextOutputFactory(), currentLevel, levelLogging, exceptionFormatter);
addTestListener(eventLogger);
addTestOutputListener(eventLogger);
TestExecutionSpec executionSpec = createTestExecutionSpec();
File binaryResultsDir = getBinResultsDir();
getProject().delete(binaryResultsDir);
getProject().mkdir(binaryResultsDir);
Map<String, TestClassResult> results = new HashMap<String, TestClassResult>();
TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir);
TestOutputStore.Writer outputWriter = testOutputStore.writer();
TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter);
addTestListener(testReportDataCollector);
addTestOutputListener(testReportDataCollector);
TestCountLogger testCountLogger = new TestCountLogger(getProgressLoggerFactory());
addTestListener(testCountLogger);
getTestListenerInternalBroadcaster().add(new TestListenerAdapter(testListenerBroadcaster.getSource(), getTestOutputListenerBroadcaster().getSource()));
ProgressLogger parentProgressLogger = getProgressLoggerFactory().newOperation(AbstractTestTask.class);
parentProgressLogger.setDescription("Test Execution");
parentProgressLogger.started();
TestWorkerProgressListener testWorkerProgressListener = new TestWorkerProgressListener(getProgressLoggerFactory(), parentProgressLogger);
getTestListenerInternalBroadcaster().add(testWorkerProgressListener);
TestExecuter testExecuter = createTestExecuter();
TestListenerInternal resultProcessorDelegate = getTestListenerInternalBroadcaster().getSource();
if (failFast) {
resultProcessorDelegate = new FailFastTestListenerInternal(testExecuter, resultProcessorDelegate);
}
TestResultProcessor resultProcessor = new StateTrackingTestResultProcessor(resultProcessorDelegate);
try {
testExecuter.execute(executionSpec, resultProcessor);
} finally {
parentProgressLogger.completed();
testWorkerProgressListener.completeAll();
testListenerBroadcaster.removeAll();
getTestOutputListenerBroadcaster().removeAll();
getTestListenerInternalBroadcaster().removeAll();
outputWriter.close();
}
new TestResultSerializer(binaryResultsDir).write(results.values());
createReporting(results, testOutputStore);
if (testCountLogger.hadFailures()) {
handleTestFailures();
}
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class InitBuild method setupProjectLayout.
@TaskAction
public void setupProjectLayout() {
final String type = getType();
BuildInitDsl dsl = BuildInitDsl.fromName(getDsl());
BuildInitTestFramework testFramework = BuildInitTestFramework.fromName(getTestFramework());
final ProjectLayoutSetupRegistry projectLayoutRegistry = getProjectLayoutRegistry();
if (!projectLayoutRegistry.supports(type)) {
String supportedTypes = Joiner.on(", ").join(Iterables.transform(projectLayoutRegistry.getSupportedTypes(), new Function<String, String>() {
@Override
public String apply(String input) {
return "'" + input + "'";
}
}));
throw new GradleException("The requested build setup type '" + type + "' is not supported. Supported types: " + supportedTypes + ".");
}
ProjectInitDescriptor initDescriptor = projectLayoutRegistry.get(type);
if (!testFramework.equals(BuildInitTestFramework.NONE) && !initDescriptor.supports(testFramework)) {
throw new GradleException("The requested test framework '" + testFramework.getId() + "' is not supported in '" + type + "' setup type");
}
initDescriptor.generate(dsl, testFramework);
}
Aggregations