Search in sources :

Example 1 with PlayApplicationDeploymentHandle

use of org.gradle.play.internal.run.PlayApplicationDeploymentHandle in project gradle by gradle.

the class PlayRun method registerOrFindDeploymentHandle.

private PlayApplicationDeploymentHandle registerOrFindDeploymentHandle(String deploymentId) {
    DeploymentRegistry deploymentRegistry = getDeploymentRegistry();
    PlayApplicationDeploymentHandle deploymentHandle = deploymentRegistry.get(PlayApplicationDeploymentHandle.class, deploymentId);
    if (deploymentHandle == null) {
        deploymentHandle = new PlayApplicationDeploymentHandle(deploymentId);
        deploymentRegistry.register(deploymentId, deploymentHandle);
    }
    return deploymentHandle;
}
Also used : DeploymentRegistry(org.gradle.deployment.internal.DeploymentRegistry) PlayApplicationDeploymentHandle(org.gradle.play.internal.run.PlayApplicationDeploymentHandle)

Example 2 with PlayApplicationDeploymentHandle

use of org.gradle.play.internal.run.PlayApplicationDeploymentHandle in project gradle by gradle.

the class PlayRun method run.

@TaskAction
public void run() {
    ProgressLoggerFactory progressLoggerFactory = getServices().get(ProgressLoggerFactory.class);
    PlayApplicationDeploymentHandle deploymentHandle = registerOrFindDeploymentHandle(getPath());
    if (!deploymentHandle.isRunning()) {
        ProgressLogger progressLogger = progressLoggerFactory.newOperation(PlayRun.class).start("Start Play server", "Starting Play");
        try {
            int httpPort = getHttpPort();
            PlayRunSpec spec = new DefaultPlayRunSpec(runtimeClasspath, changingClasspath, applicationJar, assetsJar, assetsDirs, getProject().getProjectDir(), getForkOptions(), httpPort);
            PlayApplicationRunnerToken runnerToken = playToolProvider.get(PlayApplicationRunner.class).start(spec);
            deploymentHandle.start(runnerToken);
        } finally {
            progressLogger.completed();
        }
    }
    if (!getProject().getGradle().getStartParameter().isContinuous()) {
        ProgressLogger progressLogger = progressLoggerFactory.newOperation(PlayRun.class).start("Run Play App at http://localhost:" + httpPort + "/", "Running at http://localhost:" + httpPort + "/");
        try {
            waitForCtrlD();
        } finally {
            progressLogger.completed();
        }
    } else {
        LOGGER.warn("Running Play App ({}) at http://localhost:{}/", getPath(), httpPort);
    }
}
Also used : DefaultPlayRunSpec(org.gradle.play.internal.run.DefaultPlayRunSpec) PlayApplicationRunner(org.gradle.play.internal.run.PlayApplicationRunner) ProgressLoggerFactory(org.gradle.internal.logging.progress.ProgressLoggerFactory) PlayRunSpec(org.gradle.play.internal.run.PlayRunSpec) DefaultPlayRunSpec(org.gradle.play.internal.run.DefaultPlayRunSpec) ProgressLogger(org.gradle.internal.logging.progress.ProgressLogger) PlayApplicationDeploymentHandle(org.gradle.play.internal.run.PlayApplicationDeploymentHandle) PlayApplicationRunnerToken(org.gradle.play.internal.run.PlayApplicationRunnerToken) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

PlayApplicationDeploymentHandle (org.gradle.play.internal.run.PlayApplicationDeploymentHandle)2 TaskAction (org.gradle.api.tasks.TaskAction)1 DeploymentRegistry (org.gradle.deployment.internal.DeploymentRegistry)1 ProgressLogger (org.gradle.internal.logging.progress.ProgressLogger)1 ProgressLoggerFactory (org.gradle.internal.logging.progress.ProgressLoggerFactory)1 DefaultPlayRunSpec (org.gradle.play.internal.run.DefaultPlayRunSpec)1 PlayApplicationRunner (org.gradle.play.internal.run.PlayApplicationRunner)1 PlayApplicationRunnerToken (org.gradle.play.internal.run.PlayApplicationRunnerToken)1 PlayRunSpec (org.gradle.play.internal.run.PlayRunSpec)1