如何使用maven在一个项目中使用不同的依赖?(android)
how to use different denpendency in one project with maven?(android)
我使用 maven 来打包我的应用程序。现在我只想在调试版本中集成 leakcanary。所以我需要在我的 pom.xml 中添加一个 <dependency>
节点。但我想从发行版中删除它。我怎样才能做到这一点?我有一个解决方案,一个 pom.xml 用于调试版本,另一个 pom 用于发布版本。另一种解决方案是在打包之前使用 shell 修改 pom.xml 。还有更好的主意吗?
maven:3.3.9
com.simpligility.maven.plugins:android-maven-plugin:4.4.3
你可以用 Maven profiles 做到这一点;它们可以托管多个 POM 元素:属性 值、配置、依赖项等
然后,您可以在命令行 运行 时使用 -P
启用这些配置文件中的一个,或者例如在 Eclipse 中,使用 Run as...
window.
中的特定条目
这是一个简短的例子:
<!-- Dependencies declarations -->
</dependencies>
<profiles>
<profile>
<id>extralib</id>
<properties>
<!-- specify property values here -->
</properties>
<dependencies>
<dependency>
<!-- add dependency decl here -->
<dependency>
</dependencies>
</profile>
<!-- you may have several profiles -->
<profile>
的所有孩子都是可选的。
我使用 maven 来打包我的应用程序。现在我只想在调试版本中集成 leakcanary。所以我需要在我的 pom.xml 中添加一个 <dependency>
节点。但我想从发行版中删除它。我怎样才能做到这一点?我有一个解决方案,一个 pom.xml 用于调试版本,另一个 pom 用于发布版本。另一种解决方案是在打包之前使用 shell 修改 pom.xml 。还有更好的主意吗?
maven:3.3.9
com.simpligility.maven.plugins:android-maven-plugin:4.4.3
你可以用 Maven profiles 做到这一点;它们可以托管多个 POM 元素:属性 值、配置、依赖项等
然后,您可以在命令行 运行 时使用 -P
启用这些配置文件中的一个,或者例如在 Eclipse 中,使用 Run as...
window.
这是一个简短的例子:
<!-- Dependencies declarations -->
</dependencies>
<profiles>
<profile>
<id>extralib</id>
<properties>
<!-- specify property values here -->
</properties>
<dependencies>
<dependency>
<!-- add dependency decl here -->
<dependency>
</dependencies>
</profile>
<!-- you may have several profiles -->
<profile>
的所有孩子都是可选的。