Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Convert Gradle buildscripts of Android plugin templates from Groovy to Kotlin #166312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bartekpacia
Copy link
Member

Resolve #142685

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 1, 2025
@bartekpacia bartekpacia force-pushed the bartekpacia/task/android_plugin_templates_use_gradle_kotlin_dsl branch 2 times, most recently from c15e48e to 89657a7 Compare April 22, 2025 22:10
@bartekpacia bartekpacia force-pushed the bartekpacia/task/android_plugin_templates_use_gradle_kotlin_dsl branch from 89657a7 to bcd10f1 Compare April 22, 2025 22:17
@bartekpacia bartekpacia marked this pull request as ready for review April 22, 2025 22:19
@bartekpacia
Copy link
Member Author

failures seem to be caused by:
gradle/kotlin-dsl-samples#163 (comment)

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@bkonyi
Copy link
Contributor

bkonyi commented May 26, 2025

Hi @bartekpacia is this something you're still pursuing?

@bartekpacia
Copy link
Member Author

Hey! Yes, I gotta fix the CI failures, didnt have much time recently

@helomri
Copy link

helomri commented Jun 21, 2025

Hi,

Just letting you know there are some changes required for this to work: (changes need to be made on all versions)

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11
}
sourceSets {
main.java.srcDirs += "src/main/kotlin"
test.java.srcDirs += "src/test/kotlin"
}
needs to be replaced with:

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
    }

    sourceSets {
        getByName("main").java.srcDir("src/main/kotlin")
        getByName("test").java.srcDir("src/test/kotlin")
    }

testOptions {
unitTests.all {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed", "standardOut", "standardError")
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
}
needs to be replaced with:

    testOptions {
        unitTests.all {
            it.useJUnitPlatform()

            it.testLogging {
                events("passed", "skipped", "failed", "standardOut", "standardError")
                it.outputs.upToDateWhen { false }
                showStandardStreams = true
            }
        }
    }

I can't get to import on Gradle sync com.android.library without adding the following to settings.gradle.kts:

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

and replacing

apply(plugin = "com.android.library")
apply(plugin = "kotlin-android")
with:

plugins {
    id("com.android.library") version "{{agpVersion}}"
    id("org.jetbrains.kotlin.android") version "{{kotlinVersion}}"
}

This one could be an issue on my part, I'm not sure (Gradle doesn't want to fetch the plugins from Maven repos if they are not defined in pluginManagement in settings.gradle.kts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change build language of Android plugin template from Groovy to Kotlin
3 participants