Is it possible to use appengine modules and and cloud endpoints?

后端 未结 2 2079
臣服心动
臣服心动 2021-01-24 23:57

Using appengine modules implies creating dynamic web application instead of the usual appengine web application project. Cloud endpoints work well with the usual appengine Web A

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-25 00:42

    Currently working on the same problem, I think I have found a solution with the following setup (using maven for a java project):

    In the project-root pom.xml: defines a few common values (like the appengine version you're using), a pom packaging and your modules, especially an EAR one:

    
    
    4.0.0
    
    com.example
    myproject-root
    1.0
    pom
    myproject-root
    
    
        1
        1.9.11
        UTF-8
    
    
    
        myproject-ear
        myproject-cloud-endpoints
        myproject-backend
    
    
    
    

    The pom.xml of the EAR module should have of course EAR packaging but also "war" typed dependencies on the other modules and the "unpack types" option of the maven-ear plugin set to "war":

    
    
    4.0.0
    
    
        com.example
        myproject-root
        1.0
    
    
    com.example
    myproject-ear
    1.0
    ear
    
    myproject-ear
    
    
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                2.5.1
                
                    1.7
                    1.7
                
            
            
                org.apache.maven.plugins
                maven-ear-plugin
                2.9
                
                    5
                    lib
                    war
                    ${project.basedir}/src/main/application/META-INF/maven-application.xml
                
            
            
                com.google.appengine
                appengine-maven-plugin
                ${appengine.target.version}
            
        
    
    
    
        
            com.example
            myproject-cloud-endpoints
            1.0
            war
        
        
            com.example
            myproject-backend
            1.0
            war
        
    
    
    
    

    Finally, the "cloud-endpoints" pom.xml should be configured as a basic cloud endpoints webapp project with "war" packaging:

    
    
    4.0.0
    
    
        com.example
        myproject-root
        1.0
    
    
    com.example
    myproject-cloud-endpoints
    1.0
    war
    
    myproject-cloud-endpoints
    
    
        
        
            com.google.appengine
            appengine-api-1.0-sdk
            ${appengine.target.version}
        
        
            com.google.appengine
            appengine-endpoints
            ${appengine.target.version}
        
        
            javax.servlet
            servlet-api
            2.5
            provided
        
        
            javax.inject
            javax.inject
            1
        
    
    
    
    
        
        ${project.build.directory}/${project.build.finalName}/WEB-INF/classes
        
            
                org.codehaus.mojo
                versions-maven-plugin
                2.1
                
                    
                        compile
                        
                            display-dependency-updates
                            display-plugin-updates
                        
                    
                
            
            
                org.apache.maven.plugins
                3.1
                maven-compiler-plugin
                
                    1.7
                    1.7
                
            
            
                org.apache.maven.plugins
                maven-war-plugin
                2.4
                
                    ${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml
                    
                        
                            
                            ${project.build.directory}/generated-sources/appengine-endpoints
                            
                            
                                WEB-INF/*.discovery
                                WEB-INF/*.api
                            
                        
                    
                
            
            
                com.google.appengine
                appengine-maven-plugin
                ${appengine.target.version}
                
                    false
                    
                    
                    
                    
                
                
                    
                        
                            endpoints_get_discovery_doc
                        
                    
                
            
        
    
    

    Building this project, you should be able to generate your cloud-endpoints client librariy through Eclipse: right click on the "cloud-endpoints" project => "Google App Engine WTP" => "Generate Cloud Endpoint Client Library" will generate everything needed in myproject-cloud-endpoints/endpoint-libs/.

    Hope that helps!

提交回复
热议问题