I want to create a precompiled build script plugin...
# gradle
f
I want to create a precompiled build script plugin for an Android app but I'm getting an error in the plug-in,
android
is not defined. Looks like I'm missing some dependencies possibly, does anybody have an example to follow or some hints on what the issue might be? Details in thread.
in
buildSrc
,
build.gradle.kts
Copy code
plugins {
    `kotlin-dsl`
    `kotlin-dsl-precompiled-script-plugins`
}

repositories {
    mavenCentral()
    google()
}
in
buildSrc/src/main/kotlin/base-android-library.gradle.kts
Copy code
plugins {
    id("com.android.library")
    id("kotlin-android")
}

android {
    compileSdk = Versions.compileSdkVersion
    compileSdkPreview = "Tiramisu"

    defaultConfig {
        minSdk = Versions.minSdkVersion
        targetSdk = Versions.targetSdkVersion
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles("<http://consumer-rules.pro|consumer-rules.pro>")
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "<http://proguard-rules.pro|proguard-rules.pro>"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = Config.Compiler.jvmTarget
        freeCompilerArgs = freeCompilerArgs + Config.Compiler.freeCompilerArgs
    }
}
t
in
buildSrc/build.gradle.kts
you need to add a common dependency on AGP
f
thanks, I tried this but it doesn't work either
Copy code
plugins {
    `kotlin-dsl`
    `kotlin-dsl-precompiled-script-plugins`
}

repositories {
    mavenCentral()
    google()
}

dependencies {
    classpath("com.android.tools.build:gradle:7.3.0-alpha07")
}
would you mind pointing me in the right direction?
maybe this is what you mean?
Copy code
buildscript {
    repositories {
        mavenCentral()
        google()
    }

    dependencies {
        classpath("com.android.tools.build:gradle:7.3.0-alpha07")
    }
}

plugins {
    `kotlin-dsl`
    `kotlin-dsl-precompiled-script-plugins`
}
but this prints
> Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31 because no repositories
f
thanks! that worked,
Copy code
plugins {
    `kotlin-dsl`
    `kotlin-dsl-precompiled-script-plugins`
}

repositories {
    mavenCentral()
    google()
}

dependencies {
    implementation("com.android.tools.build:gradle:7.3.0-alpha07")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
}
I have a follow-up question, I'll make a separate thread