const javaxCacheApi = {
    groupId: 'javax.cache',
    artifactId: 'cache-api',
};
const hibernateJCache = javaVersion => {
    return {
        groupId: `org.hibernate${javaVersion !== '8' ? '.orm' : ''}`,
        artifactId: 'hibernate-jcache',
    };
};
export const getCacheProviderMavenDefinition = (cacheProvider, javaDependencies, javaVersion, ormTool) => {
    const ehcache = {
        groupId: 'org.ehcache',
        artifactId: 'ehcache',
    };
    if (javaVersion !== '8') {
        ehcache.classifier = 'jakarta';
    }
    const dependenciesForCache = {
        redis: {
            base: {
                dependencies: [
                    {
                        groupId: 'org.testcontainers',
                        artifactId: 'junit-jupiter',
                        scope: 'test',
                    },
                    {
                        groupId: 'org.testcontainers',
                        artifactId: 'testcontainers',
                        scope: 'test',
                    },
                    {
                        groupId: 'org.redisson',
                        artifactId: 'redisson',
                        version: javaDependencies.redisson,
                    },
                ],
            },
            hibernateCache: {
                dependencies: ormTool === 'hibernate' ? [hibernateJCache(javaVersion)] : [],
            },
        },
        ehcache: {
            base: {
                dependencies: [
                    javaxCacheApi,
                    ehcache,
                ],
            },
            hibernateCache: {
                dependencies: ormTool === 'hibernate' ? [hibernateJCache(javaVersion)] : [],
            },
        },
        caffeine: {
            base: {
                dependencies: [
                    javaxCacheApi,
                    {
                        groupId: 'com.github.ben-manes.caffeine',
                        artifactId: 'jcache',
                    },
                    {
                        groupId: 'com.github.ben-manes.caffeine',
                        artifactId: 'caffeine',
                    },
                    {
                        groupId: 'com.typesafe',
                        artifactId: 'config',
                        version: javaDependencies.typesafe,
                    },
                ],
            },
            hibernateCache: {
                dependencies: ormTool === 'hibernate' ? [hibernateJCache(javaVersion)] : [],
            },
        },
        hazelcast: {
            base: {
                dependencies: [
                    javaxCacheApi,
                    {
                        groupId: 'com.hazelcast',
                        artifactId: 'hazelcast-spring',
                        version: javaDependencies['hazelcast-spring'],
                    },
                ],
            },
            hibernateCache: {
                dependencies: [
                    {
                        groupId: 'com.hazelcast',
                        artifactId: 'hazelcast-hibernate53',
                        version: javaDependencies['hazelcast-hibernate53'],
                    },
                ],
            },
        },
        infinispan: {
            base: {
                dependencies: [
                    javaxCacheApi,
                    {
                        groupId: 'org.infinispan',
                        artifactId: 'infinispan-hibernate-cache-v62',
                    },
                    {
                        groupId: 'org.infinispan',
                        artifactId: 'infinispan-spring-boot3-starter-embedded',
                    },
                    {
                        groupId: 'org.infinispan',
                        artifactId: 'infinispan-commons',
                    },
                    {
                        groupId: 'org.infinispan',
                        artifactId: 'infinispan-core',
                    },
                    {
                        groupId: 'org.infinispan',
                        artifactId: 'infinispan-component-annotations',
                        scope: 'compile',
                    },
                ],
            },
        },
        memcached: {
            base: {
                versions: [{ name: 'xmemcached-provider', version: javaDependencies['xmemcached-provider'] }],
                dependencies: [
                    javaxCacheApi,
                    {
                        groupId: 'com.google.code.simple-spring-memcached',
                        artifactId: 'spring-cache',
                        versionRef: 'xmemcached-provider',
                    },
                    {
                        groupId: 'com.google.code.simple-spring-memcached',
                        artifactId: 'xmemcached-provider',
                        versionRef: 'xmemcached-provider',
                    },
                    {
                        groupId: 'com.googlecode.xmemcached',
                        artifactId: 'xmemcached',
                        version: javaDependencies.xmemcached,
                    },
                ],
            },
        },
    };
    return dependenciesForCache[cacheProvider];
};
