From 04e859bc48149bddea221d4d4f272c58266be9ae Mon Sep 17 00:00:00 2001
From: Vincent Massol <vincent@massol.net>
Date: Thu, 24 Mar 2022 11:01:07 +0100
Subject: [PATCH] [Misc] Force the docker image releaser to update the JDBC
 driver versions (so that they're up to date)

---
 build.gradle        | 26 +++++++++++++++++++++-----
 template/Dockerfile | 12 ++++--------
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/build.gradle b/build.gradle
index a69ddd2..10bd8fd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -29,18 +29,34 @@ defaultTasks 'generate'
 
 def variants = ['mysql-tomcat', 'mariadb-tomcat', 'postgres-tomcat']
 
-// Note: To compute the sha256, download the XWiki WAR and issue:
-// - Unix: sha256sum <binary name>
-// - Mac: shasum --algorithm 256 <binary name>
+// Notes:
+// - To compute the XWiki sha256, download the XWiki WAR and issue:
+//   - Unix: sha256sum <binary name>
+//   - Mac: shasum --algorithm 256 <binary name>
+// - To compute the mysql JDBC sha256, get the JAR at https://search.maven.org/artifact/mysql/mysql-connector-java and
+//   do the same as for the XWiki sha256.
+// - To compute the mysql JDBC sha256, get the JAR at
+//   https://search.maven.org/artifact/org.mariadb.jdbc/mariadb-java-client and  do the same as for the XWiki sha256.
+// - Use the JDBC driver versions found in the XWiki POM for the specified versions:
+//   - mysql: https://github.com/xwiki/xwiki-platform/blob/master/pom.xml#L97 (link for master)
+//   - mariadb: https://github.com/xwiki/xwiki-platform/blob/master/pom.xml#L100 (link for master)
 
 def tokens = [
     '14': [
         xwikiVersion: '14.1',
-        xwikiSha256: '71d739098e9edc2f343c7a7c15034cf0651ad8e97f1cb59ae0c979181fc677a3'
+        xwikiSha256: '71d739098e9edc2f343c7a7c15034cf0651ad8e97f1cb59ae0c979181fc677a3',
+        mysqlJDBCVersion: '8.0.28',
+        mysqlJDBCSha256: 'a00ccdf537ff50e50067b989108c2235197ffb65e197149bbb669db843cd1c3e',
+        mariadbJDBCVersion: '3.0.3',
+        mariadbJDBCSha256: '613086a0a20f177dfcf5e227f519272bc6be88bde4011de0f23c533231a7ae05'
     ],
     '13': [
         xwikiVersion: '13.10.3',
-        xwikiSha256: 'f4f13dcab88baffb0e62fccc5d6375a6d023e4ac7414c502375dd1e8d503cbbd'
+        xwikiSha256: 'f4f13dcab88baffb0e62fccc5d6375a6d023e4ac7414c502375dd1e8d503cbbd',
+        mysqlJDBCVersion: '8.0.28',
+        mysqlJDBCSha256: 'a00ccdf537ff50e50067b989108c2235197ffb65e197149bbb669db843cd1c3e',
+        mariadbJDBCVersion: '3.0.3',
+        mariadbJDBCSha256: '613086a0a20f177dfcf5e227f519272bc6be88bde4011de0f23c533231a7ae05'
     ]
 ]
 
diff --git a/template/Dockerfile b/template/Dockerfile
index cac53e4..310ee77 100644
--- a/template/Dockerfile
+++ b/template/Dockerfile
@@ -63,10 +63,8 @@ RUN rm -rf /usr/local/tomcat/webapps/* && \\
 <% if (db == 'mysql') {
   println "# For MYSQL, download the MySQL driver version from the Maven Central repository since there's no up to "
   println "# date Debian repository for it anymore."
-  println "ENV MYSQL_JDBC_VERSION=\"8.0.28\""
-  // Get the SHA256 from the JAR at https://search.maven.org/artifact/mysql/mysql-connector-java and using the
-  // command line defined in build.gradle.
-  println "ENV MYSQL_JDBC_SHA256=\"a00ccdf537ff50e50067b989108c2235197ffb65e197149bbb669db843cd1c3e\""
+  println "ENV MYSQL_JDBC_VERSION=\"$mysqlJDBCVersion\""
+  println "ENV MYSQL_JDBC_SHA256=\"$mysqlJDBCSha256\""
   println "ENV MYSQL_JDBC_PREFIX=\"https://repo1.maven.org/maven2/mysql/mysql-connector-java/\${MYSQL_JDBC_VERSION}\""
   println "ENV MYSQL_JDBC_ARTIFACT=\"mysql-connector-java-\${MYSQL_JDBC_VERSION}.jar\""
   println "ENV MYSQL_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/\${MYSQL_JDBC_ARTIFACT}\""
@@ -75,10 +73,8 @@ RUN rm -rf /usr/local/tomcat/webapps/* && \\
 } else if (db == 'mariadb') {
   println "# For MariaDB, download the MariaDB driver version from the Maven Central repository to control the version "
   println "# used."
-  println "ENV MARIADB_JDBC_VERSION=\"3.0.3\""
-  // Get the SHA256 from the JAR at https://search.maven.org/artifact/org.mariadb.jdbc/mariadb-java-client and using the
-  // command line defined in build.gradle.
-  println "ENV MARIADB_JDBC_SHA256=\"613086a0a20f177dfcf5e227f519272bc6be88bde4011de0f23c533231a7ae05\""
+  println "ENV MARIADB_JDBC_VERSION=\"$mariadbJDBCVersion\""
+  println "ENV MARIADB_JDBC_SHA256=\"$mariadbJDBCSha256\""
   println "ENV MARIADB_JDBC_PREFIX=\"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/\${MARIADB_JDBC_VERSION}\""
   println "ENV MARIADB_JDBC_ARTIFACT=\"mariadb-java-client-\${MARIADB_JDBC_VERSION}.jar\""
   println "ENV MARIADB_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/\${MARIADB_JDBC_ARTIFACT}\""
-- 
GitLab