Gradle Debug:基于 Composite Build 的方式
source link: http://www.phodal.com/blog/gradle-debug-composite-build/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
最近,在研究 Gradle 的编译和插件相关的东西,配置了两次 Gradle Composite Build,结果还是忘了。所以,我决定写一篇文章记录一下:如何使用 Gradle Composite Build 调试 Gradle Plugin。
常规 Composite Build
对于一般项目来说,采用 Gradle 官网的配置方式即可: Composing builds
-
在
settings.gradle
中添加模块:
rootProject.name = 'my-composite' include ':plugin-example' includeBuild 'some-plugin'
如果没有的话,需要创建一级父目录,并将插件( some-plugin
)和插件示例( plugin-example
)放置在同一级目录。然后修改一下插件示例( plugin-example
)的 plugins 为:
plugins { id("com.phodal.gradle") }
然后,对于插件来说,需要使用插件: java-gradle-plugin
,同时配置一下插件:
gradlePlugin { plugins { create('com.phodal.gradle') { id = 'com.phodal.gradle' implementationClass = 'com.phodal.gradle.MainPlugin' } } }
这样一来,IDEA 就可以根据 Plugin ID 找到对应的 class,就可以进行愉快地调试。
多 Projct 项目集成
对于复杂一点的项目来说,就会麻烦一点,比如说,我们的插件和插件示例,都有 settings.gradle
。我们就需要 merge 一下这两个项目,所以就会变成一个项目包含另外一个项目的关系。
一个比较容易实现的场景是插件示例,包含插件工程:
├── plugin-demo │ └── src ├── build.gradle ├── settings.gradle └── gradle-plugin ├── build.gradle ├── buildSrc └── settings.gradle
这样,只需要稍微改一下 settings.gradle
就可以了。
Recommend
-
54
写过java的都知道,lombok几乎在项目中处于不可或缺的一部分,但是lombok在Gradle的项目中配置并非人人都知道。 很多人在项目依赖中直接这样写 compile "org.projectlombok:lombok:1.18.4"
-
8
[本文结构] 因为墙以及不同开发者的环境的原因,经常会出现clone了一个开源项目以后无法运行的情况,因此专门整理了个人的开源项目在引用或者运行时一些通用的注意事项,其实所...
-
20
[本文结构] An Android Project with more than one module,the app module(some api developed by jni) depend on an Android Library which has native so. 该项目...
-
6
使用gradle构建基于Java Chassis开发的微服务 少于 1 分钟 阅读 maven和gradle都是Java世界中常用的构建工具。在
-
12
AWS SAM The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to express functions, APIs, databases, and event source mappings. With just a few lines...
-
2
基于 IDEA 针对 Elasticsearch 7.10 源码 Debug 发表于 20...
-
15
Build and Debug C++ with WSL 2 Distributions and Visual Studio 2022 Erika
-
5
build, test, and debug regexAn explanation of your regex will be automatically generated as you type.Detailed match information will be displayed here automatically.Search re...
-
6
Applying a 3rd Party Gradle Plugin as a Composite Plugin By blundell Last updated: 2023-01-10...
-
4
When developing an app, there might be a time when you want to add some code during development (DEBUG build configuration) and remove it from the release version (RELEASE build configuration) for security and per...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK