当前位置: 首页 > news >正文

上海网站建设价wordpress封装小程序

上海网站建设价,wordpress封装小程序,珠海做网站那家好,百度关键词优化查询曾经我们使用config.gradle文件进行版本依赖配置,然后在project的build.gradle.kts中使用如下方式引入: apply(from "./config.gradle") 缺点:在project的module中引用无任何提示,无法跳转到指定引用 一、创建versio…

曾经我们使用config.gradle文件进行版本依赖配置,然后在project的build.gradle.kts中使用如下方式引入:

apply(from = "./config.gradle")

缺点:在project的module中引用无任何提示,无法跳转到指定引用

一、创建version catalog文件

创建catalog文件步骤如上图,名称使用默认名libs(也可以修改名称,在settings中引入的时候使用修改的文件明就行)创建libs.version.toml

此文件生成之后在如下目录,此时文件不用在settings.gradle中进行配置,如果文件名不是libs还是需要自行引入。

建议:文件名仍然使用libs,但是将文件libs.versions.toml移动到Project的根目录,然后在settings.gradle中显示引入。

版本目录TOML文件格式,TOML 文件由 4 个主要部分组成

  1. [versions] 用于声明可以被依赖项引用的版本
  2. [libraries] 用于声明引用的依赖包的别名
  3. [bundles] 用于声明依赖包,可以将步骤2中定义的依赖包统一引入
  4. [plugins] 用于声明插件

举例:

[versions]
groovy = "3.0.5"
ksp = "1.9.21-1.0.16"[libraries]
groovy-core = { module = "org.codehaus.groovy:groovy", version.ref = "groovy" }
groovy-json = { module = "org.codehaus.groovy:groovy-json", version.ref = "groovy" }
groovy-nio = { module = "org.codehaus.groovy:groovy-nio", version.ref = "groovy" }[bundles]
groovy = ["groovy-core", "groovy-json", "groovy-nio"][plugins]
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

例如在app.module中可以单独引入 libraties中的依赖包或者引入bundles中的一组依赖包


dependencies {implementation(libs.bundles.groovy)// 或者分开引入implementation(libs.groovy.core)implementation(libs.groovy.json)implementation(libs.groovy.nio)}

二、Settings.gradle中引入libs.versions.toml

dependencyResolutionManagement {......// 引入CatalogsversionCatalogs {create("libs") {from(files("./libs.versions.toml"))}}
}

三、在project build.gradle和module的build.gradle都能开始使用

libs.versions.toml文件

[versions]
compileSdk = "34"
minSdk = "24"
targetSdk = "34"
versionCode = "1"
versionName = "1.0"
# 插件
application = "8.3.2"
kotlin = "1.9.10"
ksp = "1.9.21-1.0.16"
# 三方库
core-ktx = "1.10.1"
appcompat = "1.6.1"
material = "1.10.0"
constraintlayout = "2.1.4"
junit = "4.13.2"
android-junit = "1.1.5"
espresso-core = "3.5.1"
room = "2.5.1"
moshi = "1.15.1"[libraries]
core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" }
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
material = { module = "com.google.android.material:material", version.ref = "material" }
constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" }
junit = { module = "junit:junit", version.ref = "junit" }
android-junit = { module = "androidx.test.ext:junit", version.ref = "android-junit" }
espresso-core  = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso-core" }
room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
room-testing = { module = "androidx.room:room-testing", version.ref = "room" }
moshi = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi" }[bundles]
room = ["room-runtime"][plugins]
application = { id = "com.android.application", version.ref = "application" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

3.1 引用插件

Project build.gradle

plugins {alias(libs.plugins.application) apply falsealias(libs.plugins.kotlin) apply falsealias(libs.plugins.ksp) apply false
}

App module build.gradle

plugins {alias(libs.plugins.application)alias(libs.plugins.kotlin)alias(libs.plugins.ksp)
}

3.2 引入版本

android {compileSdk = libs.versions.compileSdk.get().toInt()defaultConfig {applicationId = "xxxxxx"minSdk = libs.versions.minSdk.get().toInt()targetSdk = libs.versions.targetSdk.get().toInt()versionCode = libs.versions.versionCode.get().toInt()versionName = libs.versions.versionName.get()}}

3.3 引入依赖

dependencies {implementation(libs.core.ktx)implementation(libs.appcompat)implementation(libs.material)implementation(libs.constraintlayout)testImplementation(libs.junit)androidTestImplementation(libs.android.junit)androidTestImplementation(libs.espresso.core)// Roomimplementation(libs.room.runtime)annotationProcessor(libs.room.compiler)// To use Kotlin Symbol Processing (KSP)ksp(libs.room.compiler)// optional - Kotlin Extensions and Coroutines support for Roomimplementation(libs.room.ktx)// 测试数据库testImplementation(libs.room.testing)// moshiksp(libs.moshi)
}

代码:PractiseProject

参考

Android中国官网:将 build 迁移到版本目录

android官网:将 build 迁移到版本目录

Sharing dependency versions between projects

Using Plugins

http://www.yayakq.cn/news/661051/

相关文章:

  • 怎样进入网站的后台企业建网站的 程序
  • 免费个人简历制作网站什么软件做美食视频网站好
  • 湖南湘信建设工程有限公司网站wordpress前台弹窗
  • 服务器上如何做网站哪个网站推荐做挖机事的
  • 推荐6个国外自媒体平台南昌seo网站设计
  • 山东省建设部继续教育网站qq的seo综合查询
  • 软件开发怎么样深圳网站建设zhaoseo
  • 智能网站建设商家wordpress小工具有哪些
  • 濮阳建设企业网站公司怎么用pf做网站
  • 高明做网站cms影视源码采集
  • wordpress500错误网站优化新闻
  • 做视频教学网站wordpress编辑模板
  • 网站排行榜泸州市建设厅官方网站
  • 陵水网站建设公司怎么看网站是不是php语言做的
  • 青岛正规品牌网站制作策划湖南城市建设网站
  • 怎么用indesign做网站设计网络推广平台代理
  • 网站设计网站开发优化桌面软件开发工具
  • 中国建设银行泗水支行的网站怎么做用户调研网站
  • 如何建立自己的网站去推广南通市城乡和住房建设局网站
  • 装潢公司网站源码php浙江制做网站的公司
  • 杭州网站建设索q.479185700住房和城乡建设部网站资质查询
  • 江苏扬州工程建设信息网站网站后台免费模板
  • 织梦网站模板下载wordpress模板淘宝客模板下载
  • 昆明做网站设计网站没有做的关键词有排名
  • html网站建设代码接网站建设单子注意事项
  • 西昌有做网站的公司吗我想做电商怎么做
  • 建筑资源网站网站制作动
  • 珠海十大网站建设公司杭州建设网 执法人员名单
  • 建网站做站长wordpress图片小工具
  • 丽水做网站企业东莞神马seo推广排名