xref: /OpenGrok/tools/pom.xml (revision 1a2ed5cf92e80419ef690aef909685020d04e0e7)
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3
4CDDL HEADER START
5
6The contents of this file are subject to the terms of the
7Common Development and Distribution License (the "License").
8You may not use this file except in compliance with the License.
9
10See LICENSE.txt included in this distribution for the specific
11language governing permissions and limitations under the License.
12
13When distributing Covered Code, include this CDDL HEADER in each
14file and include the License file at LICENSE.txt.
15If applicable, add the following below this CDDL HEADER, with the
16fields enclosed by brackets "[]" replaced with your own identifying
17information: Portions Copyright [yyyy] [name of copyright owner]
18
19CDDL HEADER END
20
21Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
22Portions Copyright (c) 2017-2018, 2020, Chris Fraire <cfraire@me.com>.
23
24-->
25<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
26         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
27    <modelVersion>4.0.0</modelVersion>
28
29    <parent>
30        <groupId>org.opengrok</groupId>
31        <artifactId>opengrok-top</artifactId>
32        <version>1.7.32</version>
33    </parent>
34
35    <artifactId>tools</artifactId>
36    <version>1.7.32</version>
37    <packaging>pom</packaging>
38
39    <name>OpenGrok tools</name>
40
41    <properties>
42        <python.system.executable>python3</python.system.executable>
43        <python.environment>${project.build.directory}/env/bin</python.environment>
44        <project.python.package.version>${project.version}</project.python.package.version>
45        <python.checkstyle.line-length>119</python.checkstyle.line-length>
46    </properties>
47
48    <profiles>
49        <profile>
50            <id>default</id>
51            <activation>
52                <activeByDefault>true</activeByDefault>
53            </activation>
54            <properties>
55                <skipPythonTests>false</skipPythonTests>
56            </properties>
57        </profile>
58        <profile>
59            <id>Windows python environment</id>
60            <activation>
61                <os>
62                    <family>Windows</family>
63                </os>
64            </activation>
65            <properties>
66                <python.system.executable>python</python.system.executable>
67                <python.environment>${project.build.directory}/env/Scripts</python.environment>
68            </properties>
69        </profile>
70        <profile>
71            <id>skipTestsRun</id>
72            <activation>
73                <property>
74                    <name>skipTests</name>
75                </property>
76            </activation>
77            <properties>
78                <skipPythonTests>true</skipPythonTests>
79            </properties>
80        </profile>
81        <profile>
82            <id>specificTestRun</id>
83            <activation>
84                <property>
85                    <name>test</name>
86                </property>
87            </activation>
88            <properties>
89                <skipPythonTests>true</skipPythonTests>
90            </properties>
91        </profile>
92    </profiles>
93
94    <build>
95        <sourceDirectory>src/main/python</sourceDirectory>
96        <testSourceDirectory>src/test/python</testSourceDirectory>
97
98        <plugins>
99            <plugin>
100                <!-- copy all the python files to the target directory
101                     so we produce the dist and build directories there -->
102                <groupId>org.apache.maven.plugins</groupId>
103                <artifactId>maven-resources-plugin</artifactId>
104                <version>3.1.0</version>
105                <executions>
106                    <execution>
107                        <id>copy package source files</id>
108                        <phase>compile</phase>
109                        <goals>
110                            <goal>copy-resources</goal>
111                        </goals>
112                        <configuration>
113                            <outputDirectory>${project.build.directory}/src</outputDirectory>
114                            <resources>
115                                <resource>
116                                    <directory>${basedir}/src</directory>
117                                </resource>
118                            </resources>
119                        </configuration>
120                    </execution>
121                    <execution>
122                        <id>copy version file and replace the OpenGrok version in it</id>
123                        <phase>compile</phase>
124                        <goals>
125                            <goal>copy-resources</goal>
126                        </goals>
127                        <configuration>
128                            <!-- replace ${project.python.package.version} in version.py -->
129                            <outputDirectory>${project.build.directory}/src/main/python/opengrok_tools</outputDirectory>
130                            <resources>
131                                <resource>
132                                    <directory>${basedir}/src/main/python/opengrok_tools</directory>
133                                    <includes>
134                                        <include>version.py</include>
135                                    </includes>
136                                    <filtering>true</filtering>
137                                </resource>
138                            </resources>
139                        </configuration>
140                    </execution>
141                    <execution>
142                        <id>copy top level package resources</id>
143                        <phase>compile</phase>
144                        <goals>
145                            <goal>copy-resources</goal>
146                        </goals>
147                        <configuration>
148                            <outputDirectory>${project.build.directory}</outputDirectory>
149                            <resources>
150                                <resource>
151                                    <directory>${basedir}</directory>
152                                    <includes>
153                                        <include>MANIFEST.in</include>
154                                        <include>README-dist.txt</include>
155                                        <include>setup.py</include>
156                                        <include>setup.cfg</include>
157                                    </includes>
158                                </resource>
159                            </resources>
160                        </configuration>
161                    </execution>
162                    <execution>
163                        <id>copy logging.properties.template to dist</id>
164                        <phase>package</phase>
165                        <goals>
166                            <goal>copy-resources</goal>
167                        </goals>
168                        <configuration>
169                            <outputDirectory>${project.build.directory}/dist</outputDirectory>
170                            <resources>
171                                <resource>
172                                    <directory>${basedir}</directory>
173                                    <includes>
174                                        <include>logging.properties.template</include>
175                                    </includes>
176                                </resource>
177                            </resources>
178                        </configuration>
179                    </execution>
180                </executions>
181            </plugin>
182            <plugin>
183                <groupId>org.codehaus.mojo</groupId>
184                <artifactId>exec-maven-plugin</artifactId>
185                <version>1.6.0</version>
186                <executions>
187                    <execution>
188                        <id>Generate python env</id>
189                        <configuration>
190                            <executable>${python.system.executable}</executable>
191                            <workingDirectory>${project.build.directory}</workingDirectory>
192                            <arguments>
193                                <argument>-m</argument>
194                                <argument>venv</argument>
195                                <argument>env</argument>
196                            </arguments>
197                        </configuration>
198                        <phase>test</phase>
199                        <goals>
200                            <goal>exec</goal>
201                        </goals>
202                    </execution>
203                    <execution>
204                        <!-- needed for 'pip install pylint' to work -->
205                        <id>Upgrade pip and install/upgrade other packages</id>
206                        <configuration>
207                            <executable>${python.environment}/python</executable>
208                            <workingDirectory>${project.build.directory}</workingDirectory>
209                            <arguments>
210                                <argument>-m</argument>
211                                <argument>pip</argument>
212                                <argument>install</argument>
213                                <argument>--upgrade</argument>
214                                <argument>pip</argument>
215                                <argument>setuptools</argument>
216                                <argument>certifi</argument>
217                                <argument>wheel</argument>
218                            </arguments>
219                        </configuration>
220                        <phase>test</phase>
221                        <goals>
222                            <goal>exec</goal>
223                        </goals>
224                    </execution>
225                    <execution>
226                        <id>Generate python package</id>
227                        <goals>
228                            <goal>exec</goal>
229                        </goals>
230                        <configuration>
231                            <executable>${python.environment}/python</executable>
232                            <workingDirectory>${project.build.directory}</workingDirectory>
233                            <arguments>
234                                <argument>setup.py</argument>
235                                <argument>sdist</argument>
236                                <argument>--formats</argument>
237                                <argument>gztar</argument>
238                            </arguments>
239                        </configuration>
240                        <phase>package</phase>
241                    </execution>
242                    <execution>
243                        <id>Install python package for tests/pylint</id>
244                        <configuration>
245                            <executable>${python.environment}/python</executable>
246                            <workingDirectory>${project.build.directory}</workingDirectory>
247                            <arguments>
248                                <argument>setup.py</argument>
249                                <argument>install</argument>
250                            </arguments>
251                            <skip>${skipPythonTests}</skip>
252                        </configuration>
253                        <phase>test</phase>
254                        <goals>
255                            <goal>exec</goal>
256                        </goals>
257                    </execution>
258                    <execution>
259                        <id>Install python lint and flake8</id>
260                        <configuration>
261                            <executable>${python.environment}/python</executable>
262                            <workingDirectory>${project.build.directory}</workingDirectory>
263                            <arguments>
264                                <argument>-m</argument>
265                                <argument>pip</argument>
266                                <argument>install</argument>
267                                <argument>pylint</argument>
268                                <argument>flake8</argument>
269                            </arguments>
270                        </configuration>
271                        <phase>verify</phase>
272                        <goals>
273                            <goal>exec</goal>
274                        </goals>
275                    </execution>
276                    <execution>
277                        <id>Python lint</id>
278                        <configuration>
279                            <executable>${python.environment}/python</executable>
280                            <workingDirectory>${project.build.directory}</workingDirectory>
281                            <arguments>
282                                <argument>-m</argument>
283                                <argument>pylint</argument>
284                                <argument>--max-line-length</argument>
285                                <argument>${python.checkstyle.line-length}</argument>
286                                <argument>-E</argument>
287                                <argument>${project.build.sourceDirectory}/opengrok_tools</argument>
288                                <argument>${project.build.directory}/setup.py</argument>
289                            </arguments>
290                            <skip>${skipPythonTests}</skip>
291                        </configuration>
292                        <phase>verify</phase>
293                        <goals>
294                            <goal>exec</goal>
295                        </goals>
296                    </execution>
297                    <execution>
298                        <id>Python flake8</id>
299                        <configuration>
300                            <executable>${python.environment}/python</executable>
301                            <workingDirectory>${project.build.directory}</workingDirectory>
302                            <arguments>
303                                <argument>-m</argument>
304                                <argument>flake8</argument>
305                                <argument>--max-line-length</argument>
306                                <argument>${python.checkstyle.line-length}</argument>
307                                <argument>-v</argument>
308                                <argument>${project.build.sourceDirectory}</argument>
309                                <argument>${project.build.testSourceDirectory}</argument>
310                                <argument>setup.py</argument>
311                            </arguments>
312                        </configuration>
313                        <phase>verify</phase>
314                        <goals>
315                            <goal>exec</goal>
316                        </goals>
317                    </execution>
318                    <execution>
319                        <id>Test python package</id>
320                        <configuration>
321                            <executable>${python.environment}/python</executable>
322                            <workingDirectory>${project.build.directory}</workingDirectory>
323                            <environmentVariables>
324                                <PATH>${python.environment}:${env.PATH}</PATH>
325                            </environmentVariables>
326                            <arguments>
327                                <argument>setup.py</argument>
328                                <argument>test</argument>
329                            </arguments>
330                            <skip>${skipPythonTests}</skip>
331                        </configuration>
332                        <phase>test</phase>
333                        <goals>
334                            <goal>exec</goal>
335                        </goals>
336                    </execution>
337                </executions>
338            </plugin>
339            <plugin>
340                <groupId>org.apache.maven.plugins</groupId>
341                <artifactId>maven-checkstyle-plugin</artifactId>
342            </plugin>
343        </plugins>
344    </build>
345</project>
346