Showing posts with label Google App Engine. Show all posts
Showing posts with label Google App Engine. Show all posts

Tuesday, September 2, 2014

Upload App Engine Endpoint project

Step 1: create the project at Google Developer Console and copy the project id for later usage.

Step 2: import the app engine project into Eclipse (follow this link on how to do this: http://czcodezone.blogspot.sg/2014/09/import-and-run-app-engine-endpoint.html). Expand the project directory in the "project explorer" of Eclipse to the folder "[project_folder]->main->webapp->WEB-INF" and double-click to open "appengine-web.xml". Change the text element in the xml element "<application>"
to the project id copied earlier in step 1.

Step 3: Right-click the project in the "project explorer" of Eclipse and select "Run As->Run Configuration". In the run configuration dialog, right-click "Maven Build" and select "New". enter the configuration name (e.g. "training-upload") and select the base directory using the "Browse Workspace" button. Next enter "appengine:update" into the "Goals" and click "Apply". Now click "Run" button.

Step 4: To reupload, simply right-click the project in the "project explorer" and select "Run As->Maven Build" and select the earlier created configuration (e.g. the "training-upload" specified earlier in Step 3).

Import and Run App Engine Endpoint project in Eclipse J2EE

Step 1: Download J2EE Eclipse if you have not done so, the link is http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/keplersr2

Now unzip and launch the eclipse IDE

Step 2: Import the App Engine Endpoint project (which can be created using maven, e.g., following this link: http://czcodezone.blogspot.sg/2014/09/using-maven-to-create-app-engine.html) into Eclipse. To do so, right-click "project explorer" in Eclipse and select "Import->Import". Next, in the import dialog, select "Maven->Existing Maven Projects", and follow the steps to import the maven app engine endpoint project.

Step 3:  To run the imported project, right-click the project in the "project explorer" and select "Run As->Run Configurations". In the run configuration dialog, right-click "Maven Build" and select "New", now enter the configuration name on top of the page and enter "appengine:devserver" in the "Goals" textfield. In click "Browse Workspace" below the "Base Directory" and select the imported project. Finally click on "Apply" button, and then "Run", the maven will then go and compile and download related libraries and start running the project".

When the project is running, the output command line in Eclipse will read "[INFO] INFO: Dev App Server is now running". Now you can open the url http://localhost:8080/ in your browser and see the app engine endpoint web app running.

Step 4: To see the available endpoint api, after the app is running go to the link http://localhost:8080/_ah/api/explorer

Using Maven to create App Engine Endpoints project via archetype generation

Step 1: launch your console or terminal, and navigate to the folder where you want to create your appengine endpoints project.

Step 2: Now launch maven to generate archetype (if you are on Windows the console warns "mvn" is not a command, it is because you have not installed and add maven to the system path, follow this link to setup the maven environment: http://czcodezone.blogspot.sg/2014/09/setup-maven-on-windows.html)

$mvn archetype:generate 

Step 3: Use "appengine" as filter

$appengine 

This will list 3 archetypes.

Step 4: Now use "endpoints" as the filter

$endpoints 

This will list 2 archetypes.

Step 5: Now enter "2" to select the second archetype (which is a hello-world endpoints project).

$2

This will list 3 versions of the archetype 2.

Step 6: Now enter "3" to select the latest version of the archetype 2.

$3 

Step 7: Now maven will ask the "groupId", which is just the java package name, so i enter "com.appengine.training"

$com.appengine.training

Step 8: Now maven will ask the "artifactId", which is the project package folder name, so i enter "training"

$training 

Step 9: Now maven will ask the "version", so I just press the ENTER key to accept the default

Finally: next few steps just press the ENTER key and "y" to accept YES, which completes the process of building a hello-world appengine end point project using maven. You can then load the project into eclipse to do further development