question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SqlDelight Plugin not detected if more than one plugin defined in Gradle dependency classpath

See original GitHub issue

When trying to set up multi-module support where ModuleA depends on ModuleB, if ModuleA also happens to apply another Gradle Plugin, such as the Protobuf Gradle Plugin, then the Gradle configuration will complain that ModelA:

Cannot depend on a module with no sqldelight plugin.

Example:

ModuleA's build.gradle snippet:

buildscript {
    dependencies {
        classpath libs.protobufGradlePlugin <-- Causes Gradle configuration to fail
        classpath libs.sqldelight.gradlePlugin
    }
}

apply from: configs.kotlin.androidLibrary
apply plugin: 'com.squareup.sqldelight'

sqldelight {
    Database {
        packageName = "com.example.coredata.data"
        dependency libs.featureData
    }
}

ModuleB's build.gradle snippet:

buildscript {
    dependencies {
        classpath libs.sqldelight.gradlePlugin
    }
}

apply from: configs.kotlin.androidLibrary
apply plugin: 'com.squareup.sqldelight'

sqldelight {
    Database {
        packageName = "com.example.featuredata.data"
    }
}

If I comment out classpath libs.protobufGradlePlugin, the Gradle configuration succeeds.

I have attached a repro Android project. If you go to coredata/build.gradle, you can uncomment the classpath definition that has been commented out in order to repro the issue. Thank you!

Repro: SqlDelightMultiModule.zip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
AlecStrongcommented, Apr 21, 2019

thats super weird. Thanks for the repro project, will take a look at this

0reactions
AlecStrongcommented, Oct 8, 2020

the issue here is having all the separate buildscript classpaths, that’s confusing some part of gradle. If I consolidate the classpath into the root build.gradle its fine:

buildscript {
    ...
    dependencies {
        classpath libs.agp
        classpath libs.kotlin.gradlePlugin
        classpath libs.protobufGradlePlugin
        classpath libs.sqldelight.gradlePlugin
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not resolve com.squareup.sqldelight:runtime:1.1.3
I was solved this problem. First: Apply sqldelight plugin right to all project: apply plugin: 'com.squareup.sqldelight' sqldelight ...
Read more >
Build Sometimes Fails if Kotlin Plugin Classpath Dependency ...
He found that if he moved the kotlin-gradle-plugin to the bottom of the dependencies block it works, and moving it back to the...
Read more >
SQLDelight: Getting Started - Tony Owen - Medium
I wanted to try out SQLDelight, a library (and IntelliJ plugin) that generates Java models based ... classpath 'com.squareup.sqldelight:gradle-plugin:0.5.1'
Read more >
How `buildscript` relates to `pluginManagement` - Help/Discuss
hi I'm looking for help in understanding how buildscript relates to pluginManagement in terms of declaring plugins and their versions.
Read more >
Getting started on Kotlin JS with SQLDelight
buildscript { repositories { google() mavenCentral() } dependencies { classpath 'com.squareup.sqldelight:gradle-plugin:1.5.3' } } apply plugin: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found