AppeEngine Flex- how to set version name instead of timestamp as version - google-app-engine

Whenever I deploy my app in Google App-engine Flexible, the version is based on the timestamp and each time new version will be created. In appEngine Standard we have:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>_your_app_id_</application>
<version>alpha-001</version>
<threadsafe>true</threadsafe>
</appengine-web-app>
I need that my app will be deployed always with the same Version name instead of creating new version. How can i do this goal in the same way as Appengine Standard.

If you are using maven with the new google cloud tools maven plugin to deploy your application:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.plugin.version}</version>
</plugin>
you can define the version into your pom.xml adding the following property:
<properties>
<app.deploy.version>alpha-001</app.deploy.version>
</properties>
If you are using directly the gcloud executable form command line, you can specify the version adding the argument --version like this:
gcloud app deploy --version alpha-001
You can remove the <version> entry from appengine-web.xml.

Related

Fail to deploy application to appengine

Execution default-cli of goal com.google.cloud.tools:appengine-maven-plugin:1.3.2:deploy
failed: Validation Error: Java App Engine components not installed.
Fix by running 'gcloud components install app-engine-java' on command-line.
I already install the latest app-engine-java and google cloud SDK
And i also reinstalled cloud Sdk, that is not working for me.
below is my pom.xml
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<stage.enableJarSplitting>true</stage.enableJarSplitting>
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
<cloudSdkPath>/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk</cloudSdkPath>
</configuration>
As you use Java and App Engine I recommend you to take a look to this official documentation in order to install the required SDK and configure your develop environment with the necessary tools for the purpose of deploy successfully your app.
Let me know how it goes.

My java App Engine Managed VMs build doesn't deploy after 4/14/2015 update

My java App Engine Managed VMs build doesn't deploy any more using gcloud preview app deploy target/myapp-SNAPSHOT I get this:
ERROR: Found no valid App Engine configuration files in directory
The usage of gcloud preview app deploy changed in our gcloud 2015.04.14 release, you now have to specify the .yaml file for your module as well as --project projectID. The documentation should be updated shortly.
For Java, we've released an updated maven plugin. In your pom.xml, please add the following:
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>0.9.57.v20150425</version>
<configuration>
<gcloud_project>XXX</gcloud_project>
</configuration>
</plugin>
mvn gcloud:deploy
Update to a specific version of the SDK
You have some version of the SDK, but you want to change to a specific non-latest version, add the property:
$ gcloud config set --scope=installation component_manager/fixed_sdk_version 0.9.55
Then run:
$ gcloud components update
Returning to the current version of the SDK
$ gcloud config unset --scope=installation component_manager/fixed_sdk_version
Then run:
$ gcloud components update

GAE OAuth deploy using different accounts based on project

So when deploying to GAE with maven using OAuth it creates .appcfg_oauth2_tokens_java file in your home directory. This works great if you can deploy all your projects with one account. But what can you do when you wish to use different account for one of projects?
Can this file be project specific?
I don't wish to delete this file every time I want to deploy with different account.
You can prevent storing cookies with appcfg.sh --oauth2 --no_cookies.
For use with maven you can add the following config to your pom.xml:
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.9</version>
<configuration>
<oauth2>true</oauth2>
<noCookies>true</noCookies>
</configuration>
</plugin>

Using the google appengine maven plugin to deploy a Jax-RS war

