Search in sources :

Example 1 with EtlasUpdate

use of com.typelead.gradle.eta.tasks.EtlasUpdate in project gradle-eta by typelead.

the class EtaBasePlugin method configureEtaRootTasks.

private void configureEtaRootTasks() {
    /* The global, consistent dependency resolution must be done in the
           root project. */
    if (isRootProject()) {
        EtaSetupEnvironment setupEnvironmentTask = project.getTasks().create(ETA_SETUP_ENVIRONMENT_TASK_NAME, EtaSetupEnvironment.class);
        EtaResolveDependencies resolveDependenciesTask = project.getTasks().create(ETA_RESOLVE_DEPENDENCIES_TASK_NAME, EtaResolveDependencies.class);
        EtaInstallAllDependencies installAllDependenciesTask = project.getTasks().create(ETA_INSTALL_ALL_DEPENDENCIES_TASK_NAME, EtaInstallAllDependencies.class);
        EtaRepl replTask = project.getTasks().create(ETA_REPL_TASK_NAME, EtaRepl.class);
        EtlasUpdate updateTask = project.getTasks().create(ETLAS_UPDATE_TASK_NAME, EtlasUpdate.class);
        resolveDependenciesTask.setVersionsChanged(setupEnvironmentTask.getVersionsChanged());
        resolveDependenciesTask.dependsOn(setupEnvironmentTask);
        installAllDependenciesTask.dependsOn(resolveDependenciesTask);
        replTask.setDestinationDir(project.provider(() -> project.getLayout().getProjectDirectory()));
        replTask.dependsOn(setupEnvironmentTask);
        updateTask.dependsOn(setupEnvironmentTask);
        // We need to wait until the Eta dependencies of *all* subprojects
        // have been configured.
        project.getGradle().projectsEvaluated(gradle -> {
            if (extension.shouldPreInstallDependencies()) {
                setupEnvironmentTask.setupEnvironment();
                resolveDependenciesTask.resolveDependencies();
                installAllDependenciesTask.installAllDependencies();
            }
        });
        project.getGradle().getTaskGraph().whenReady(graph -> {
            List<Task> tasks = graph.getAllTasks();
            for (Task task : tasks) {
                if (task instanceof EtaRepl) {
                    boolean inDaemon = false;
                    Set<Thread> allThreads = Thread.getAllStackTraces().keySet();
                    for (Thread thread : allThreads) {
                        if (thread.getName().contains("Daemon")) {
                            inDaemon = true;
                            break;
                        }
                    }
                    if (inDaemon) {
                        throw new GradleException("You are running a REPL task '" + task.getName() + "' in daemon mode, which is not supported.\n\nAdd the flags '--no-daemon -q --console plain' for the best REPL experience.");
                    }
                    if (project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.QUIET) < 0) {
                        project.getLogger().warn("WARNING: You are running a REPL task without '-q'. You are missing out on a better REPL experience.");
                    }
                    if (!project.getGradle().getStartParameter().getConsoleOutput().equals(ConsoleOutput.Plain)) {
                        project.getLogger().warn("WARNING: You are running a REPL task without '--console plain'. You are missing out on a better REPL experience.");
                    }
                }
            }
        });
    }
}
Also used : EtaInstallAllDependencies(com.typelead.gradle.eta.tasks.EtaInstallAllDependencies) Task(org.gradle.api.Task) EtlasUpdate(com.typelead.gradle.eta.tasks.EtlasUpdate) GradleException(org.gradle.api.GradleException) EtaResolveDependencies(com.typelead.gradle.eta.tasks.EtaResolveDependencies) EtaSetupEnvironment(com.typelead.gradle.eta.tasks.EtaSetupEnvironment) EtaRepl(com.typelead.gradle.eta.tasks.EtaRepl)

Aggregations

EtaInstallAllDependencies (com.typelead.gradle.eta.tasks.EtaInstallAllDependencies)1 EtaRepl (com.typelead.gradle.eta.tasks.EtaRepl)1 EtaResolveDependencies (com.typelead.gradle.eta.tasks.EtaResolveDependencies)1 EtaSetupEnvironment (com.typelead.gradle.eta.tasks.EtaSetupEnvironment)1 EtlasUpdate (com.typelead.gradle.eta.tasks.EtlasUpdate)1 GradleException (org.gradle.api.GradleException)1 Task (org.gradle.api.Task)1