行家 - 从属性文件中读取的版本号 [英] maven - read version number from property file

查看:129
本文介绍了行家 - 从属性文件中读取的版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的试图从一个文本文件中读取我的内部版本号,然后将其分配给生成的包名称:myRelease-1.1.1.apk其中版本号手动设置为一个属性文件 version.number = 1.1.1 我怎样才能过载$ {version.number}如由一个在属性文件设置的pom.xml?

I`m trying to read my build version number from a text file, and then assign it to the generated package name: myRelease-1.1.1.apk where the build number is manually set into a property file version.number=1.1.1 How can I overload ${version.number} as set in pom.xml by the one in the property file?

编辑:关于项目的更多细节 。我使用git提交的属性文件,然后詹金斯接管,并建立与Maven。我想结束了一个打造myBuild-9.9.9.apk。现在我有myBuild,1.1.2.apk 在演员/ version.properties

more details about the project . I use git to commit the property file and then Jenkins takes over and builds with Maven. I would like to end up with a build "myBuild-9.9.9.apk". Right now I have "myBuild-1.1.2.apk" In extras/version.properties

project.version=9.9.9  

在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>

...... 看来, $ {project.artifactId} 需要的版本号从&LT;版&GT;&LT; /版本&GT; 和它成为1.1.2。这应该反映在 $ {project.version} ,其中我想从属性文件超载。

…… It seems that ${project.artifactId} takes the version number from <version></version> and it becomes 1.1.2. This should be reflected in ${project.version}, which I’m trying to overload from the property file.

<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>

我是什么做错了什么我没有做呢?我的Maven的理解是非常基本的(我来自一个Ant背景)。

What am I doing wrong and what I am not doing at all? My understanding of Maven is very rudimentary (I come from an Ant background).

推荐答案

只是为了回答我的问题:事实证明,Maven的需要设置之前,任何事情都有可能在脚本中发生的财产。因此,它被设置在石和从文件不可更改。我结束了书面修改的pom.xml和文件中修改的版本,之前的Maven脚本触发的Ant任务。丑陋和不平凡的,但它的作品。

Just to answer my own question: it turns out that Maven needs the property to be set before anything can happen in the script. As such, it is set in stone and not modifiable from a file. I ended up writing an Ant task that modifies the pom.xml and changes the version in the file, before Maven script is triggered. Ugly and non-trivial, but it works.

这篇关于行家 - 从属性文件中读取的版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