Search in sources :

Example 11 with TaskAction

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();
    }
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) OutputStream(java.io.OutputStream) ProgressLogger(org.gradle.internal.logging.progress.ProgressLogger) Socket(java.net.Socket) ConnectException(java.net.ConnectException) InvalidUserDataException(org.gradle.api.InvalidUserDataException) ConnectException(java.net.ConnectException) TaskAction(org.gradle.api.tasks.TaskAction)

Example 12 with TaskAction

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);
    }
}
Also used : BuildClientMetaData(org.gradle.initialization.BuildClientMetaData) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) TaskAction(org.gradle.api.tasks.TaskAction)

Example 13 with TaskAction

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()));
}
Also used : HtmlDependencyReporter(org.gradle.api.reporting.dependencies.internal.HtmlDependencyReporter) ConsoleRenderer(org.gradle.internal.logging.ConsoleRenderer) TaskAction(org.gradle.api.tasks.TaskAction)

Example 14 with TaskAction

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()));
}
Also used : Project(org.gradle.api.Project) ProjectReportGenerator(org.gradle.api.tasks.diagnostics.internal.ProjectReportGenerator) ReportGenerator(org.gradle.api.tasks.diagnostics.internal.ReportGenerator) ProjectReportGenerator(org.gradle.api.tasks.diagnostics.internal.ProjectReportGenerator) Configuration(org.gradle.api.artifacts.Configuration) TaskAction(org.gradle.api.tasks.TaskAction)

Example 15 with TaskAction

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);
}
Also used : ArrayList(java.util.ArrayList) File(java.io.File) StandardJavadocDocletOptions(org.gradle.external.javadoc.StandardJavadocDocletOptions) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

TaskAction (org.gradle.api.tasks.TaskAction)167 File (java.io.File)66 GradleException (org.gradle.api.GradleException)38 IOException (java.io.IOException)35 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)32 ArrayList (java.util.ArrayList)29 Project (org.gradle.api.Project)18 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)16 InputFile (org.gradle.api.tasks.InputFile)16 OutputFile (org.gradle.api.tasks.OutputFile)15 FileCollection (org.gradle.api.file.FileCollection)13 AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)12 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)12 Map (java.util.Map)12 DefaultTask (org.gradle.api.DefaultTask)12 HashMap (java.util.HashMap)10 InvalidUserDataException (org.gradle.api.InvalidUserDataException)9 AndroidLibrary (com.android.builder.model.AndroidLibrary)8 URLClassLoader (java.net.URLClassLoader)8 WorkResult (org.gradle.api.tasks.WorkResult)8