use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class ScalaDoc method generate.
@TaskAction
protected void generate() {
ScalaDocOptions options = getScalaDocOptions();
if (!GUtil.isTrue(options.getDocTitle())) {
options.setDocTitle(getTitle());
}
AntScalaDoc antScalaDoc = new AntScalaDoc(getAntBuilder());
antScalaDoc.execute(getSource(), getDestinationDir(), getClasspath(), getScalaClasspath(), options);
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class PublishToMavenLocal method publish.
@TaskAction
public void publish() {
final MavenPublicationInternal publication = getPublicationInternal();
if (publication == null) {
throw new InvalidUserDataException("The 'publication' property is required");
}
new PublishOperation(publication, "mavenLocal") {
@Override
protected void publish() throws Exception {
MavenPublisher localPublisher = new MavenLocalPublisher(getLoggingManagerFactory(), getMavenRepositoryLocator());
MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(localPublisher);
MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher);
validatingPublisher.publish(publication.asNormalisedPublication(), null);
}
}.run();
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class PublishToMavenRepository method publish.
@TaskAction
public void publish() {
MavenPublicationInternal publicationInternal = getPublicationInternal();
if (publicationInternal == null) {
throw new InvalidUserDataException("The 'publication' property is required");
}
MavenArtifactRepository repository = getRepository();
if (repository == null) {
throw new InvalidUserDataException("The 'repository' property is required");
}
doPublish(publicationInternal, repository);
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class Test method executeTests.
@TaskAction
public void executeTests() {
LogLevel currentLevel = determineCurrentLogLevel();
TestLogging levelLogging = testLogging.get(currentLevel);
TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
TestEventLogger eventLogger = new TestEventLogger(getTextOutputFactory(), currentLevel, levelLogging, exceptionFormatter);
addTestListener(eventLogger);
addTestOutputListener(eventLogger);
if (getFilter().isFailOnNoMatchingTests() && !getFilter().getIncludePatterns().isEmpty()) {
addTestListener(new NoMatchingTestsReporter("No tests found for given includes: " + getFilter().getIncludePatterns()));
}
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);
testListenerInternalBroadcaster.add(new TestListenerAdapter(testListenerBroadcaster.getSource(), testOutputListenerBroadcaster.getSource()));
TestResultProcessor resultProcessor = new StateTrackingTestResultProcessor(testListenerInternalBroadcaster.getSource());
if (testExecuter == null) {
testExecuter = new DefaultTestExecuter(getProcessBuilderFactory(), getActorFactory(), getModuleRegistry(), getServices().get(BuildOperationWorkerRegistry.class), getServices().get(BuildOperationExecutor.class), getServices().get(StartParameter.class).getMaxWorkerCount());
}
JavaVersion javaVersion = getJavaVersion();
if (!javaVersion.isJava6Compatible()) {
throw new UnsupportedJavaRuntimeException("Support for test execution using Java 5 or earlier was removed in Gradle 3.0.");
}
try {
testExecuter.execute(this, resultProcessor);
} finally {
testExecuter = null;
testListenerBroadcaster.removeAll();
testOutputListenerBroadcaster.removeAll();
testListenerInternalBroadcaster.removeAll();
outputWriter.close();
}
new TestResultSerializer(binaryResultsDir).write(results.values());
TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore);
try {
if (testReporter == null) {
testReporter = new DefaultTestReport(getBuildOperationProcessor());
}
JUnitXmlReport junitXml = reports.getJunitXml();
if (junitXml.isEnabled()) {
TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase() ? TestOutputAssociation.WITH_TESTCASE : TestOutputAssociation.WITH_SUITE;
Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation, getBuildOperationProcessor(), getInetAddressFactory().getHostname());
binary2JUnitXmlReportGenerator.generate();
}
DirectoryReport html = reports.getHtml();
if (!html.isEnabled()) {
getLogger().info("Test report disabled, omitting generation of the HTML test report.");
} else {
testReporter.generateReport(testResultsProvider, html.getDestination());
}
} finally {
CompositeStoppable.stoppable(testResultsProvider).stop();
testReporter = null;
testFramework = null;
}
if (testCountLogger.hadFailures()) {
handleTestFailures();
}
}
use of org.gradle.api.tasks.TaskAction in project flyway by flyway.
the class AbstractFlywayTask method runTask.
@TaskAction
public Object runTask() {
try {
List<URL> extraURLs = new ArrayList<URL>();
if (isJavaProject()) {
JavaPluginConvention plugin = getProject().getConvention().getPlugin(JavaPluginConvention.class);
for (SourceSet sourceSet : plugin.getSourceSets()) {
URL classesUrl = sourceSet.getOutput().getClassesDir().toURI().toURL();
getLogger().debug("Adding directory to Classpath: " + classesUrl);
extraURLs.add(classesUrl);
URL resourcesUrl = sourceSet.getOutput().getResourcesDir().toURI().toURL();
getLogger().debug("Adding directory to Classpath: " + resourcesUrl);
extraURLs.add(resourcesUrl);
}
addDependenciesWithScope(extraURLs, "compile");
addDependenciesWithScope(extraURLs, "runtime");
addDependenciesWithScope(extraURLs, "testCompile");
addDependenciesWithScope(extraURLs, "testRuntime");
}
ClassLoader classLoader = new URLClassLoader(extraURLs.toArray(new URL[extraURLs.size()]), getProject().getBuildscript().getClassLoader());
Flyway flyway = new Flyway();
flyway.setClassLoader(classLoader);
flyway.configure(createFlywayConfig());
return run(flyway);
} catch (Exception e) {
handleException(e);
return null;
}
}
Aggregations