<commit_before>@file:Suppress("unused")

package reactivecircus.flowbinding

import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.LibraryPlugin
import com.android.build.gradle.TestedExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.kotlin.dsl.getByType

/**
 * A plugin that provides baseline gradle configurations for all projects, including:
 * - root project
 * - Android Application projects
 * - Android Library projects
 * - Kotlin JVM projects
 * - Java JVM projects
 *
 * Apply this plugin to the build.gradle.kts file in all projects:
 * ```
 * plugins {
 *     id 'flowbinding-plugin'
 * }
 * ```
 */
class FlowBindingPlugin : Plugin<Project> {
    override fun apply(project: Project) {
        project.afterEvaluate {
            configureForAllProjects()

            if (isRoot) {
                configureRootProject()
            }

            plugins.all {
                when (this) {
                    is JavaPlugin,
                    is JavaLibraryPlugin -> {
                        project.convention.getPlugin(JavaPluginConvention::class.java).apply {
                            sourceCompatibility = JavaVersion.VERSION_1_8
                            targetCompatibility = JavaVersion.VERSION_1_8
                        }
                    }
                    is LibraryPlugin -> {
                        extensions.getByType<TestedExtension>().configureCommonAndroidOptions(project.gradle.startParameter)
                        extensions.getByType<LibraryExtension>().configureAndroidLibraryOptions(project)
                    }
                    is AppPlugin -> {
                        extensions.getByType<TestedExtension>().configureCommonAndroidOptions(project.gradle.startParameter)
                    }
                }
            }
        }
    }
}

val Project.isRoot get() = this == this.rootProject<commit_msg>Move plugin configurations out of afterEvaluate to avoid applying plugins in specific order.<commit_after>@file:Suppress("unused")

package reactivecircus.flowbinding

import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.LibraryPlugin
import com.android.build.gradle.TestedExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.kotlin.dsl.getByType

/**
 * A plugin that provides baseline gradle configurations for all projects, including:
 * - root project
 * - Android Application projects
 * - Android Library projects
 * - Kotlin JVM projects
 * - Java JVM projects
 *
 * Apply this plugin to the build.gradle.kts file in all projects:
 * ```
 * plugins {
 *     id 'flowbinding-plugin'
 * }
 * ```
 */
class FlowBindingPlugin : Plugin<Project> {
    override fun apply(project: Project) {
        project.configureForAllProjects()

        if (project.isRoot) {
            project.configureRootProject()
        }

        project.plugins.all {
            when (this) {
                is JavaPlugin,
                is JavaLibraryPlugin -> {
                    project.convention.getPlugin(JavaPluginConvention::class.java).apply {
                        sourceCompatibility = JavaVersion.VERSION_1_8
                        targetCompatibility = JavaVersion.VERSION_1_8
                    }
                }
                is LibraryPlugin -> {
                    project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions(project.gradle.startParameter)
                    project.extensions.getByType<LibraryExtension>().configureAndroidLibraryOptions(project)
                }
                is AppPlugin -> {
                    project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions(project.gradle.startParameter)
                }
            }
        }
    }
}

val Project.isRoot get() = this == this.rootProject
{'fraction_non_alphanumeric': 0.0847457627118644, 'fraction_numerical': 0.0018574413745066172, 'mean_word_length': 2.2960979342004593, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '534841', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1041, 'n_words': 208}