Relocate MySQL connector and fix migrations

This commit is contained in:
Gabriele C 2021-11-28 16:47:47 +01:00
parent 0a418e886a
commit 31564d8284
5 changed files with 17 additions and 12 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Sat Aug 21 23:12:31 CEST 2021. See docs/config/config.tpl.md -->
<!-- File auto-generated on Sun Nov 28 16:47:07 CET 2021. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -30,9 +30,9 @@ DataSource:
mySQLPassword: '12345'
# Driver Name of the MySQL database.
# Built-in drivers:
# MySQL: 'com.mysql.cj.jdbc.Driver'
# MariaDB: 'org.mariadb.jdbc.Driver'
mySQLDriverClassName: com.mysql.cj.jdbc.Driver
# MySQL: 'fr.xephi.authme.libs.com.mysql.cj.jdbc.Driver'
# MariaDB: 'fr.xephi.authme.libs.org.mariadb.jdbc.Driver'
mySQLDriverClassName: fr.xephi.authme.libs.com.mysql.cj.jdbc.Driver
# Database Name, use with converters or as SQLITE database name
mySQLDatabase: authme
# Table of the database
@ -590,4 +590,4 @@ To change settings on a running server, save your changes to config.yml and use
---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Aug 21 23:12:31 CEST 2021
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Nov 28 16:47:07 CET 2021

View File

@ -384,6 +384,10 @@
<pattern>org.mariadb.jdbc</pattern>
<shadedPattern>fr.xephi.authme.libs.org.mariadb.jdbc</shadedPattern>
</relocation>
<relocation>
<pattern>com.mysql</pattern>
<shadedPattern>fr.xephi.authme.libs.com.mysql</shadedPattern>
</relocation>
</relocations>
<filters>

View File

@ -104,8 +104,8 @@ public class MySQL extends AbstractSqlDataSource {
try {
Class.forName(this.className);
} catch (ClassNotFoundException e) {
logger.info("Driver class '" + this.className + "' not found! Falling back to legacy MySQL driver (com.mysql.jdbc.Driver)");
this.className = "com.mysql.jdbc.Driver";
this.className = DatabaseSettings.MYSQL_DRIVER_CLASS_NAME.getDefaultValue();
logger.info("Driver class '" + this.className + "' not found! Falling back to the built-in MySQL driver (" + this.className + ")");
}
this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);

View File

@ -65,8 +65,9 @@ public class SettingsMigrationService extends PlainMigrationService {
configurationData.setValue(ALLOWED_NICKNAME_CHARACTERS, "[a-zA-Z0-9_]*");
changes = true;
}
if ("com.mysql.jdbc.Driver".equals(reader.getString(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME.getPath()))) {
configurationData.setValue(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME, "com.mysql.cj.jdbc.Driver");
String driverClass = reader.getString(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME.getPath());
if ("com.mysql.jdbc.Driver".equals(driverClass) || "com.mysql.cj.jdbc.Driver".equals(driverClass)) {
configurationData.setValue(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME, DatabaseSettings.MYSQL_DRIVER_CLASS_NAME.getDefaultValue());
changes = true;
}

View File

@ -47,10 +47,10 @@ public final class DatabaseSettings implements SettingsHolder {
@Comment({"Driver Name of the MySQL database.",
"Built-in drivers:",
" MySQL: 'com.mysql.cj.jdbc.Driver'",
" MariaDB: 'org.mariadb.jdbc.Driver'"})
" MySQL: 'fr.xephi.authme.libs.com.mysql.cj.jdbc.Driver'",
" MariaDB: 'fr.xephi.authme.libs.org.mariadb.jdbc.Driver'"})
public static final Property<String> MYSQL_DRIVER_CLASS_NAME =
newProperty("DataSource.mySQLDriverClassName", "com.mysql.cj.jdbc.Driver");
newProperty("DataSource.mySQLDriverClassName", "fr.xephi.authme.libs.com.mysql.cj.jdbc.Driver");
@Comment("Database Name, use with converters or as SQLITE database name")
public static final Property<String> MYSQL_DATABASE =