const javaxCacheApi = {
    groupId: 'javax.cache',
    artifactId: 'cache-api',
};
const hibernateJCache = (javaVersion) => {
    return {
        groupId: 'org.hibernate' + (javaVersion !== '8' ? '.orm' : ''),
        artifactId: 'hibernate-jcache',
        version: '${hibernate.version}',
    };
};
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',
                    },
                ],
            },
            hibernateCache: {
                dependencies: ormTool === 'hibernate' ? [hibernateJCache(javaVersion)] : [],
            },
        },
        ehcache: {
            base: {
                dependencies: [
                    javaxCacheApi,
                    ehcache,
                ],
            },
            hibernateCache: {
                dependencies: ormTool === 'hibernate' ? [hibernateJCache(javaVersion)] : [],
            },
        },
        caffeine: {
            base: {
                properties: [
                    {
                        property: 'typesafe.version',
                        value: javaDependencies.typesafe,
                    },
                ],
                dependencies: [
                    javaxCacheApi,
                    {
                        groupId: 'com.github.ben-manes.caffeine',
                        artifactId: 'jcache',
                    },
                    {
                        groupId: 'com.github.ben-manes.caffeine',
                        artifactId: 'caffeine',
                    },
                    {
                        groupId: 'com.typesafe',
                        artifactId: 'config',
                        version: '${typesafe.version}',
                    },
                ],
            },
            hibernateCache: {
                dependencies: ormTool === 'hibernate' ? [hibernateJCache(javaVersion)] : [],
            },
        },
        hazelcast: {
            base: {
                properties: [
                    {
                        property: 'hazelcast-spring.version',
                        value: javaDependencies['hazelcast-spring'],
                    },
                ],
                dependencies: [
                    javaxCacheApi,
                    {
                        groupId: 'com.hazelcast',
                        artifactId: 'hazelcast-spring',
                        version: '${hazelcast-spring.version}',
                    },
                ],
            },
            hibernateCache: {
                properties: [
                    {
                        property: 'hazelcast-hibernate53.version',
                        value: javaDependencies['hazelcast-hibernate53'],
                    },
                ],
                dependencies: [
                    {
                        groupId: 'com.hazelcast',
                        artifactId: 'hazelcast-hibernate53',
                        version: '${hazelcast-hibernate53.version}',
                    },
                ],
            },
        },
        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-jakarta',
                    },
                    {
                        groupId: 'org.infinispan',
                        artifactId: 'infinispan-core-jakarta',
                    },
                    {
                        groupId: 'org.infinispan',
                        artifactId: 'infinispan-component-annotations',
                        scope: 'compile',
                    },
                ],
            },
        },
        memcached: {
            base: {
                dependencies: [
                    javaxCacheApi,
                    {
                        groupId: 'com.google.code.simple-spring-memcached',
                        artifactId: 'spring-cache',
                    },
                    {
                        groupId: 'com.google.code.simple-spring-memcached',
                        artifactId: 'xmemcached-provider',
                    },
                    {
                        groupId: 'com.googlecode.xmemcached',
                        artifactId: 'xmemcached',
                    },
                ],
            },
        },
    };
    return dependenciesForCache[cacheProvider];
};
