cancel
Showing results for 
Search instead for 
Did you mean: 

Modify module.properties from pom.xml

satheeshkumar
Champ in-the-making
Champ in-the-making
Hi,

We have been using Alfresco 3.X version for a quite long time where we use ANT's build.xml to create an AMP package. In that we have an automated script which reads the module.properties and increments the build.number by one and update the module.properties, so each time we create a build the build.number will be incremented by one, so module.version=${major.version}.${minor.version}.${build.number} will also be incremented accordingly.
Sample build.xml script is shown below,

   

        <target name="increment-build-number">
      <property file="config/alfresco/module/alfresco/module.properties"/>
      <propertyfile file="config/alfresco/module/alfresco/module.properties">
         <entry  key="build.number" type="int" default="0" operation="+"/>
         <entry  key="module.version" type="string" operation="=" value="${major.version}.${minor.version}.${build.number}"/>
      </propertyfile>
   </target>


Now we are upgrading to Alfresco Community 5.0, where we are using Maven's pom.xml to create an AMP package.
Can some one help me how to increment the build.number as mentioned above using Maven's pom.xml.
Want I want is, I would like to create similar script in pom.xml as mentioned above(build.xml) to do the automatic increment of build.numer and module.version and update them in module.properties.
I'm pretty new to Maven, so any help would be greatly appreciated.
2 REPLIES 2

satheeshkumar
Champ in-the-making
Champ in-the-making
Can someone help me to figure out, how to do the above stated task in Maven?
It's been 10 days, since I asked, but could not see any comments yet.
Is there a way to do this? Please can someone help?

satheeshkumar
Champ in-the-making
Champ in-the-making
Finally, after long research, I was able to figure out and find a way to achieve this.
I used maven-antrun-plugin, to get this thing done.
Below is the code snippet, can be useful for someone, hence sharing.


   <build>   
      <plugins>
         <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
               <execution>
                  <phase>generate-sources</phase>
                  <configuration>

                     <!– Place any ant task here. You can add anything you can add between
                        <target> and </target> in a build.xml. –>
                     <target name="increment-build-number">
                     <echo>Incrementing Build Number and Updating module.properties file.</echo>
                        <property file="src/main/amp/module.properties" />
                        <propertyfile file="src/main/amp/module.properties">
                           <entry key="build.number" type="int" default="0"
                              operation="+" />
                           <entry key="module.version" type="string" operation="="
                              value="${major.version}.${minor.version}.${build.number}" />
                        </propertyfile>
                     </target>
                  </configuration>
                  <goals>
                     <goal>run</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>