Skip to content

Commit a99355d

Browse files
author
Vladimir Kotal
committed
generate info.properties file from Maven
helps with #2244
1 parent f3e7c6e commit a99355d

File tree

2 files changed

+76
-61
lines changed

2 files changed

+76
-61
lines changed

opengrok-indexer/build.xml

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -54,58 +54,13 @@ Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
5454

5555
<property name="git" value="git"/>
5656

57-
<!-- Get the id of the changeset we're building from using a
58-
Mercurial command.
59-
-->
60-
<target name="-get-changeset-from-command"
61-
depends="-check-is-git-repo" if="build.from.repo">
62-
<exec executable="${git}"
63-
failifexecutionfails="no"
64-
outputproperty="changeset">
65-
<arg value="rev-parse"/>
66-
<arg value="HEAD"/>
67-
</exec>
68-
</target>
69-
70-
<!-- Check if we build from a checked out copy of the repository,
71-
so that we have history information from git available.
72-
-->
73-
<target name="-check-is-git-repo">
74-
<available property="build.from.repo" file=".git" filepath=".." type="dir"/>
75-
</target>
76-
77-
<!-- Get the id of the changeset we're building from by reading
78-
.git_archival.txt file created by git archive. This will only
79-
be used when we're not building from a checked out copy of
80-
the repository, for example the source distribution.
81-
-->
82-
<target name="-get-changeset-from-file"
83-
depends="-check-is-git-repo" unless="build.from.repo">
84-
<tempfile property="git.archival.temp" deleteonexit="true"/>
85-
<copy file="../.git_archival.txt" tofile="${git.archival.temp}"/>
86-
<replaceregexp file="${g.archival.temp}" flags="s"
87-
match=".*node: ([0-9a-f]{12}).*"
88-
replace="\1"/>
89-
<loadfile srcFile="${git.archival.temp}" property="changeset"/>
90-
</target>
91-
9257
<target name="-collect-lex-lexh">
9358
<mkdir dir="${tgt.dir}"/>
9459
<copy todir="${tgt.dir}" flatten="true">
9560
<fileset dir="${src.dir}" includes="**/*.lex,**/*.lexh"/>
9661
</copy>
9762
</target>
9863

99-
<target name="-update-build-info"
100-
depends="-get-changeset-from-command,-get-changeset-from-file">
101-
<mkdir dir="${build.classes.dir}/org/opengrok/indexer"/>
102-
<propertyfile
103-
file="${build.classes.dir}/org/opengrok/indexer/info.properties">
104-
<entry key="version" value="${version}"/>
105-
<entry key="changeset" value="${changeset}"/>
106-
</propertyfile>
107-
</target>
108-
10964
<target name="-post-compile-test">
11065
<antcall target="-create-svn-repository"/>
11166
<antcall target="-create-razor-repository"/>

opengrok-indexer/pom.xml

Lines changed: 76 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
3737

3838
<name>OpenGrok Indexer</name>
3939

40+
<properties>
41+
<version>${project.version}</version>
42+
</properties>
43+
4044
<dependencies>
4145
<dependency>
4246
<groupId>org.apache.bcel</groupId>
@@ -152,9 +156,78 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
152156
</dependencies>
153157

154158
<build>
155-
156159
<plugins>
157-
160+
<plugin>
161+
<groupId>pl.project13.maven</groupId>
162+
<artifactId>git-commit-id-plugin</artifactId>
163+
<version>2.2.4</version>
164+
<configuration>
165+
<includeOnlyProperties>
166+
<includeOnlyProperty>^git.commit.id$</includeOnlyProperty>
167+
</includeOnlyProperties>
168+
</configuration>
169+
<executions>
170+
<execution>
171+
<id>get-the-git-infos</id>
172+
<goals>
173+
<goal>revision</goal>
174+
</goals>
175+
<phase>initialize</phase>
176+
</execution>
177+
<execution>
178+
<id>validate-the-git-infos</id>
179+
<goals>
180+
<goal>validateRevision</goal>
181+
</goals>
182+
<phase>package</phase>
183+
</execution>
184+
</executions>
185+
</plugin>
186+
<plugin>
187+
<groupId>org.codehaus.mojo</groupId>
188+
<artifactId>properties-maven-plugin</artifactId>
189+
<version>1.0.0</version>
190+
<executions>
191+
<execution>
192+
<id>generate-info-properties</id>
193+
<phase>generate-resources</phase>
194+
<goals>
195+
<goal>write-project-properties</goal>
196+
</goals>
197+
<configuration>
198+
<outputFile>
199+
${project.build.outputDirectory}/org/opengrok/indexer/info.properties
200+
</outputFile>
201+
</configuration>
202+
</execution>
203+
</executions>
204+
</plugin>
205+
<plugin>
206+
<groupId>com.google.code.maven-replacer-plugin</groupId>
207+
<artifactId>replacer</artifactId>
208+
<version>1.5.3</version>
209+
<executions>
210+
<execution>
211+
<id>perform-git-substitutions</id>
212+
<goals>
213+
<goal>replace</goal>
214+
</goals>
215+
<phase>process-resources</phase>
216+
<configuration>
217+
<filesToInclude>
218+
${project.build.outputDirectory}/org/opengrok/indexer/info.properties
219+
</filesToInclude>
220+
<replacements>
221+
<replacement>
222+
<token>git.commit.id</token>
223+
<value>changeset</value>
224+
</replacement>
225+
</replacements>
226+
<quiet>false</quiet>
227+
</configuration>
228+
</execution>
229+
</executions>
230+
</plugin>
158231
<plugin>
159232
<groupId>org.apache.maven.plugins</groupId>
160233
<artifactId>maven-jar-plugin</artifactId>
@@ -210,6 +283,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
210283
<version>1.5.3</version>
211284
<executions>
212285
<execution>
286+
<id>replace-in-jflex-sources</id>
213287
<phase>generate-sources</phase>
214288
<goals>
215289
<goal>replace</goal>
@@ -243,7 +317,6 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
243317
<token>[ \t]*/\* not supposed to occur according to specification of java\.io\.Reader \*/\s+if \(numRead == 0.*?\}[ \t]*\r?\n</token>
244318
<value></value>
245319
</replacement>
246-
247320
</replacements>
248321
<regexFlags>
249322
<regexFlag>DOTALL</regexFlag>
@@ -270,19 +343,6 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
270343
<goal>run</goal>
271344
</goals>
272345
</execution>
273-
<execution>
274-
<id>update-build-info</id>
275-
<phase>generate-resources</phase>
276-
<configuration>
277-
<target>
278-
<property name="version" value="${project.version}"/>
279-
<ant target="-update-build-info"/>
280-
</target>
281-
</configuration>
282-
<goals>
283-
<goal>run</goal>
284-
</goals>
285-
</execution>
286346
<execution>
287347
<id>build-config-files</id>
288348
<phase>process-test-classes</phase>

0 commit comments

Comments
 (0)