maven-android-plugin 传递构建属性
我在资产文件夹中有一个属性文件,我想在项目构建时覆盖此属性文件中的值。 像 mvn clean install -Durl=https://xyx.xom 一样?
EX:assets/my_prop.properties
# my_server_url=http://www.test.com/
change to
my_server_url=${url}
我想在构建时替换 my_server_url 值,我做了什么: mvn clean install -Durl=http://xys.com
但它没有替换,我如何在执行以下操作时替换 my_server_url建造
I have a property file in asset folder, i want to override the values in this property file at project build time.
like mvn clean install -Durl=https://xyx.xom?
EX: assets/my_prop.properties
# my_server_url=http://www.test.com/
change to
my_server_url=${url}
i want to replace the my_server_url value at the build time what i did:
mvn clean install -Durl=http://xys.com
but it's not replacing,how can i replace the my_server_url when doing the buid
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的 pom 中,在
节点中,您需要启用如下过滤:完成后,您可以通过运行进行测试:
请注意,排除部分在那里,因为您不这样做不希望 Maven 过滤 asset 目录中可能存在的任何二进制文件。如果您没有该部分,它通常会通过尝试过滤二进制文件而最终损坏它们。
通过这种配置方式,过滤后的属性文件将进入您可能不想要的目标/类。您可以通过添加
节点来更改它。有关配置资源的更多说明,请参阅此链接。In your pom, within the
<build>
node, you'll need to enable filtering like this:Once that's done, you can test by running:
Note that the excludes portion is there because you don't want Maven to filter through any binary files that you may have in the assets directory. If you don't have that portion, it usually ends up corrupting any binary files by attempting to filter them.
With the way that this is configured, the filtered property file will go into target/classes, which you probably don't want. You can change that by adding a
<targetPath>
node. See this link for more notes on configuring resources.