I'm trying to make a simple base project to deploy a service I make using Jax-RS librarys to my Google app engine cloud space. The problem is that I don't know how to configure the plugin properly to not keep looking to a webapp directory under the target folder. The structure of the Jax-rs project puts the web.xml and all other WEB-INF files under the resources directory instead of a webapp directory. Is there a way to configure the maven plugin to deploy my already built and zipped up war file?
This is the error I see
[INFO] Updating Google App Engine Application Unable to find the
webapp directory C:\dev\gameTrunk\server\target\HOMMTG-server-1.0
usage: AppCfg [options] [] []
Action must be one of: help: Print help for a specific action.
download_app: Download a previously uploaded app version.
request_logs: Write request logs in Apache common log format.
rollback: Rollback an in-progress update. start: Start the specified
server version.
and it goes on with all the appengine plugin targets...
This s my pom
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>2.5.1</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<archiveClasses>true</archiveClasses>
<webResources>
<!-- in order to interpolate version from pom into appengine-web.xml -->
<resource>
<directory>${basedir}/src/main/resources/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
</plugin>
</plugins>
Thats just the plugins part but its almost exactly the same as the guestbook example project except for the path for the WEB-INF directory
Currently there is no way to configure the appengine-maven-plugin to use a different directory for the war contents. It would be best though to probably create a multimodule build where one submodule just used the maven-ant-plugin to assemble the war directory and then run the plugin on that instead. I don't think we want to make that configurable in the plugin, since it doesn't really align with the maven-war-plugin, and configuring that would make it difficult to setup your project to use the maven-war-plugin seamlessly in the future.
The configuration you currently have for the war-plugin in your pom isn't necessary unless you want interpolation of the version number into the appengine-web.xml. I'm happy to help with setting up your pom so that the official Google App Engine Maven plugin works correctly for you.
(The instructions below apply to maven-gae-plugin, not appengine-maven-plugin.
Have I told you how much Google sucks in Open Source today?)
I think you must add in your maven-gae-plugin a property called appDir pointing to your webapp directory, like this:
<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<configuration>
<appDir>PATH-TO-YOUR-BUILT-EXPLODED-WAR-PATH</appDir>
</configuration>
</plugin>
However, I must stress that changing the path in Maven produces undesirable results (you're mixing source and object code, your .ignore files will get messed up, and other weird things)
Note you STILL NEED your unpacked war somewhere. One way to achieve that is to create another .war project and use dependencies-unpack into it. See http://maven.apache.org/plugins/maven-dependency-plugin/unpack-dependencies-mojo.html
(reference: https://github.com/maven-gae-plugin/maven-gae-plugin/blob/master/maven-gae-plugin/src/main/java/net/kindleit/gae/EngineGoalBase.java)
(just in case, there is a JAX-RS based project for GAE I've wrote a while ago, and its open. See https://github.com/ipeirotis/ReadabilityMetrics/ for an overview)

Maven + App Engine + Google Eclipse Plugin

Is there a way I can have a Maven compatible Google App Engine (Java) project that is also compatible with the Google Eclipse Plugin inside Eclipse?
Thanks!
EDIT:
Native support for a Maven plugin now:
https://developers.google.com/appengine/docs/java/tools/maven
Depends on what you mean by "compatible" and it depends on what features you're using of GAE plugin. We use the appengine maven plugin http://code.google.com/p/maven-gae-plugin/ and eclipse and they seem to work fine together but we're not using GWT or JDO. As with most things maven/eclipse I find it's best to run your stuff from the command line and just use eclipse as an editor.
I use maven and GAE since one year with JDO with no problems.
Here is my configuration on MacOSX Snow Leopard:
Apache Maven 3.0.3
Eclipse Version: 3.7.1
m2e - Maven Integration for Eclipse 1.0.100.20110804-1717
An important thing to have fully integrated Eclipse with Maven (run all the tests both from command line "mvn test" and from JUnit interface inside Eclipse) is to have the .project file in this way:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PROJECT_NAME</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
The plugin has moved here:
https://github.com/maven-gae-plugin/maven-gae-plugin
+1 to Rick's answer, but I'd like to add this:
Google has a tutorial on this: http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven
That said, we have never gotten it to work 100%. The maven-gwt-plugin seems to have problems with Eclipse, and it gets worse if you're using RequestFactory due to APT. maven-gae-plugin seems to play nicely. Running from cmdline is much easier. Further, there's a known bug[citation needed] in Eclipse 3.7/m2e that prevents a lot of things from working correctly.
As mentioned google provided support for maven:
https://developers.google.com/appengine/docs/java/tools/maven
But looks it doesn't work fully with Eclipse (as mentioned in one of comments: "SDK location '.m2\repository\com\google\appengine\appengine-api-1.0-sdk\1.7.2\appengine-api-‌​1.0-sdk-1.7.2.jar' is not a directory")
To resolve it I've used maven-eclipse-plugin, and specified containers for GAE/JRE:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>com.google.appengine.eclipse.core.GAE_CONTAINER</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
My general findings about GAE + Maven + Eclipse.
Rule no 1: Use GAE archetype to generate your GAE project: https://developers.google.com/appengine/docs/java/tools/maven
Rule no 2: If you want to develop with Eclipse - don't do "mvn eclipse:eclipse" and then import - it will cause a lot of problems. Instead import as "Maven Project"
Rule no 3: Simple / working solution how to create MVN/GAE/Eclipse project described on YouTube http://www.youtube.com/watch?v=oC6bJp5X3LI
PS. I'm working on project with separate Web/DAO/Domain modules - I will post later my findings and clues.

Resources