0
votes

I want to use the frontend-gradle-plugin with the app-gradle-plugin for AppEngine.

If I start with the "multi-project-war-application example everything builds fine.

When I add the app-gradle-plugin using either the method in the documentation linked above the build the fails. For example if I add it through a build script block:

buildscript {
  repositories {
    mavenCentral()
  }

  dependencies {
    classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.1'
  }
}

apply plugin: 'com.google.cloud.tools.appengine'

Gradle will fail with:

A problem occurred configuring project ':backend'.
> Could not create task ':backend:processFrontendResources'.
   > Task with name 'assembleFrontend' not found in project ':frontend'.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':backend'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75) 
...

Note that in the example project the build.gradle has the following part:

tasks.register('processFrontendResources', Copy) {
    // Directory containing the artifacts in the frontend project
    def frontendBuildDir = file("${project(':frontend').buildDir}/www")
    // Directory where the frontend artifacts must be copied to be packaged alltogether with the backend by the 'war'
    // plugin.
    def frontendResourcesDir = file("${project.buildDir}/resources/main/public")

    group 'Frontend'
    description 'Process frontend resources'
    dependsOn project(':frontend').tasks.named('assembleFrontend')

    from frontendBuildDir
    into frontendResourcesDir
}

After adding the app-gradle-plugin the dependsOn line fails. Through debugging I've found that project(':frontend').tasks becomes empty after the app-gradle-plugin is added.

What is the app-gradle-plugin doing that is changing tasks in the project? Is there a different way I can look up the assembleFrontend task that will work with the app-gradle-plugin or is the plugin fundamenatally incompatible with multi project gradle builds?

2

2 Answers

0
votes

I have cloned the repo frontend-gradle-plugin and added the app engine gradle plugin to the build.gradle file of the example multi-project-war-application. Here is the content of it:

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

apply plugin: 'java'                      
apply plugin: 'war'                       
apply plugin: 'com.google.cloud.tools.appengine'

That is all I have and I was able to run ./gradlew bootRun, ./gradlew tasks & ./gradlew build without any issues.

I have taken as a reference the build.gradle file from the app engine standard quickstart.

I hope you find this useful.

0
votes

I opened an issue with the project on Github. They have a new ticket they opened to track the fix but it will be in development for a while. In the mean time the workaround recommendation is to:

not use a "managed Cloud SDK." ("Managed" means app-gradle-plugin automatically downloads an SDK at some cache location (e.g., ~/.cache/google-cloud-tools-java/...) and keeps updating it transparently.) So, a workaround is to manually download the SDK and periodically update it yourself. For example, download the Cloud SDK, unzip it into your home directory (probably you'll also need to do gcloud components install app-engine-java after unzipping), and configure app-gradle-plugin to use the downloaded Cloud SDK:

The Groovy DSL example they gave:

appengine {
  tools.cloudSdkHome = '/home/chanseok/google-cloud-sdk'
}

The Kotlin DSL I am using successfully:

the<AppEngineStandardExtension>().apply {
    appengine {
        tools {
            setCloudSdkHome(File("/home/ciferkey/google-cloud-sdk"))
        }
    }
}

I am able to use dependsOn with that configuration change. Once the ticket above is finished and release this should be unnecessary.