/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *    https://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */

plugins {
    id 'groovy'
    id 'java-library'
    id 'org.apache.grails.buildsrc.publish'
    id 'org.apache.grails.buildsrc.sbom'
}

version = projectVersion
group = 'org.apache.grails'

ext {
    gormApiDocs = true
    pomTitle = 'GORM for MongoDB'
    pomDescription = 'Provides a GORM Object Mapping implementations for the MongoDB Document Database'
    pomDevelopers =  [
            'graemerocher': 'Graeme Rocher',
            'jeffscottbrown': 'Jeff Brown',
            'burtbeckwith': 'Burt Beckwith'
    ]
}

dependencies {

    implementation platform(project(':grails-bom'))

    api project(':grails-data-mongodb-core'), {
        // api: MongoDatastore
        if (excludeUnusedTransDeps) {
            // API dependencies in grails-datastore-gorm-mongodb
            exclude group: 'org.mongodb', module: 'mongodb-driver-sync'
            exclude group: 'org.apache.grails.data', module: 'grails-datamapping-validation'
            //exclude group: 'org.apache.grails.data', module: 'grails-datastore-gorm' // GormEntity needed downstream
            //exclude group: 'org.apache.grails.data', module: 'grails-data-mongodb-bson' //  Needed at runtime downstream (BsonPersistentEntityCodec)
        }
    }
    api 'org.mongodb:mongodb-driver-core', {
        // api: MongoClientSettings
    }
    api 'org.mongodb:mongodb-driver-sync', {
        // api: MongoClient
        // impl: MongoClients
    }
    api 'org.springframework:spring-beans', {
        // api: BeansException
        // impl: @Autowired(runtime), ConfigurableListableBeanFactory
    }
    api 'org.springframework:spring-context', {
        // api: ApplicationContext, ApplicationContextAware, ConfigurableApplicationContext
        // impl: @Bean(runtime), @Configuration(runtime)
    }
    api 'org.springframework:spring-tx', {
        // api: PlatformTransactionManager
    }

    implementation 'org.apache.groovy:groovy', {
        // impl: Needed for Java Spring Boot apps
        // comp: @CompileStatic(source)
    }
    // Provided by grails-datamapping-core
//    implementation project(':grails-datastore-core'), {
//        // impl: Service
//    }
    implementation project(':grails-datamapping-core'), {
        // impl: ConfigurableApplicationContextEventPublisher
    }
    implementation 'org.springframework:spring-core', {
        // impl: ConfigurableEnvironment
    }
    implementation 'org.springframework.boot:spring-boot-autoconfigure', {
        // impl: AutoConfigurationPackages, @AutoConfigureAfter(runtime), @ConditionalOnMissingBean(runtime),
        //       MongoAutoConfiguration, MongoProperties
    }

    compileOnlyApi 'jakarta.persistence:jakarta.persistence-api', {
        // compApi: Entity needed for GlobalJpaEntityTransform downstream
    }

    compileOnly 'org.slf4j:slf4j-api', {
        // "optional" compile dependency in mongodb-driver-core
    }

    testImplementation 'org.spockframework:spock-core'

    testRuntimeOnly 'org.slf4j:slf4j-nop'
    testImplementation project(':grails-testing-support-mongodb')
}

apply {
    from rootProject.layout.projectDirectory.file('gradle/java-config.gradle')
    from rootProject.layout.projectDirectory.file('gradle/code-style-config.gradle')
    from rootProject.layout.projectDirectory.file('gradle/mongodb-test-config.gradle')
    from rootProject.layout.projectDirectory.file('gradle/docs-config.gradle')
}