question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Applying plugin to Gradle KTS project fails

See original GitHub issue

I am creating a project using Gradle 6.5 and the Kotlin DSL. When I add the appengine plugin to my :api-server module I get this error:

An exception occurred applying plugin request [id: 'com.google.cloud.tools.appengine', version: '2.2.0', artifact: 'com.google.cloud.tools:appengine-gradle-plugin:2.2.0']
> Failed to apply plugin [class 'com.google.cloud.tools.gradle.appengine.standard.AppEngineStandardPlugin']
   > Task with name 'assemble' not found in project ':api-server'.

It looks like the plugin is trying to access the assemble task before it’s created. My plugins block looks like this:

plugins {
    kotlin("jvm")
    kotlin("plugin.serialization") version "1.3.72"
    id("com.google.cloud.tools.appengine") version "2.2.0"
    application
    war
}

Changing the plugins order doesn’t change the result.

PS: I am using a resolutionStrategy in my settings.gradle.kts to be able to reference the plugin — not that it has anything to do with the issue at hand:

pluginManagement {
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == "com.google.cloud.tools.appengine") {
                useModule("com.google.cloud.tools:appengine-gradle-plugin:${requested.version}")
            }
        }
    }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
rock3rcommented, Jun 23, 2020

For anyone else having issues with the plugin with the Kotlin DSL, and stumbling on this issue, here’s the current workaround:

plugins {
    kotlin("jvm")
    application
    war
}

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("com.google.cloud.tools:appengine-gradle-plugin:2.2.0")
    }
}

// Note: the AppEngine plugin currently does not work when applied using the
// plugins DSL, so we need to use the old-school way
apply(plugin = "com.google.cloud.tools.appengine")

configure<AppEngineStandardExtension> {
    deploy {
        projectId = "[TODO]"
        version = "[TODO]"
    }
}

tasks {
    val run by registering {
        dependsOn(named("appengineRun"))
    }
}
1reaction
loosebazookacommented, Jun 22, 2020

Agree, there’s some work to be done here to bring things up to date.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failure when applying custom external gradle plugin to multi ...
In my main project, I've configured settings.gradle.kts to resolve plugins from mavenLocal and apply one of the plugins (let's say plugin1) ...
Read more >
How to diagnose unexpected build failures caused by plugin ...
Hi, we're using a couple of plugins in a Gradle multi project build. ... Failed to apply plugin class 'org.jfrog.gradle.plugin.artifactory.
Read more >
Using Gradle Plugins
By applying plugins, rather than adding logic to the project build script, we can reap a number of benefits. Applying plugins:.
Read more >
Gradle Kotlin script: apply(from=) failed (not the same context)
Hi We are currently updating our Groovy build script to Kotlin (.gradle.kts). We have the following structure, to avoid duplicating some ...
Read more >
Gradle Kotlin DSL Primer
Script plugins, via apply(from = "script-plugin.gradle.kts"). Plugins applied via cross-project configuration. You also can not use type-safe accessors in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found