From a5c45149f8a3d595a3a47c2c5d7ee323e926fdbe Mon Sep 17 00:00:00 2001
From: Nicola Fulvio Calabria <nicola.calabria@inaf.it>
Date: Mon, 20 Mar 2023 21:56:19 +0100
Subject: [PATCH] extend pom to use revisions

---
 .gitlab-ci.yml |  6 +++---
 pom.xml        | 31 +++++++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ebe4c3d..de1de91 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -13,7 +13,7 @@ build:
   artifacts:
     paths:
       - target/vospace-datamodel.jar
-      - pom.xml
+      - flattened-pom.xml
     expire_in: 7 days
   only:
     - master
@@ -24,7 +24,7 @@ build-test:
     - docker
   image: maven:3.6.3-openjdk-14
   script:
-    - mvn clean package -DskipTests -DfinalName=vospace-datamodel-test -Drevision=TEST
+    - mvn clean package -DskipTests -DfinalName=vospace-datamodel-test -Drevision=0.0.2-TEST
   artifacts:
     paths:
       - target/vospace-datamodel-test.jar
@@ -63,7 +63,7 @@ deploy:
     - mvn deploy:deploy-file
         -Dfile=target/vospace-datamodel.jar
         -DrepositoryId=ia2.snapshots
-        -DpomFile=pom.xml
+        -DpomFile=flattened-pom.xml
         -Durl=${IA2_MVN_REPO_SNAPSHOTS}
   only:
     - master
diff --git a/pom.xml b/pom.xml
index 21de764..ac22cd1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,12 +3,13 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>it.oats.inaf</groupId>
     <artifactId>vospace-datamodel</artifactId>
-    <version>0.0.2-SNAPSHOT</version>
+    <version>${revision}</version>
     <packaging>jar</packaging>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <maven.compiler.source>14</maven.compiler.source>
         <maven.compiler.target>14</maven.compiler.target>
+	<revision>0.0.2-SNAPSHOT</revision>
         <finalName>${project.artifactId}-${project.version}</finalName>
     </properties>
     
@@ -59,7 +60,33 @@
     </dependencies>
     <build>
         <finalName>${finalName}</finalName>
-        <plugins>            
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>flatten-maven-plugin</artifactId>
+                <version>1.3.0</version>
+                <configuration>
+                    <updatePomFile>true</updatePomFile>
+                    <flattenMode>resolveCiFriendliesOnly</flattenMode>
+                    <flattenedPomFilename>flattened-pom.xml</flattenedPomFilename>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>flatten</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>flatten</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>flatten.clean</id>
+                        <phase>clean</phase>
+                        <goals>
+                            <goal>clean</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>            
             <plugin>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <version>2.22.2</version>
-- 
GitLab