as DSL 配置

gradle 配置写法

settings.gradle.kts

maven { url = uri("https://maven.aliyun.com/repository/gradle-plugin") }

build.gradle.kts

implementation(libs.permissions)

lib.versions.toml

[versions]
permissions = "18.5"
[libraries]
permissions = { module = "com.github.getActivity:XXPermissions", version.ref = "permissions" }

version 指的是版本号,libraries声明依赖,注意名称驼峰与build.gradle中implementation(libs.permissions),保持一致
lib.versions.toml

plugin ksp

ksp与kapt、annotationProcessor功能一致,项目中没有使用kotlin的直接用annotaionProcessor,kapt kotlin的一些专有属性拿不到,ksp是新出的注解处理器,编译速度快,用来取代kapt。
以kapt "com.github.liujingxing.rxhttp:rxhttp-compiler:3.0.1"为例

[versions]
rx-http-compiler = "3.2.3"
ksp = "1.9.0-1.0.11"
[libraries]
rx-http-compiler = { module = "com.github.liujingxing.rxhttp:rxhttp-compiler", version.ref = "rx-http-compiler" }
[plugins]
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

build.gradle.kts

    ksp(libs.rx.http.compiler)

ps:使用时需要注意ksp和kotlin的版本,否则可能会提示错误
class org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation_Dec
我这里的版本如下

kotlin = "1.9.0"
ksp = "1.9.0-1.0.11"

Fatal Error 文档中根元素前面的标记必须格式正确

注释掉阿里云镜像,只保留gradle-plugin,具体的解释在这里

pluginManagement {
    repositories {
        maven { url = uri("https://maven.aliyun.com/repository/gradle-plugin") }
//        maven { url = uri("https://maven.aliyun.com/repository/public/") }
//        maven { url = uri("https://maven.aliyun.com/repositories/jcenter") }
//        maven { url = uri("https://maven.aliyun.com/repositories/google") }
//        maven { url = uri("https://maven.aliyun.com/repositories/central") }
        maven { url = uri("https://jitpack.io") }
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
  • 10
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值