Friday, November 15, 2013

Google App Engine Maven setup


Maven Setup for Google App Engine

Playing with Google App Engine to setup simple Spring application .It's  simple to setup simple Servlet application through Eclipse plugin but I don't want to maintain dependency in eclipse , got to have Maven . It's little tricky to setup , so here is the info . 

  1. Download AppEngine ( Not just the Eclipse plugin for gae )  
  2. Setup Maven master password and google password as encrypted value 
  3. pom.xml

Password Setup

Setup the master password and the google password .Details for setting up password explained here 
Your settings-security.xml and settings.xml has to be updated . Provided mine below for reference
settings-security.xml

<settingsSecurity>
 <master>encryptedvaluehere</master>
</settingsSecurity>

Settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers>
      <server>
            <id>appengine.google.com</id>
            <username>emailhere</username>
            <password>encryptedvaluehere</password>
        </server>
  </servers>
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>
</settings>


Directory

My case the source directory is src , not src/main and all the other required files are in src main as shown below



pom.xml

Specify the Google App Engine home in gae.home tag.
Enter the group and artifact id
mvn gae:deploy will deploy the application to the app engine
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0</version>


<groupId>entergroupid</groupId>
<artifactId>enterartifactid</artifactId>

<pluginRepositories>
<pluginRepository>
<id>maven-gae-plugin-repo</id>
<name>Maven Google App Engine Repository</name>
<url>http://maven-gae-plugin.googlecode.com/svn/repository/</url>
</pluginRepository>
<pluginRepository>
<id>google-staging</id>
<name>Google Staging</name>
<url>https://oss.sonatype.org/content/repositories/comgoogleappengine-1004/</url>
</pluginRepository>
</pluginRepositories>

<repositories>
<repository>
<id>google-maven-repo</id>
<name>Maven Google App Engine Repository</name>
<url>http://maven-gae-plugin.googlecode.com/svn/repository/</url>
</repository>
<repository>
<id>codehaus</id>
<name>codehaus</name>
<url>http://repository.codehaus.org/org/codehaus/groovy/</url>
</repository>
<repository>
<id>repository.springsource.release</id>
<name>SpringSource GA Repository</name>
<url>http://repo.springsource.org/release</url>
</repository>
</repositories>


<properties>
<appengine.app.version>1</appengine.app.version>
<appengine.target.version>1.8.6</appengine.target.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-framework.version>3.1.2.RELEASE</spring-framework.version>
<spring-integration.version>2.1.3.RELEASE</spring-integration.version>
<spring-ws.version>2.1.0.RELEASE</spring-ws.version><!--2.1.0.RELEASE-->
<spring-security-version>3.1.2.RELEASE</spring-security-version>
<enunciate.version>1.27</enunciate.version>
<gae.version>1.8.6</gae.version>
<gae.port>9090</gae.port>
<net.kindleit.version>0.9.6-SNAPSHOT</net.kindleit.version>
<gae.home>/Library/appengine/appengine-java-sdk-${gae.version}</gae.home>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>

</properties>

<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${appengine.target.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-framework.version}</version>
</dependency>

<dependency>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>enunciate-rt</artifactId>
<version>${enunciate.version}</version>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${appengine.target.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${appengine.target.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src/resources</directory>
</resource>
</resources>
<outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<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.4</version>
<configuration>
<webResources>
<resource>
<directory>src/resources</directory>
</resource>
</webResources>
</configuration>
</plugin>

<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${gae.version}</version>
<configuration>
<fullScanSeconds>1</fullScanSeconds>
<server>preview.appengine.google.com</server>
</configuration>
</plugin>



<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<version>0.9.2</version>
<configuration>
<unpackVersion>${gae.version}</unpackVersion>
<serverId>appengine.google.com</serverId>
</configuration>
<dependencies>
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>${gae.version}</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<goals>gae:deploy</goals>
</configuration>
</plugin>


</plugins>
</build>



</project>

No comments: