3

this guide過濾,我實現了谷歌雲端點在我的Maven項目的AppEngine Maven插件 - 終點目標 - 啓用夏卓文件

這裏是我的pom.xml的性質

<properties> 
    <appengine.app.id>xxxxxxxx</appengine.app.id> 
</properties> 

這裏在pom.xml中

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-war-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 

     <!-- http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html --> 
     <!-- To prevent corrupting your binary files when filtering is enabled, you can configure a list of file extensions that will not be filtered. --> 
     <nonFilteredFileExtensions> 
      <nonFilteredFileExtension>p12</nonFilteredFileExtension> 
     </nonFilteredFileExtensions> 

     <archiveClasses>true</archiveClasses> 

     <!-- https://cloud.google.com/appengine/docs/java/tools/maven#cloud_endpoints_goals --> 
     <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml> 

     <webResources> 

      <!-- in order to interpolate version from pom into appengine-web.xml --> 
      <resource> 
       <directory>${basedir}/src/main/webapp/WEB-INF</directory> 
       <filtering>true</filtering> 
       <targetPath>WEB-INF</targetPath> 
      </resource> 

      <resource> 
       <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory> 
       <includes> 
        <include>WEB-INF/*.discovery</include> 
        <include>WEB-INF/*.api</include> 
       </includes> 
      </resource> 

     </webResources> 

    </configuration> 
</plugin> 

這裏我Maven的戰爭插件配置是我的AppEngine-web.xml文件的頭部

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> 

    <application>${appengine.app.id}</application> 
    <version>${project.version}</version> 
    .... 
</appengine-web-app> 

這裏是生成的數據

enter image description here

問題夏卓文件他們的創作

的MyStore-V1-休息期間不解決Maven的財產.discovery

"protocol": "rest", 
"baseUrl": "https://${appengine.app.id}.appspot.com/_ah/api/mystore/v1/", 
"basePath": "/_ah/api/mystore/v1/", 
"rootUrl": "https://${appengine.app.id}.appspot.com/_ah/api/", 
"servicePath": "mystore/v1/", 

爲什麼這個文件不被過濾像保存在WEB-INF文件夾的任何其他文件的MyStore-V1-rpc.discovery

protocol": "rpc", 
"rootUrl": "https://${appengine.app.id}.appspot.com/_ah/api/", 
"rpcUrl": "https://${appengine.app.id}.appspot.com/_ah/api/rpc", 
"rpcPath": "/_ah/api/rpc", 

我在許多文件(在WEB-INF父文件夾下)使用Maven變量,並且值被替換爲沒有問題。

如何調整我的配置以允許在.discovery文件上進行篩選?

我認爲在appengine-web.xml中產生的值(在lib代碼中)application的值不會解析該值,並且在Maven構建期間,不會應用該過濾。

我已經嘗試添加<filtering>true</filtering>到資源配置,W/O成功

---編輯25/01/2014 ---

後收到的一些建議,我需要澄清我忘了在原文中寫的東西。

的問題是關係到endpoints_get_discovery_doc

這裏是由端點目標生成的文件\target\generated-sources\appengine-endpoints\WEB-INF/mystore-v3-rpc.discovery Maven的目標

API Discovery Document written to ..\target\generated-sources\appengine-endpoints\WEB-INF/mystore-v3-rpc.discovery 
API Discovery Document written to ..\target\generated-sources\appengine-endpoints\WEB-INF/mystore-androidtest-rpc.discovery 

的日誌,它沒有被過濾。

即使在過濾性能

<resource> 
    <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory> 
    <filtering>true</filtering> 
    <includes> 
     <include>WEB-INF/*.discovery</include> 
     <include>WEB-INF/*.api</include> 
    </includes> 
</resource> 

生成的文件進行過濾。

也許問題是如果文件直接寫入${project.build.directory}/generated-sources/appengine-endpoints文件夾中,那麼文件不會被過濾?

+0

我複製你所看到的錯誤。我不認爲這是一個不正確的項目配置或用戶錯誤。似乎是maven appengine插件的問題。 [我會建議在他們的追蹤器上打開一個問題。](https://code.google.com/p/appengine-maven-plugin/issues/entry) – Nick 2015-01-08 17:58:37

+0

這似乎適用於我後,使用您的建議添加。請注意,appengine-maven-plugin不執行過濾... maven-war-plugin啓動過濾。 – Ronald 2015-01-23 16:34:06

+0

感謝@Ronald的提示。你可以在這裏發佈你的配置,所以我可以更好地理解在哪裏放置過濾屬性。 – 2015-01-23 19:26:41

回答

2
<plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.4</version> 
      <configuration> 
       <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml> 
       <webResources> 
        <!-- in order to interpolate version from pom into appengine-web.xml --> 
        <resource> 
         <directory>${basedir}/src/main/webapp/WEB-INF</directory> 
         <filtering>true</filtering> 
         <targetPath>WEB-INF</targetPath> 
        </resource> 
        <resource> 
         <!-- this is relative to the pom.xml directory --> 
         <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory> 
         <!-- the list has a default value of ** --> 
         <includes> 
          <include>WEB-INF/*.discovery</include> 
          <include>WEB-INF/*.api</include> 
         </includes> 
         <filtering>true</filtering> 
        </resource> 
       </webResources> 
      </configuration> 
     </plugin> 
0
<!--User the below Line, I also had the same problem that I solved using Note: <version>${app.version}</version><appId>${app.id}</appId> folow as per your configuration --!>         
    <plugin> 
    <groupId>com.google.appengine</groupId> 
      <artifactId>appengine-maven-plugin</artifactId> 
      <version>${appengine.version}</version> 
      <configuration> 
       <enableJarClasses>false</enableJarClasses> 
       <version>${app.version}</version> 
       <appId>${app.id}</appId> 
       <!-- Comment in the below snippet to bind to all IPs instead of just localhost --> 
       <address>0.0.0.0</address> 
       <port>8080</port> 
       <!-- Comment in the below snippet to enable local debugging with a remote debugger 
        like those included with Eclipse or IntelliJ --> 
       <jvmFlags> 
        <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag> 
       </jvmFlags> 
      </configuration> 
      <executions> 
       <execution> 
        <goals> 
         <goal>endpoints_get_discovery_doc</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin>