Skip to content

Commit 92ee3ae

Browse files
tulinkryVladimir Kotal
authored andcommitted
Reading the python version from pom.xml (#2431)
Use maven native plugins to read and transform the module version and place it into the setup.py. fixes #2393
1 parent 1896d2f commit 92ee3ae

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
lines changed

distribution/assembly.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
<destName>source.war</destName>
2121
</file>
2222
<file>
23-
<source>${project.basedir}/../opengrok-tools/${project.build.directory}/dist/opengrok-tools-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${parsedVersion.qualifier}.tar.gz</source>
23+
<source>${project.basedir}/../opengrok-tools/${project.build.directory}/dist/opengrok-tools-${project.python.package.version}.tar.gz</source>
2424
<outputDirectory>tools</outputDirectory>
25-
<destName>opengrok-tools.tar.gz</destName>
25+
<destName>opengrok-tools-${project.python.package.version}.tar.gz</destName>
2626
</file>
2727
</files>
2828
<fileSets>

distribution/pom.xml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,25 @@
6767
<plugin>
6868
<groupId>org.codehaus.mojo</groupId>
6969
<artifactId>build-helper-maven-plugin</artifactId>
70-
<version>3.0.0</version>
70+
<version>1.8</version>
7171
<executions>
7272
<execution>
73-
<id>parse-version</id>
73+
<id>generate-python-package-version</id>
7474
<goals>
75-
<goal>parse-version</goal>
75+
<goal>regex-property</goal>
7676
</goals>
77+
<phase>package</phase>
78+
<configuration>
79+
<!--
80+
Use property ${project.version} but delete the "-" (dash) from it
81+
and place it into the property ${project.python.package.version}
82+
-->
83+
<name>project.python.package.version</name>
84+
<regex>-rc</regex>
85+
<value>${project.version}</value>
86+
<replacement>rc</replacement>
87+
<failIfNoMatch>false</failIfNoMatch>
88+
</configuration>
7789
</execution>
7890
</executions>
7991
</plugin>

opengrok-tools/pom.xml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,31 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
4343
<testSourceDirectory>src/test/python</testSourceDirectory>
4444

4545
<plugins>
46-
46+
<plugin>
47+
<groupId>org.codehaus.mojo</groupId>
48+
<artifactId>build-helper-maven-plugin</artifactId>
49+
<version>1.8</version>
50+
<executions>
51+
<execution>
52+
<id>generate-python-package-version</id>
53+
<goals>
54+
<goal>regex-property</goal>
55+
</goals>
56+
<phase>generate-resources</phase>
57+
<configuration>
58+
<!--
59+
Use property ${project.version} but delete the "-" (dash) from it
60+
and place it into the property ${project.python.package.version}
61+
-->
62+
<name>project.python.package.version</name>
63+
<regex>-rc</regex>
64+
<value>${project.version}</value>
65+
<replacement>rc</replacement>
66+
<failIfNoMatch>false</failIfNoMatch>
67+
</configuration>
68+
</execution>
69+
</executions>
70+
</plugin>
4771
<plugin>
4872
<!-- copy all the python files to the target directory
4973
so we produce the dist and build directories there -->
@@ -78,10 +102,17 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
78102
<resource>
79103
<directory>${basedir}</directory>
80104
<includes>
81-
<include>setup.py</include>
82105
<include>MANIFEST.in</include>
83106
</includes>
84107
</resource>
108+
<!-- replace ${project.python.package.version} in setup.py -->
109+
<resource>
110+
<directory>${basedir}</directory>
111+
<includes>
112+
<include>setup.py</include>
113+
</includes>
114+
<filtering>true</filtering>
115+
</resource>
85116
</resources>
86117
</configuration>
87118
</execution>

opengrok-tools/setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import unittest
3+
34
from setuptools import setup
45

56
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -20,7 +21,10 @@ def my_test_suite():
2021

2122
setup(
2223
name='opengrok-tools',
23-
version='1.1rc63',
24+
# The package version is taken from maven.
25+
# this "variable" is replaced by maven on the fly so don't change it here
26+
# see pom.xml for this module
27+
version='${project.python.package.version}',
2428
packages=[
2529
'opengrok_tools',
2630
'opengrok_tools.utils',

0 commit comments

Comments
 (0)