app-gradle-plugin breaks tasks in multi project build - google-app-engine

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?

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.

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.

Related

Update composer.json for Google APP Engine

Enviroment: php 7.3
I added a new package to local composer.json
How can I move the changes? gcloud app deploy seems to ignore it as the new files doesnt appear there.
Is there anything else that needs to be run in order to check the new composer.json and update it live?
From the GCP documentation:
Composer runs automatically when you deploy a new version of your
application. Simply add the following line to the top of your PHP
scripts to require the autoload.php file:
require_once __DIR__ . '/vendor/autoload.php';
Also,
Scripts defined in your composer.json file will not run when Composer
can use a cached result.
By default, App Engine caches fetched dependencies to reduce build
times. To install an uncached version of the dependency, use the
command:
gcloud beta app deploy --no-cache
Let me know if that helps!
I had this issue, and eventually realised I had to run:
composer install
before running
gcloud app deploy
I'm putting this answer here in case it helps someone else...
By trial and error I have discovered that GAE will actually load your Composer resources before your entrypoint script is called, I had Composer file autoloads specified in composer.json "autoload":{"files":[...]} and I found out that those files are actually called before my call to vendor/autoload.php in my entrypoint script

Build several projects from one repository with Azure DevOps

We have one Java/Spring Boot/React project hosted on GitLab. After initial development we decided to move to Azure DevOps. Project structure hosted on the GitLab and in local folder structure is simple:
-- Parent project (parent folder)
------- First Spring Boot Project (built with Maven, produces JAR1)
------- Second Spring Boot Project (built with Maven, uses JAR1 as dependency, produces JAR2)
------- React project (built with NPM, produces static pages)
I need to setup separate build process for React and for Spring 1 and 2 projects.
In Azure DevOps there is selector for build from specific branch but I don't see how can I set pipelines to build project from specific folder?
When you use Maven task to build your Spring Boot Project, you need to specify the path to your pom.xml file by changing the value of Maven POM file field. The file path value should be relative to the root of the repository, such as IdentityService/pom.xml or $(system.defaultWorkingDirectory)/IdentityService/pom.xml.
Here is the document about Maven task.
When you use npm task to build your React project, you can set the working folder that contains package.json. Please select the folder instead of the file when you set the working folder.
Here is the document about npm task.
In addition, you may also need to set path filters in Continuous integration (CI) triggers. Here is the document about CI Triggers.
You have path filter:
# specific path build
trigger:
branches:
include:
- master
- releases/*
paths:
include:
- docs/*
exclude:
- docs/README.md
Please check documentation here

Unable to resolve "./aws-exports" from "App.js"

I have been building an app with awsamplify for quite some time now. Today I descided to run some test and when I did
npm run start-web
Everythin worked fine. Now I went on to run mobile test with the use of Expo and ran
npm run ios & npm run android
which both returned the following errors.
Unable to resolve "./aws-exports" from "App.js"
Building JavaScript bundle: error
my problem is similar to the one below just its amplify and not awsmobile
https://github.com/aws-amplify/amplify-js/issues/669
Deos anyone know what I can do to resolve this?
Thanks alot!
I jsut removed some unused imports and the error changed to this
Unable to resolve "#aws-amplify/ui/dist/style.css" from "node_modules\aws-amplify-react\dist\Amplify-UI\Amplify-UI-Components-React.js"
Barely mentioned in the AWS docs:
For setting up a local dev folder, from an existing amplify repo, use an amplify env pull,
It will "pull" the ./aws-exports.js from the server, the latest one that was pushed there,
similar to git push and git pull but for the amplify env
It's true that an amplify push will create the ./aws-exports.js file,
but it will also "push" it to the server, overwriting whatever is there.
amplify status is also a handy command, similar to git status
I ran amplify env pull
and then found it in the ./src/aws-exports.js
not sure if the pull did it, or if it was always there but this is for an existing expo project
Confing your projects, using terminal go to the main folder and amplify init to config your project
amplify init
Do you to use an existing environment? (Y/n) Y
Choose the environment you would like to use: dev
Choose your default editor: Visual Studio Code
Choose the type of app you're building: javascript
What javascript framework you're using: ionic
Source Directory Path: src
Distribution Directory Path: www
Build Command: npm run-script build
Do you want to use an AWS profile? Y
Please choose the profile you want to use: select your personal IAM profile

How to use Kotlin in AppEngine projects using Gradle

Like the title says, how can I use Kotlin when developing AppEngine projects? I'm using IntelliJ/Android Studio with Gradle as my build tool.
Since AppEngine executes compiled .class files, it doesn't care what JVM language produced these. This means we can use Kotlin.
One way to do this is by using Gradle and the Gradle App Engine plugin. Create a project with a build.gradle that looks something like this. Then add the Kotlin dependencies and apply the plugin. The final build file looks something like this:
buildscript {
ext.kotlin_version = '1.0.6' //replace with latest Kotlin version
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.32' //Replace with latest GAE plugin version
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral();
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.32' //Replace with latest GAE SDK version
compile 'javax.servlet:servlet-api:2.5'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
}
Since M11 you don't need to have a separate directory for Kotlin files so you can just add your .kt files to src/main/java.

Failed to import App engine DatastoreService using Android Studio Beta (0.8.1)

import com.google.appengine.api.datastore.DatastoreService;
I migrated my App Engine Java servlet module from Eclipse Kepler to Android Studio using the Export to -> build.gradle from Eclipse.
The problem is that Android Studio doesnt recognize the imports mentioned above.
I already did the following:
-Updated the corresponding build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.6'
}
}
(...)
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.6'
compile 'javax.servlet:servlet-api:2.5' }
I downloaded the Android Support repository from the SDK
I also tried to find the jars needed from the download jar from web, option, after clicking on the Datastoreservice Datastore =...
The module I created in Android Studio is the proper module for a Java Http Servlet.
Any ideas, how to import the appengine datastore service using build.gradle or by any other method?
Thank you
Found it!
Just added the following to my build.gradle file and the imports were successful. Although the app-engine endpoints seem irrelevant, the com.google.appengine.api.datastore.DatastoreService; was imported
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.1'
compile 'com.google.appengine:appengine-endpoints:1.9.1'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.1'
compile 'javax.servlet:servlet-api:2.5'}

Resources