我试图从文本文件中读取我的构建版本号,然后将其分配给生成的包名:myRelease-1.1.1.apk,其中内部版本号被手动设置为属性文件version.number = 1.1.1如何通过属性文件中的那个重载pom.xml中设置的$ {version.number}?
编辑:有关该项目的更多详细信息.我使用git提交属性文件,然后Jenkins接管并使用Maven构建.我想最终得到一个构建"myBuild-9.9.9.apk".现在我在extras/version.properties中有"myBuild-1.1.2.apk"
project.version=9.9.9
Run Code Online (Sandbox Code Playgroud)
在pom.xml中
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
.....
<version>1.1.2</version>
</parent>
<groupId>ca.lapresse.android</groupId>
<artifactId>lapresse-hockey-app</artifactId>
<packaging>apk</packaging>
<name>La Presse Hockey - App</name>
<version>1.1.2</version>
Run Code Online (Sandbox Code Playgroud)
......似乎${project.artifactId}从版本号开始<version></version>,它变成了1.1.2.这应该反映在${project.version},我试图从属性文件重载.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${project.basedir}/extras/version.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我做错了什么,我根本没做什么?我对Maven的理解非常简陋(我来自Ant背景).
只是回答我自己的问题:事实证明Maven需要在脚本中发生任何事情之前设置属性.因此,它是一成不变的,不能从文件中修改.我最终编写了一个Ant任务,在触发Maven脚本之前修改了pom.xml并更改了文件中的版本.丑陋和不平凡,但它的工作原理.
阅读以下答案:
要不就:
<project>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>dev.properties</file> <!-- THIS!!! -->
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
更新工作概念证明是http://sourceforge.net/u/gavenkoa/exp/ci/default/tree/maven/properties/pom.xml 上的一个子项目
运行 build as mvn compile,检查pom.xml和控制台输出。
| 归档时间: |
|
| 查看次数: |
9691 次 |
| 最近记录: |