【发布时间】:2014-12-03 14:25:23
【问题描述】:
在this guide 之后,我在我的 Maven 项目中实现了 Google Cloud Endpoints
这是我的 pom.xml 的属性
<properties>
<appengine.app.id>xxxxxxxx</appengine.app.id>
</properties>
这是我在 pom.xml 中的 maven-war-plugin 配置
<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>
这是我的 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>
这是生成的数据
问题 .discovery 文件在创建过程中不解析 maven 属性
mystore-v1-rest.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/",
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 文件夹中保存的任何其他文件一样被过滤?
我在许多文件(在 WEB-INF 父文件夹下)中使用了 Maven 变量,并且值被替换而没有问题。
如何调整我的配置以允许对 .discovery 文件进行过滤?
我认为(在 lib 生成期间)appengine-web.xml 中的 application 值是在未解析该值的情况下获取的,并且在 Maven 构建期间,不应用过滤。
我已经尝试将<filtering>true</filtering> 添加到资源配置中,但没有成功
--- 编辑 25/01/2014 ---
在收到一些建议后,我需要澄清一个我在原帖中忘记写的东西。
问题与endpoints_get_discovery_doc有关
这是 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
文件\target\generated-sources\appengine-endpoints\WEB-INF/mystore-v3-rpc.discovery由endpoints目标生成,未过滤。
即使有过滤属性
<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文件夹,文件没有过滤?
【问题讨论】:
-
我已经重现了您看到的错误。我不认为这是不正确的项目配置或用户错误。似乎是 maven appengine 插件的问题。 I'd suggest opening an issue on their tracker.
-
在使用您添加
true 的建议后,这似乎对我有用。请注意,appengine-maven-plugin 不执行过滤...maven-war-plugin 启动过滤。 -
感谢@Ronald 的提示。您能否在此处发布您的配置,以便我更好地了解过滤属性的放置位置。
-
嗨@Ronald,我用一些额外的信息编辑了这个问题。
标签: google-app-engine maven google-cloud-endpoints maven-war-plugin