网站后台编辑器无法显示计算机网络公司

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

网站后台编辑器无法显示,计算机网络公司,用word怎么做网站,app开发公司产业背景资料#xff1a; GitHub - ChenSWD/CopyGradleInAction: 备份《Gradle IN Action》书中的源码#xff0c;添加了部分注释 //github上一个开源项目#xff0c;外加pdf书 Gradle User Manual gradle官网 讲的挺好的博客 Gradle之重新认识Gradle(项目结构、命令行、tas…资料 GitHub - ChenSWD/CopyGradleInAction: 备份《Gradle IN Action》书中的源码添加了部分注释   //github上一个开源项目外加pdf书 Gradle User Manual    gradle官网 讲的挺好的博客 Gradle之重新认识Gradle(项目结构、命令行、task、构建Java项目、包装器)_gradle no-source-CSDN博客 Kotlin DSL 是基于 Kotlin 语言 的一种 领域特定语言DSL用来更方便地在 Gradle 中编写构建脚本。为了让 Kotlin 能够适配 GradleKotlin DSL 对 Gradle 的一些功能做了特定的调整和封装使其能够以更自然、更 Kotlin 风格的方式使用。 goovy DSL是一个意思 所以gradle不是一个脚本而是一个构建工具他是用java写的运行的jvm上所以有gradle和jdkc冲突的情况。Android是ART虚拟机解释的是dex文件 脚本语言Scripting Language是一种用于编写脚本脚本是一系列按照特定顺序执行的命令或指令的计算机编程语言。与编译型语言不同脚本语言的代码不需要事先通过编译生成机器码而是在运行时由解释器逐行解释执行。比如python就是脚本语言不需要编译就可以运行只需要解释器 这里有个gradlew很有用因为这个可以在窗口中运行gradlew脚本  gradlew 和 gradlew.bat 都是 Gradle WrapperGradle 包装器 的一部分它们的作用是让项目可以使用 Gradle 而无需提前在系统中安装 Gradle。两者的主要区别在于 操作系统环境 和 文件格式如下所示 什么是Gradle Wrapper? Gradle Wrapper Basics.   官网地址 Gradle Wrapper 的主要功能 统一 Gradle 版本 Gradle Wrapper 可以确保所有开发者使用项目指定的 Gradle 版本避免版本不一致导致的问题。Wrapper 会根据 gradle/wrapper/gradle-wrapper.properties 中配置的版本自动下载所需的 Gradle。 自动下载 Gradle 如果本地没有所需的 Gradle 版本Wrapper 会自动从官方仓库下载指定版本的 Gradle。下载的 Gradle 存储在本地缓存目录默认在 ~/.gradle/wrapper/dists。 无需手动安装 Gradle 开发者无需手动安装 Gradle只需运行项目中的 Wrapper 脚本即可。 跨平台支持 gradlew 和 gradlew.bat 分别支持类 Unix 和 Windows 系统让项目可以在不同操作系统中无缝构建。 环境依赖 gradlew 依赖于系统的 Shell 环境如 Bash。gradlew.bat 依赖于 Windows 的批处理执行环境如 CMD。 如我在mac环境中执行 ./gradlew -v  —查看当前的gradle版本信息 这里请注意在这里使用的gradle是我们项目的wrap中配置的gradle gradle是由一系列构建任务组成的 我们查看下gradle一共有提供多少任务 在窗口中输入./gradlew -v 可以看到有很多任务

Android tasks

androidDependencies - Displays the Android dependencies of the project. signingReport - Displays the signing info for the base and test modules

sourceSets - Prints out all the source sets defined in this project.Build tasks

