const testcontainerFileForDB = {
    mariadb: 'MariadbTestContainer.java',
    mssql: 'MsSqlTestContainer.java',
    mysql: 'MysqlTestContainer.java',
    postgresql: 'PostgreSqlTestContainer.java',
};
const databaseArtifactForDB = {
    mariadb: {
        jdbc: { groupId: 'org.mariadb.jdbc', artifactId: 'mariadb-java-client' },
        r2dbc: { groupId: 'io.asyncer', artifactId: 'r2dbc-mysql' },
    },
    mssql: {
        jdbc: { groupId: 'com.microsoft.sqlserver', artifactId: 'mssql-jdbc' },
        r2dbc: { groupId: 'io.r2dbc', artifactId: 'r2dbc-mssql' },
    },
    mysql: {
        jdbc: { groupId: 'com.mysql', artifactId: 'mysql-connector-j' },
        r2dbc: { groupId: 'io.asyncer', artifactId: 'r2dbc-mysql' },
    },
    postgresql: {
        jdbc: { groupId: 'org.postgresql', artifactId: 'postgresql' },
        r2dbc: { groupId: 'org.postgresql', artifactId: 'r2dbc-postgresql' },
    },
};
export const getDatabaseDriverForDatabase = (databaseType) => databaseArtifactForDB[databaseType];
export const getCommonMavenDefinition = ({ javaDependencies }) => ({
    properties: [
        { property: 'jaxb-runtime.version', value: javaDependencies['jaxb-runtime'] },
        { property: 'validation-api.version', value: javaDependencies['validation-api'] },
    ],
    dependencies: [
        { groupId: 'com.zaxxer', artifactId: 'HikariCP' },
        { groupId: 'com.fasterxml.jackson.module', artifactId: 'jackson-module-jaxb-annotations' },
        { groupId: 'org.testcontainers', artifactId: 'jdbc', scope: 'test' },
    ],
    annotationProcessors: [
        { groupId: 'org.glassfish.jaxb', artifactId: 'jaxb-runtime', version: '${jaxb-runtime.version}' },
    ],
});
export const getReactiveMavenDefinition = ({ javaDependencies }) => ({
    properties: [{ property: 'commons-beanutils.version', value: javaDependencies['commons-beanutils'] }],
    dependencies: [
        { groupId: 'org.springframework.boot', artifactId: 'spring-boot-starter-data-r2dbc' },
        { groupId: 'commons-beanutils', artifactId: 'commons-beanutils', version: '${commons-beanutils.version}' },
        { groupId: 'jakarta.persistence', artifactId: 'jakarta.persistence-api' },
    ],
});
export const getImperativeMavenDefinition = ({ javaDependencies }, javaVersion) => ({
    properties: [{ property: 'hibernate.version', value: javaDependencies.hibernate }],
    dependencies: [
        { groupId: 'org.springframework.boot', artifactId: 'spring-boot-starter-data-jpa' },
        { groupId: 'com.fasterxml.jackson.datatype', artifactId: `jackson-datatype-hibernate${javaVersion !== '8' ? '6' : '5'}` },
        { groupId: 'org.hibernate.orm', artifactId: 'hibernate-core', version: '${hibernate.version}' },
        { groupId: 'org.hibernate.orm', artifactId: 'hibernate-jpamodelgen', scope: 'provided' },
        { groupId: 'org.hibernate.validator', artifactId: 'hibernate-validator' },
        { groupId: 'org.springframework.security', artifactId: 'spring-security-data' },
        { inProfile: 'IDE', groupId: 'org.hibernate.orm', artifactId: 'hibernate-jpamodelgen' },
    ],
    annotationProcessors: [
        { groupId: 'org.hibernate.orm', artifactId: 'hibernate-jpamodelgen', version: '${hibernate.version}' },
    ],
});
export const getImperativeMavenDefinitionMybatis = ({ javaDependencies }, javaVersion) => ({
    dependencies: [
        { groupId: 'com.fasterxml.jackson.datatype', artifactId: `jackson-datatype-hibernate5${javaVersion !== '8' ? '-jakarta' : ''}` },
        { groupId: 'org.hibernate.validator', artifactId: 'hibernate-validator' },
        { groupId: 'org.springframework.security', artifactId: 'spring-security-data' },
    ],
});
export const getH2MavenDefinition = ({ prodDatabaseType, packageFolder, }) => {
    const testcontainerFile = testcontainerFileForDB[prodDatabaseType];
    const excludeContainerPlugin = testcontainerFile
        ? [
            {
                inProfile: 'dev',
                groupId: 'org.apache.maven.plugins',
                artifactId: 'maven-compiler-plugin',
                additionalContent: `
<configuration>
  <testExcludes>
    <testExclude>${packageFolder}config/${testcontainerFile}</testExclude>
  </testExcludes>
</configuration>
`,
            },
        ]
        : [];
    return {
        jdbc: {
            dependencies: [{ inProfile: 'dev', groupId: 'com.h2database', artifactId: 'h2' }],
            plugins: excludeContainerPlugin,
        },
        r2dbc: {
            dependencies: [{ inProfile: 'dev', groupId: 'io.r2dbc', artifactId: 'r2dbc-h2' }],
        },
    };
};
export const getDatabaseTypeMavenDefinition = (databaseType, { inProfile }) => {
    const dependenciesForType = {
        mariadb: {
            jdbc: {
                dependencies: [
                    { inProfile, ...databaseArtifactForDB.mariadb.jdbc },
                    { groupId: 'org.testcontainers', artifactId: 'mariadb', scope: 'test' },
                ],
            },
            r2dbc: {
                dependencies: [{ inProfile, ...databaseArtifactForDB.mariadb.r2dbc }],
            },
        },
        mssql: {
            jdbc: {
                dependencies: [
                    { inProfile, ...databaseArtifactForDB.mssql.jdbc },
                    { groupId: 'org.testcontainers', artifactId: 'mssqlserver', scope: 'test' },
                ],
            },
            r2dbc: {
                dependencies: [{ inProfile, ...databaseArtifactForDB.mssql.r2dbc }],
            },
        },
        mysql: {
            jdbc: {
                dependencies: [
                    { inProfile, ...databaseArtifactForDB.mysql.jdbc },
                    { groupId: 'org.testcontainers', artifactId: 'mysql', scope: 'test' },
                ],
            },
            r2dbc: {
                dependencies: [{ inProfile, ...databaseArtifactForDB.mysql.r2dbc }],
            },
        },
        oracle: {
            jdbc: {
                dependencies: [
                    { inProfile, groupId: 'com.oracle.database.jdbc', artifactId: 'ojdbc8' },
                    { groupId: 'org.testcontainers', artifactId: 'oracle-xe', scope: 'test' },
                ],
            },
            r2dbc: {},
        },
        postgresql: {
            jdbc: {
                dependencies: [
                    { inProfile, ...databaseArtifactForDB.postgresql.jdbc },
                    { groupId: 'org.testcontainers', artifactId: 'postgresql', scope: 'test' },
                ],
            },
            r2dbc: {
                dependencies: [{ inProfile, ...databaseArtifactForDB.postgresql.r2dbc }],
            },
        },
    };
    return dependenciesForType[databaseType];
};
