use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class JettyStop method stop.
@TaskAction
public void stop() {
if (getStopPort() == null) {
throw new InvalidUserDataException("Please specify a valid port");
}
if (getStopKey() == null) {
throw new InvalidUserDataException("Please specify a valid stopKey");
}
ProgressLogger progressLogger = getServices().get(ProgressLoggerFactory.class).newOperation(JettyStop.class).start("Stop Jetty server", "Stopping Jetty");
try {
Socket s = new Socket(InetAddress.getByName("127.0.0.1"), getStopPort());
s.setSoLinger(false, 0);
OutputStream out = s.getOutputStream();
out.write((getStopKey() + "\r\nstop\r\n").getBytes());
out.flush();
s.close();
} catch (ConnectException e) {
LOGGER.info("Jetty not running!");
} catch (Exception e) {
LOGGER.error("Exception during stopping", e);
} finally {
progressLogger.completed();
}
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class Help method displayHelp.
@TaskAction
void displayHelp() {
StyledTextOutput output = getTextOutputFactory().create(Help.class);
BuildClientMetaData metaData = getClientMetaData();
if (taskPath != null) {
printTaskHelp(output);
} else {
printDefaultHelp(output, metaData);
}
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class HtmlDependencyReportTask method generate.
@TaskAction
public void generate() {
if (!reports.getHtml().isEnabled()) {
setDidWork(false);
return;
}
HtmlDependencyReporter reporter = new HtmlDependencyReporter(getVersionSelectorScheme(), getVersionComparator());
reporter.render(getProjects(), reports.getHtml().getDestination());
getProject().getLogger().lifecycle("See the report at: {}", new ConsoleRenderer().asClickableFileUrl(reports.getHtml().getEntryPoint()));
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class BuildEnvironmentReportTask method generate.
@TaskAction
public void generate() {
ProjectReportGenerator projectReportGenerator = new ProjectReportGenerator() {
@Override
public void generateReport(Project project) throws IOException {
Configuration configuration = getProject().getBuildscript().getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION);
renderer.startConfiguration(configuration);
renderer.render(configuration);
renderer.completeConfiguration(configuration);
}
};
ReportGenerator reportGenerator = new ReportGenerator(renderer, getClientMetaData(), null, getTextOutputFactory(), projectReportGenerator);
reportGenerator.generateReport(Collections.singleton(getProject()));
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class Javadoc method generate.
@TaskAction
protected void generate() {
final File destinationDir = getDestinationDir();
StandardJavadocDocletOptions options = new StandardJavadocDocletOptions((StandardJavadocDocletOptions) getOptions());
if (options.getDestinationDirectory() == null) {
options.destinationDirectory(destinationDir);
}
options.classpath(new ArrayList<File>(getClasspath().getFiles()));
if (!GUtil.isTrue(options.getWindowTitle()) && GUtil.isTrue(getTitle())) {
options.windowTitle(getTitle());
}
if (!GUtil.isTrue(options.getDocTitle()) && GUtil.isTrue(getTitle())) {
options.setDocTitle(getTitle());
}
String maxMemory = getMaxMemory();
if (maxMemory != null) {
final List<String> jFlags = options.getJFlags();
final Iterator<String> jFlagsIt = jFlags.iterator();
boolean containsXmx = false;
while (!containsXmx && jFlagsIt.hasNext()) {
final String jFlag = jFlagsIt.next();
if (jFlag.startsWith("-Xmx")) {
containsXmx = true;
}
}
if (!containsXmx) {
options.jFlags("-Xmx" + maxMemory);
}
}
List<String> sourceNames = new ArrayList<String>();
for (File sourceFile : getSource()) {
sourceNames.add(sourceFile.getAbsolutePath());
}
options.setSourceNames(sourceNames);
executeExternalJavadoc(options);
}
Aggregations