Bonjour,

Je travaille sur un projet Maven importé sous Eclipse Neon qui intègre M2Eclipse et donc la version 3.3.9 de Maven.
Les sources de mon projet sont gérées sous SVN 1.6 (oui je sais c'est vieux, mais l'équipe Systèmes ne souhaite pas upgrader vers la version 1.7 ou 1.8).

J'ai voulu utiliser le plugin buildnumber-maven-plugin pour, à la fois, récupérer le numéro de révision du dépôt svn et générer un numéro de build incrémental dans l'intention de les ajouter au Manifest.MF.

Après quelques tâtonnements, le pom.xml ci-dessous fait presque ce que j'attends. En fait, tout marche bien, à l'exception du fait que le buildNumber n'est pas augmenté séquentiellement à chaque build.
Il est incrémenté notamment chaque fois que je fais une modification dans un fichier source ou dans le pom.xml lui-même. De plus n'est pas toujours augmenté de 1 à chaque fois, sans que j'ai pu trouver une logique à la façon dont il est incrémenté. Ce n'est donc plus un "buildNumber" mais un compteur d'actions.

Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<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/xsd/maven-4.0.0.xsd">
 
	<modelVersion>4.0.0</modelVersion>
 
	<groupId>mygroup</groupId>
	<artifactId>myartifact</artifactId>
	<version>3.1.0</version>
	<!--  <packaging>jar</packaging>-->
 
	<name>myproject</name>
	<url>http://maven.apache.org</url>
 
	<properties>
		<subversion.repository>svn://myserversvn/pse/trunk/</subversion.repository>
		<redmine.url>https://myredmine:3000/</redmine.url>
		<src>src</src>
		<src.java>src/java</src.java>
		<src.junit>src/junit</src.junit>
		<src.resources>src/resources</src.resources>
		<target>target</target>
		<target.java>target/java</target.java>
		<target.junit>target/junit</target.junit>
		<target.javadoc>target/javadoc</target.javadoc>
		<compileSource>1.8</compileSource>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<!-- Specific properties -->
		<codaclibs>${project.basedir}/../dependencies/codac-libs</codaclibs>
	</properties>
 
	<scm>
		<connection>scm:svn:${subversion.repository}/myproject/trunk</connection>
		<developerConnection>scm:svn:${subversion.repository}/myproject</developerConnection>
		<url>${redmine.url}/projects/pse/repository</url>
	</scm>
 
	<build>
		<sourceDirectory>${src.java}</sourceDirectory>
		<testSourceDirectory>${src.junit}</testSourceDirectory>
 
		<!-- This section is mandatory to avoid an error message in the definition of buildnumber-maven-plugin -->
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>org.codehaus.mojo</groupId>
										<artifactId>buildnumber-maven-plugin</artifactId>
										<versionRange>[1.2,)</versionRange>
										<goals>
											<goal>create</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<execute>
											<runOnConfiguration>true</runOnConfiguration>
											<runOnIncremental>true</runOnIncremental>
										</execute>
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
 
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>buildnumber-maven-plugin</artifactId>		
				<version>1.4</version>
				<executions>
					<!-- First step to get svn revision number as buildNumber -->
					<!-- Works only on a machine on which svn is installed (so not on a PC a priori) -->
					<execution>
						<id>number1</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>create</goal>
						</goals>
						<configuration>
							<doCheck>false</doCheck>
							<doUpdate>false</doUpdate>
							<revisionOnScmFailure>unknown</revisionOnScmFailure>
							<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
							<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
						</configuration>
					</execution>
					<execution>
						<!-- Second step to compute an incremental number as myBuildNumber -->
						<id>number2</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>create</goal>
						</goals>
						<configuration>
							<doCheck>false</doCheck>
							<doUpdate>false</doUpdate>
							<revisionOnScmFailure>svn revision unknown</revisionOnScmFailure>
							<buildNumberPropertyName>myBuildNumber</buildNumberPropertyName>
							<format>#{0}</format> 
							<items>
								<item>buildNumber</item>
							</items>
							<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
							<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
						</configuration>
					</execution>
				</executions>
			</plugin>
 
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.5.1</version>
				<executions>
					<execution>
						<id>default-testCompile</id>
						<phase>test-compile</phase>
						<goals>
							<goal>testCompile</goal>
						</goals>
						<configuration>
							<skip>true</skip>
						</configuration>
					</execution>
					<execution>
						<id>default-compile</id>
						<phase>compile</phase>
						<goals>
							<goal>compile</goal>
						</goals>
						<configuration>
							<source>${compileSource}</source>
							<target>${compileSource}</target>
						</configuration>
					</execution>
				</executions>
			</plugin>
 
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.1.1</version>
				<configuration>
					<archive>
						<manifest>
							<mainClass>${mainclass}</mainClass>
						</manifest>
						<manifestEntries>
							<groupId>${project.groupId}</groupId>
							<artifactId>${project.artifactId}</artifactId>
							<version>${project.version}</version>
							<Build>svn rev ${buildNumber}-build${myBuildNumber} at ${timestamp}</Build>
						</manifestEntries>
					</archive>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>3.0.0-M3</version>
				<configuration>
					<forkMode>always</forkMode>
					<skipTests>true</skipTests>
				</configuration>
			</plugin>
		</plugins>
	</build>
 
	<dependencies>
		<dependency>
			...
		</dependency>
		...
	</dependencies>
</project>

Quelqu'un pourrait-il m'expliquer la raison de ce comportement?
Une idée pour corriger ça et obtenir un "vrai" compteur de build (augmenté de 1 chaque fois que je lance la commande 'Maven install')?

Pour info si je supprime l'exécution qui récupère le numéro de révision svn (<id>number1</id>), cela n'influe pas sur la génération du numéro de build incrémental.

Merci à tous ceux qui se pencheront sur ma question.
Cordialement,
Jacqueline