Bonjour,

Mon problème est simple. J'aimerais, à la compilation de mon projet, récupérer la variable Build_Number que Hudson génère durant le build, afin de le placer dans le champ versionCode mon AndroidManifest.

Voici la portion de code du fichier pom.xml (je vous ai sélectionné que la partie la plus importante, celle du build:
Code : 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
<build>
        <finalName>${project.artifactId}-${project.version}.{buildNumber}</finalName>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>maven-android-plugin</artifactId>
                <version>2.8.4</version>
                <configuration>
                    <sdk>
                        <!-- platform or api level (api level 4 = platform 1.6)-->
                        <platform>8</platform>
                    </sdk>
                    <emulator>
                        <!-- the name of the avd device to use for starting the emulator -->
                        <avd>Android2.1-update1</avd>
                    </emulator>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>
 
 
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <archive>
                    <manifestEntries>
                        <Svn-Revision>${SVN_REVISION}</Svn-Revision>
                        <Build-Tag>${BUILD_TAG}</Build-Tag>
                        <Build-Number>${BUILD_NUMBER}</Build-Number>
                        <Build-Id>${BUILD_ID}</Build-Id>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
 
 
              <plugin>
                <!-- Sets the AndroidManifest.xml Version Name to the projects version number -->
                <groupId>org.codehaus.groovy.maven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <source>
 
                                    try {
                                        def manifestFile = new File("AndroidManifest.xml")
                                        def ns = new groovy.xml.Namespace(
                                            "http://schemas.android.com/apk/res/android", "ns")
                                        def parser = new groovy.util.XmlParser(false, true)
                                        def rootNode = parser.parse(manifestFile)
                                        def attributes = rootNode.attributes()
                                        attributes[ns.versionName] = "${project.version}"
                                        def writer = new groovy.io.GroovyPrintWriter(manifestFile)
                                        writer.println('&lt;?xml version="1.0" encoding="UTF-8"?&gt;')
                                        def xmlWriter = new groovy.util.XmlNodePrinter(writer)
                                        xmlWriter.setPreserveWhitespace(false)
                                        xmlWriter.setNamespaceAware(true)
                                        xmlWriter.print(rootNode)
                                    } catch (FileNotFoundException e)
                                    {
                                        println('No AndroidManifest.xml file found. Skipping version update.')
                                        println('Probably not an Android project, but a library.')
                                        println('Skipping version update.')
                                    }
 
                            </source>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
 
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <!-- version 2.3 defaults to java 1.5, so no further configuration needed-->
                <version>2.3</version>
            </plugin>
 
 
        </plugins>
    </build>
Grâce au second plugin, j'arrive à récupérer le build number mais cette valeur va se mettre dans un autre fichier, et ce n'est pas ce que je veux. Et quand je mets directement $(BUILD_NUMBER) dans le champ versionName (dans mon troisième plugin), à la compilation ça me dit que le champ n'existe pas.

Quelqu'un saurait-il m'indiquer comment résoudre ce problème ?

Merci d'avance pour votre aide.