Java Code Examples for org.gradle.api.Task#doLast()

The following examples show how to use org.gradle.api.Task#doLast() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OssIndexPlugin.java    From ossindex-gradle-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public synchronized void apply(Project project) {
    logger.info("Apply OSS Index Plugin");
    this.project = project;

    project.getExtensions().create("audit", AuditExtensions.class, project);
    Task audit = project.task("audit");
    Proxy proxy = getProxy(project, "http");

    if (proxy != null) {
        proxies.add(proxy);
    }proxy = getProxy(project, "https");
    if (proxy != null) {
        proxies.add(proxy);
    }
    audit.doLast(this::doAudit);
}
 
Example 2
Source File: AjcAction.java    From gradle-plugins with MIT License 6 votes vote down vote up
@SuppressWarnings("WeakerAccess")
public void addToTask(Task task) {
    task.doLast("ajc", this);
    task.getExtensions().add("ajc", this);

    task.getInputs().files(this.getClasspath())
            .withPropertyName("aspectjClasspath")
            .withNormalizer(ClasspathNormalizer.class)
            .optional(false);

    task.getInputs().files(this.getOptions().getAspectpath())
            .withPropertyName("aspectpath")
            .withNormalizer(ClasspathNormalizer.class)
            .optional(true);

    task.getInputs().files(this.getOptions().getInpath())
            .withPropertyName("ajcInpath")
            .withNormalizer(ClasspathNormalizer.class)
            .optional(true);

    task.getInputs().property("ajcArgs", this.getOptions().getCompilerArgs())
            .optional(true);

    task.getInputs().property("ajcEnabled", this.getEnabled())
            .optional(true);
}
 
Example 3
Source File: AjcAction.java    From gradle-plugins with MIT License 6 votes vote down vote up
@SuppressWarnings("WeakerAccess")
public void addToTask(Task task) {
    task.doLast("ajc", this);
    task.getExtensions().add("ajc", this);

    task.getInputs().files(this.getClasspath())
            .withPropertyName("aspectjClasspath")
            .withNormalizer(ClasspathNormalizer.class)
            .optional(false);

    task.getInputs().files(this.getOptions().getAspectpath())
            .withPropertyName("aspectpath")
            .withNormalizer(ClasspathNormalizer.class)
            .optional(true);

    task.getInputs().files(this.getOptions().getInpath())
            .withPropertyName("ajcInpath")
            .withNormalizer(ClasspathNormalizer.class)
            .optional(true);

    task.getInputs().property("ajcArgs", this.getOptions().getCompilerArgs())
            .optional(true);

    task.getInputs().property("ajcEnabled", this.getEnabled())
            .optional(true);
}
 
Example 4
Source File: CloudServicesPackagingPlugin.java    From commerce-gradle-plugin with Apache License 2.0 5 votes vote down vote up
private void setupBootstrap(Project p, Task bootstrap, PackagingExtension extension) {
    bootstrap.doLast(tsk -> {
        try {
            Path configurationFolder = extension.getConfigurationFolder().getAsFile().get().toPath();
            Set<String> environments = new HashSet<>(extension.getEnvironments().get());
            environments.add(COMMON_CONFIG);
            for (String environment : environments) {
                Path hybrisConfigFolder = configurationFolder.resolve(environment).resolve("hybris");
                if (!Files.exists(hybrisConfigFolder)) {
                    Files.createDirectories(hybrisConfigFolder);
                }
                if (extension.getDatahub().getOrElse(Boolean.FALSE)) {
                    Path datahubConfigFolder = configurationFolder.resolve(environment).resolve("datahub");
                    if (!Files.exists(datahubConfigFolder)) {
                        Files.createDirectories(datahubConfigFolder);
                    }
                }
                if (extension.getSolr().getOrElse(Boolean.FALSE)) {
                    Path solrConfigFolder = configurationFolder.resolve(environment).resolve("solr");
                    if (!Files.exists(solrConfigFolder)) {
                        Files.createDirectories(solrConfigFolder);
                    }
                }
            }
        } catch (IOException e) {
            tsk.getLogger().error("could not setup config folders", e);
        }
    });
}
 
Example 5
Source File: CoroutinesPlugin.java    From coroutines with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void addInstrumentActionToTask(String sourceType, Task task, CoroutinesPluginConfiguration config) {
    task.doLast(x -> {
        try {
            // Get source sets -- since we don't have access to the normal Gradle plugins API (artifact can't be found on any repo) we
            // have to use Java reflections to access the data.
            Project proj = task.getProject();

            Object sourceSets = JXPathContext.newContext(proj).getValue("properties/sourceSets");

            // can't use JXPath for this because jxpath can't read inherited properties (getAsMap is inherited??)
            Map<String, Object> sourceSetsMap = (Map<String, Object>) MethodUtils.invokeMethod(sourceSets, "getAsMap");

            if (sourceSetsMap.containsKey(sourceType)) {
                JXPathContext ctx = JXPathContext.newContext(sourceSetsMap);
                File classesDir = (File) ctx.getValue(sourceType + "/output/classesDir");
                Set<File> compileClasspath = (Set<File>) ctx.getValue(sourceType + "/compileClasspath/files");
                
                if (classesDir.isDirectory()) {
                    instrument(classesDir, compileClasspath, config);
                }
            }
        } catch (Exception e) {
            throw new IllegalStateException("Coroutines instrumentation failed", e);
        }
    });        
}
 
Example 6
Source File: JdkBootstrapPlugin.java    From gradle-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public void apply(Project project) {
	JdkBootstrapExtension extension = project.getExtensions().create("jdk", JdkBootstrapExtension.class);
	Task wrapperTask = project.getTasks().getByName("wrapper");
	wrapperTask.doLast(new GenerateBootstrapScript(extension));
}