auto update snapshot-version, snapshot-versionCode via regex property

This commit is contained in:
Anthony Calosa
2024-10-10 17:10:05 +08:00
parent 28a28bfd68
commit ad81b0e32d
2 changed files with 83 additions and 7 deletions

View File

@@ -1 +1 @@
${alpha-version} ${snapshot-version}

View File

@@ -8,8 +8,6 @@
<build.min.memory>-Xms1024m</build.min.memory> <build.min.memory>-Xms1024m</build.min.memory>
<build.max.memory>-Xmx1536m</build.max.memory> <build.max.memory>-Xmx1536m</build.max.memory>
<alpha-version>${revision}</alpha-version> <alpha-version>${revision}</alpha-version>
<!-- the previous android:versionCode was 106650000, so it must be larger or it will not be installed -->
<alpha-versionCode>200000000</alpha-versionCode>
<sign.keystore>keystore</sign.keystore> <sign.keystore>keystore</sign.keystore>
<sign.alias>alias</sign.alias> <sign.alias>alias</sign.alias>
<sign.storepass>storepass</sign.storepass> <sign.storepass>storepass</sign.storepass>
@@ -39,6 +37,52 @@
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<plugins> <plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>timestamp-property</id>
<phase>initialize</phase>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>month.date</name>
<pattern>MMdd</pattern>
</configuration>
</execution>
<execution>
<id>regex-property</id>
<phase>initialize</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>snapshot-version</name>
<value>${revision}</value>
<regex>-SNAPSHOT</regex>
<replacement>-SNAPSHOT-${month.date}</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
<execution>
<id>regex-property2</id>
<phase>initialize</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>snapshot-versionCode</name>
<value>${revision}</value>
<regex>[^0-9]</regex>
<replacement></replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
@@ -53,7 +97,7 @@
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
<finalName>forge-android-${alpha-version}</finalName> <finalName>forge-android-${snapshot-version}</finalName>
</build> </build>
<dependencies> <dependencies>
<dependency> <dependency>
@@ -268,7 +312,7 @@
<configuration> <configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile> <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<manifestVersionName>${alpha-version}</manifestVersionName> <manifestVersionName>${alpha-version}</manifestVersionName>
<manifestVersionCode>${alpha-versionCode}</manifestVersionCode> <manifestVersionCode>1</manifestVersionCode>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
@@ -283,6 +327,38 @@
</properties> </properties>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>timestamp-property</id>
<phase>initialize</phase>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>month.date</name>
<pattern>MMdd</pattern>
</configuration>
</execution>
<execution>
<id>regex-property</id>
<phase>initialize</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>snapshot-version</name>
<value>${revision}</value>
<regex>-SNAPSHOT</regex>
<replacement>-SNAPSHOT-${month.date}</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<artifactId>exec-maven-plugin</artifactId> <artifactId>exec-maven-plugin</artifactId>
<version>3.4.1</version> <version>3.4.1</version>
@@ -388,8 +464,8 @@
</goals> </goals>
<configuration> <configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile> <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<manifestVersionName>${alpha-version}</manifestVersionName> <manifestVersionName>${snapshot-version}</manifestVersionName>
<manifestVersionCode>${alpha-versionCode}</manifestVersionCode> <manifestVersionCode>${snapshot-versionCode}0${month.date}</manifestVersionCode>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>