buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
        classpath "com.avast.gradle:gradle-docker-compose-plugin:$dockerComposePluginVersion"
    }
}

apply plugin: 'docker-compose'

subprojects {
    apply plugin: 'java'
    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    repositories {
        mavenCentral()
        eventuateMavenRepoUrl.split(',').each { repoUrl -> maven { url repoUrl } }
    }

    dependencies {
      implementation(platform("io.eventuate.platform:eventuate-platform-dependencies:$eventuatePlatformVersion"))
      implementation(platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion"))
      constraints {
          implementation "org.springdoc:springdoc-openapi-ui:$springDocOpenApiUiVersion"
      }
    }

}

dockerCompose {
    environment.put "EVENTUATE_COMMON_VERSION", eventuateCommonImageVersion
    environment.put "EVENTUATE_MESSAGING_KAFKA_IMAGE_VERSION", eventuateMessagingKafkaImageVersion
    environment.put "EVENTUATE_CDC_VERSION", eventuateCdcImageVersion
    environment.put "EVENTUATE_MESSAGING_KAFKA_IMAGE_VERSION", eventuateMessagingKafkaImageVersion
    environment.put "EVENTUATE_JAVA_BASE_IMAGE_VERSION", eventuateExamplesBaseImageVersion
    projectName = null
    noRecreate = Boolean.valueOf(dockerComposeNoCreate)

    mysqlbinlog {
        projectName = null
        useComposeFiles = ["docker-compose-eventuate-local-mysql.yml"]
    }

    mysqlbinlogcdc {
        projectName = null
        useComposeFiles = ["docker-compose-eventuate-local-mysql.yml"]
        startedServices = ["cdcservice"]
    }

    postgrespolling {
        projectName = null
        useComposeFiles = ["docker-compose-eventuate-local-postgres-polling.yml"]
    }

    postgrespollingcdc {
        projectName = null
        useComposeFiles = ["docker-compose-eventuate-local-postgres-polling.yml"]
        startedServices = ["cdcservice"]
    }

    postgreswal {
        projectName = null
        useComposeFiles = ["docker-compose-eventuate-local-postgres-wal.yml"]
    }

    postgreswalcdc {
        projectName = null
        useComposeFiles = ["docker-compose-eventuate-local-postgres-wal.yml"]
        startedServices = ["cdcservice"]
    }
}
