/*
 *  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-gradle-plugin'
    id 'maven-publish'
    id 'org.apache.grails.buildsrc.publish'
    id 'org.apache.grails.buildsrc.sbom'
}

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

ext {
    pomTitle = 'Grails Gradle Plugins'
    pomDescription = 'Various bundled Gradle plugins for Grails'
    pomMavenPublicationName = 'pluginMaven'
}

dependencies {
    implementation platform(project(':grails-gradle-bom'))

    // compile grails-gradle-plugin with the Groovy version provided by Gradle
    // to ensure build compatibility with Gradle, currently Groovy 3.0.x
    // see: https://docs.gradle.org/current/userguide/compatibility.html#groovy
    compileOnly "org.codehaus.groovy:groovy"

    implementation project(':grails-gradle-common')
    implementation project(':grails-gradle-tasks')

    // spock is leaking from the grails-gradle-bom through grails-gradle-model
    implementation project(':grails-gradle-model'), {
        exclude group: 'org.spockframework'
    }

    implementation "${gradleBomDependencies['grails-publish-plugin']}"
    implementation 'org.springframework.boot:spring-boot-gradle-plugin'
    implementation 'org.springframework.boot:spring-boot-loader-tools'
    implementation 'io.spring.gradle:dependency-management-plugin'
}

gradlePlugin {
    plugins {
        grailsCore {
            displayName = 'Grails Core Gradle Plugin'
            description = 'The main Grails gradle plugin implementation'
            id = 'org.apache.grails.gradle.grails-app'
            implementationClass = 'org.grails.gradle.plugin.core.GrailsGradlePlugin'
        }
        grailsGsp {
            displayName = 'Grails GSP Gradle Plugin'
            description = 'A plugin that adds support for compiling Groovy Server Pages (GSP)'
            id = 'org.apache.grails.gradle.grails-gsp'
            implementationClass = 'org.grails.gradle.plugin.views.gsp.GroovyPagePlugin'
        }
        grailsGson {
            displayName = 'Grails GSON Gradle Plugin'
            description = 'A plugin that adds support for compiling Groovy Json Views (GSON)'
            id = 'org.apache.grails.gradle.grails-gson'
            implementationClass = 'org.grails.gradle.plugin.views.json.GrailsGsonViewsPlugin'
        }
        grailsMarkup {
            displayName = 'Grails Markup Gradle Plugin'
            description = 'A plugin that adds support for compiling Markup Views'
            id = 'org.apache.grails.gradle.grails-markup'
            implementationClass = 'org.grails.gradle.plugin.views.markup.GrailsMarkupViewsPlugin'
        }
        grailsPlugin {
            displayName = 'Grails-Plugin Gradle Plugin'
            description = 'A Gradle plugin for Grails plugins'
            id = 'org.apache.grails.gradle.grails-plugin'
            implementationClass = 'org.grails.gradle.plugin.core.GrailsPluginGradlePlugin'
        }
        grailsProfile {
            displayName = 'Grails Profile Gradle Plugin'
            description = 'A plugin that is capable of compiling a Grails profile into a JAR file for distribution'
            id = 'org.apache.grails.gradle.grails-profile'
            implementationClass = 'org.grails.gradle.plugin.profiles.GrailsProfileGradlePlugin'
        }
        grailsWeb {
            displayName = 'Grails Web Gradle Plugin'
            description = 'Adds web specific extensions'
            id = 'org.apache.grails.gradle.grails-web'
            implementationClass = 'org.grails.gradle.plugin.web.GrailsWebGradlePlugin'
        }
        grailsProfilePublish {
            displayName = 'Grails Profile Publish Plugin'
            description = 'A plugin for publishing profiles'
            id = 'org.apache.grails.gradle.grails-publish-profile'
            implementationClass = 'org.grails.gradle.plugin.profiles.GrailsProfilePublishGradlePlugin'
        }
        grailsExploded {
            displayName = 'Grails Exploded Plugin'
            description = 'A plugin that configures a Grails Plugin so that its classes and resources are exploded when running bootRun from a dependent Application'
            id = 'org.apache.grails.gradle.grails-exploded'
            implementationClass = 'org.grails.gradle.plugin.exploded.GrailsExplodedPlugin'
        }
    }
}

tasks.withType(Copy) {
    configure {
        duplicatesStrategy = DuplicatesStrategy.INCLUDE
    }
}

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/docs-config.gradle')
}