assemble - Assemble main outputs for all the variants. assembleAndroidTest - Assembles all the Test applications. assembleUnitTest - Assembles all the unit test applications. build - Assembles and tests this project. buildDependents - Assembles and tests this project and all projects that depend on it. buildKotlinToolingMetadata - Build metadata json file containing information about the used Kotlin tooling buildNeeded - Assembles and tests this project and all projects it depends on. bundle - Assemble bundles for all the variants. clean - Deletes the build directory. compileDebugAndroidTestSources compileDebugSources compileDebugUnitTestSources compilePreSources compilePreUnitTestSources compileReleaseSources compileReleaseUnitTestSources debugSourcesJar - Assembles a jar archive containing the sources of target debug. extractDebugAnnotations - Extracts Android annotations for the debug variant into the archive file extractReleaseAnnotations - Extracts Android annotations for the release variant into the archive file releaseSourcesJar - Assembles a jar archive containing the sources of target release.比如 ./gradlew clean 清楚app的build下的缓存 如果嫌弃敲命令可以点击图形化的 gradle的一个配置流程 最开始读取setting.gradle就知道一共有多少模块了 build.gradel是每个模块的构建脚本可以读取这个模块依赖了哪些插件支持哪些任务等最为核心的东西 讲解几个方法其实gradle中写的全是方法比如plugins 点击plugins,发现就是一个fun,因为kotlin中如果最后一个参数是方法的话lamd表达式可以放在后面因为只有一个参数所以可以省略 public final fun plugins(block: org.gradle.kotlin.dsl.PluginDependenciesSpecScope.() - kotlin.Unit): kotlin.Unit { /* compiled code / } 那alias函数呢其实是PluginDependenciesSpecScope类中的因为你传入的函数给你弄成了 PluginDependenciesSpecScope的扩展函数he gradle虽然是用java写的运行在虚拟机上但是他不支持用 java写脚本只是支持kotin和goovy,因为java太繁琐了 这种都是gradle的脚本 编写设置文件_哔哩哔哩_bilibili pluginManagement {repositories {google {content {includeGroupByRegex(com\.android.)includeGroupByRegex(com\.google.)includeGroupByRegex(androidx.)}}mavenCentral()gradlePluginPortal()} } dependencyResolutionManagement {repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)repositories {google()mavenCentral()} }rootProject.name My Application include(:app) include(:suAssert) include(:mylibrary)这些方法其实都是settings对象对象提供的 eg: settings.include(:mylibrary) 只是为了方便把settings去掉了 setting.gradle中也可以配置插件但是这里配置了的都是全局的一般都在module中配置 记得是一行一行往下执行 pluginManagement { //这个是指定插件的仓库地址repositories {google {content {includeGroupByRegex(com\.android.)includeGroupByRegex(com\.google.)includeGroupByRegex(androidx.)}}mavenCentral()gradlePluginPortal()} } dependencyResolutionManagement { //这是第三方依赖库的仓库地址repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)repositories {google()mavenCentral()} } 指定自定义的maven仓库 maven{setUrl()credentials {username SCOPE_ACCOUNTpassword SCOPE_PWD} } settings.gradle.kts其实作用域是 SettingsScriptApi,他是继承setting的所以返回的是setting对象 自定义任务 tasks有两种注册方式register和creat 。register是懒加载的意思 tasks.register(sujinbiao){doLast{println(结束)}doFirst{println(开始)} } 这样后gradle的task -others-sujinbiao 双击就可以执行或者命令行执行./gradlew sujinbiao  新创建的task的组别是在other中那么如何切换呢 tasks.create(sujinbiao){group builddescription 新建的task //会出现在打印的日志中doLast{println(结束)}doFirst{println(开始)} }tasks.create(sujin){group builddescription 新建的taskdoLast{println(sujin)}doFirst{println(sujin)} }tasks.create(sujinbiao){group builddescription 新建的taskdependsOn(sujin) //依赖别的任务别人任务执行完再执行这个任务doLast{println(结束)}doFirst{println(开始)} } 作用  如何修改现有的task    任务的配置的呢比如在现有的任务的基础上依赖我的任务呢 tasks.named(build){ //执行指定你要修改任务的名字就行dependsOn(sujin) } 如何自定义一个Task,其实 register方法有一个扩展函数支持传入一个泛行的 public inline fun reified T : org.gradle.api.Task org.gradle.api.tasks.TaskContainer.register(name: kotlin.String, noinline configuration: T.() - kotlin.Unit): org.gradle.api.tasks.TaskProviderT { / compiled code */ }open class myTask: DefaultTask(){private var name TaskAction //标记了这个就是在最后默认调用fun taskAction(){ println(执行了)}fun taskName(name: String){this.name nameprintln(name\({name})}}tasks.registermyTask(haha){taskName(苏金标)println(name\){})} 其实gradle也给我们提供一个内置的Task类型给我们使用 gradle的几大重要信息首先是加在顺序 最开始是加载电脑中国的全局配置文件gradle.properties,这个是所有的项目都可以用的这个默认是没有的得自己放置进去  .gradle/gradle.properties 再加载项目中的gradle.properties  - setting.gradle (setting对象)- 项目的build.gradle(rootproject和project 发现这两个没什么区别) -模块的 gradle.properties -模块的 build.gradle生成project对象     注意一点配置信息的等级是 .gradle/gradle.properties  模块的 项目中的 gradle/gradle.properties等级是最高的会覆盖其他的。 如何在build.gradle中读取配置信息呢 goovy DSL project.属性 或者 project.findProperty(属性) kotlin DSL  project.findProperty(属性) gradle的生命周期钩子