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

长春网站建设开发维护网站排名首页前三位

长春网站建设开发维护,网站排名首页前三位,做海外贸易的网站名叫什么,墙纸 html 网站模板来到这里的是不是都有以下疑问: 1.build.gradle配置文件结构好复杂啊,怎么记? 2.内部是怎么进行分析和执行的? 3.为什么可以在配置文件里面写groovy代码,怎么识别的? 4.怎么才能很方便的记住和快速上手…

来到这里的是不是都有以下疑问:

1.build.gradle配置文件结构好复杂啊,怎么记?

2.内部是怎么进行分析和执行的?

3.为什么可以在配置文件里面写groovy代码,怎么识别的?

4.怎么才能很方便的记住和快速上手gradle呢?

好的,现在我带着你们的疑问,使用groovy代码的方式,慢慢解开build.grade神秘的面纱,探索其中的奥妙!!!

声明:不要急,我们慢慢深入,请耐心看完

首先我们先看一段groovy代码

        def dependencies = {println("我执行了")}dependencies()

执行结果:

这断代码就是一个无参方法声明和调用,是不是非常简单。

现在我们进一步改造

代码:

        def dependencies = {int a, int b ->println("我执行了" + a + b)}dependencies(1, 2)

 执行结果:

我这次只是加了两个整型参数,进行打印。

好的,我们再次深入改造

代码:

        def dependencies = {int a, int b, Closure c ->println( a+b)c.call()}dependencies(1, 2){println("我执行了")}

 执行结果:

 卧槽,什么鬼!!!!,竟然也行,

重要先看这部分代码

 dependencies(1, 2){println("我执行了")}

这部分代码起始可以看成是两部分:

1. 执行函数部分,dependencies(1, 2)

 2.回调函数逻辑实现部分, 

{println("我执行了")
}

当我们执行

dependencies(1, 2){println("我执行了")
}
这段代码时,实际执行流程就是将
{println("我执行了")
}这部分代码生成回调函数,由Closure对象的call函数进行执行回调 

然后真正执行函数dependencies,然后执行Closure.call执行回调逻辑。

以上都看明白了,现在我们真正进入主题

以gradle配置文件为例子,如下

dependencies {implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.0.4'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

此时你有该蒙蔽了

implementation 'com.google.android.material:material:1.4.0'是什么意思啊,你上面没有说啊,

那好,我们现在说,其实方法调用还有另一种方式

方法名称  参数1[,参数2]

就拿前面举得例子

代码:

        def dependencies = {a ->println("结果:" + a)}dependencies 100

执行结果: 

和dependencies(100)效果是一样的,

那好现在明白了,原来implementation、testImplementation、androidTestImplementation 其实就是内置函数哈。

implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.0.4'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

这些其实都是在调用函数哈,

dependencies {implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.0.4'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

那好,现在我就按照这个配置文件整体实现一下代码。

代码:

 def implementation = {arg ->println("引入接口依赖:" + arg)};def testImplementation  = {arg ->println("引入测试接口依赖:" + arg)};def androidTestImplementation = {arg ->println("引入安卓测试接口依赖:" + arg)}def dependencies = {Closure c ->c.call()}dependencies{implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.0.4'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'}

执行结果:

恍然大悟,原来build.gradle配置文件其实就是在执行各种函数。

应当随时学习,学习一切;应该集中全力,以求知道得更多,知道一切

http://www.hkea.cn/news/30435/

相关文章:

  • 微信网站上传图片手机怎么制作网站
  • 简单做网站需要学什么搜索引擎有哪些网站
  • 网站备案信息加到哪里如何进行网站推广
  • 昭通网站制作aso优化技巧
  • 制作网站时怎样做滚动字幕新网站多久会被百度收录
  • 余姚物流做网站微信指数是搜索量吗
  • 怎样做网站轮播今日国内重大新闻事件
  • 想给大学做网站百度网盘搜索神器
  • jsp网站开发论文官方app下载安装
  • 关于机场建设的网站今日疫情最新情况
  • 网站域名注册服务商google浏览器官方
  • 通过网站开发工具怎么改自动跳网站百度指数有哪些功能
  • 可以发锚文本的网站百度搜索官方网站
  • 东莞网站建设企慕简述如何优化网站的方法
  • 可以做网站的公司seo外包
  • 自己怎么做网站视频赚钱5g网络优化培训
  • 数据库修改网站管理员密码seo网站有优化培训吗
  • 福田做商城网站建设找哪家公司好抖音怎么运营和引流
  • 厘米售卡站怎么做网站禁止搜索引擎收录的方法
  • 网站首页滚动图片怎么做谷歌搜索关键词排名
  • 嵩县网站开发友情链接获取的途径有哪些
  • 国家企业信息公示网(广东)海南快速seo排名优化
  • 高端网站设计 上海徐州seo排名公司
  • 泰安网站建设公司排名石家庄最新消息
  • 域名只做邮箱没网站要备案吗常见的网络推广方式包括
  • 昆山建设局网站360搜索首页
  • 正常做网站多少钱无锡网站制作无锡做网站
  • php做网站csdn网站seo公司哪家好
  • 今日头条建站工具何鹏seo
  • wordpress 培训模板优化落实疫情防控新十条