I want to use maven for a GAE project, how do i do

2019-03-20 12:18发布

i'm new in the world of GAE. I 'm using eclipse and GAE's SDK, i can deploy to the cloud with the GAE icon and everything is fine. The problem arises when I have to import the infinite number of dependency, then I want to use maven for that. I discovered that there is a special GAE maven plugin called: maven-gae-plugin

Can I use regular maven only to fetch dependencys or I have to use the GAE special plugin to do this?

Thanks

3条回答
一纸荒年 Trace。
2楼-- · 2019-03-20 12:32

You'll need to define a pom.xml for the project which declares the dependencies.
When you build with maven the dependencies will be downloaded from the remote repositories and stored in you local repository ${userhome}/.m2/repository.
The maven build will also bindle the dependencies in your war file.

The easiest way to get started is by creating a project structure using an archetype.

There are 2 archetypes that I've tried for gae so far:

  1. gae-archetype-gwt, which is built adjacent to the gae-maven-plugin, see this article.
  2. gae-eclipse-maven-archetype, see this article and also note the link at the top of the article for the helios update.

As the name suggests gae-eclipse-maven-archetype has better support for eclipse, I have been finding that the configurations for maven and eclipse have been clashing with each other, which gae-eclipse-maven-archetype goes a long way to alleviate.

If your current project is not using the maven directory structure, then you are going to have an uphill battle. Maven projects are easier to configure if you try to fit in with the defaults which are largely sensible options, rather than going against the grain and having to override all of the default configuration options.

查看更多
我想做一个坏孩纸
3楼-- · 2019-03-20 12:33

Add the following to your pom.xml, modifying it to your needs:

<project>
...
    <properties>
    ... 
       <com.google.appengine-version>1.6.4</com.google.appengine-version>
    ...
    </properties>
    <dependencies>
    ...     
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${com.google.appengine-version}</version>
        </dependency>
    ...
    </dependencies>
...
</project>

In case you need any additional GAE-related artifacts besides appengine-api-1.0-sdk, have a look for those artifacts in The Central Repository under com.google.appengine, then add them to your pom.xml's dependencies list.

查看更多
小情绪 Triste *
4楼-- · 2019-03-20 12:56

There is no reason you can't use maven for it's dependency management only. The GAE dependencies are all in maven central.

There is a write up about how to set it up here

I personally use the eclipse plugin in dev and the maven plugin when running under continuous integration.

The main gotcha is to follow the advice about ensuring that the maven dependencies are the last thing in your build path under the GAE plugin dependencies.

查看更多
登录 后发表回答