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

前端 未结 3 1125
时光说笑
时光说笑 2021-02-09 20:32

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 th

相关标签:
3条回答
  • 2021-02-09 20:56

    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.

    0 讨论(0)
  • 2021-02-09 20:59

    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.

    0 讨论(0)
  • 2021-02-09 21:06

    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.

    0 讨论(0)
提交回复
热议问题