Bonjour,

Je fais face à un petit problème.
Je souhaite créer une variable à utiliser dans mon POM, que j’enrichirai lors du lancement de la commande mvn.

Mon problème est le suivant:

Voici ma commande:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
mvn -Dtgt=src release:prepare
Voici mon pom.xml:
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
<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>com.projet</groupId>
<artifactId>nom-projet</artifactId>
<version>1.9-SNAPSHOT</version>
 
<name>Maven Assembly</name>
 
<scm>
	<connection>connection</connection>
	<developerConnection>connection</developerConnection>
	<url>url</url>
	<tag>HEAD</tag>
 </scm>
 
<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
 
<distributionManagement>
   <repository>
      <id>nexus</id>
      <url>url.nexus</url>
   </repository>
   <snapshotRepository>
      <id>snpsht.nexus</id>
      <url>url.nexus.snapshot</url>
   </snapshotRepository>
</distributionManagement>
 
<build>
	<plugins>		
		<plugin>
                <groupId>ru.yaal.maven</groupId>
                <artifactId>write-text-files-maven-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <charset>UTF-8</charset>
                    <files>
                        <file>
                            <path>${tgt}/version.txt</path>
                            <lines>
                                <line>Version: ${project.version}</line>                               
                            </lines>
                        </file>
                    </files>
                </configuration>
                <executions>
                    <execution>
                        <id>write-text-files</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>write-text-files</goal>
                        </goals>
                    </execution>
                </executions>
        </plugin>
 
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-assembly-plugin</artifactId>
			<version>2.3</version>
			<configuration>
				<descriptors>
					<descriptor>assembly-final.xml</descriptor>
				</descriptors>
			</configuration>
			<executions>
				<execution>
					<id>assembly</id>
					<phase>package</phase>
					<goals>
						<goal>single</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>		
</build>
 
</project>

A noter que tout fonctionne correctement je n'utilise pas de variable.
Si nous observons le plugin write-text-files-maven-plugin, j'ai défini le path <path>${tgt}/version.txt</path> censé devenir src/version.txt (si on se base sur la commande lancée).
Seulement à la place ça, il me crée un répertoire ${tgt} avec mon fichier version.txt dedans.

Nom : Capture.PNG
Affichages : 709
Taille : 4,9 Ko

J'en déduis donc qu'il ne vois pas ${tgt} comme une variable? Comment faire?