跳至主要內容

ihub-settings

Henry...大约 2 分钟

ihub-settings

插件说明

ihub-settings插件用于配置插件仓库、插件版本以及子项目管理,配置与settings.gradle

插件ID插件名称插件类型扩展名称
pub.ihub.plugin.ihub-settings设置插件Settings[1]iHubSettings

扩展属性

DSL扩展配置支持配置

扩展方法扩展描述
includeProjects添加项目(支持多个项目)
prefix项目前缀
noPrefix无项目前缀
suffix项目后缀
subproject包含三级子项目
onlySubproject仅含三级子项目(不含当前项目,三级项目为主项目的子项目)
skippedDirs忽略三级子项目目录

gradle.properties配置支持属性

PropertyDescription
name配置主项目名称
iHubSettings.includeDirs包含项目路径,多目录“,”分割
iHubSettings.skippedDirs排除项目路径,多目录“,”分割
iHubSettings.includeBom用于配置bom组件,包含所有含ihub-publish组件的子项目
iHubSettings.includeLibs发布catalog组件开关,
iHubSettings.includeDependencies用于配置dependencies组件,基于catalog组件配置

配置如下:

name=demo
iHubSettings.includeDirs=rest,service
iHubSettings.includeBom=ihub-bom

插件安装

Kotlin
plugins {
    id("pub.ihub.plugin.ihub-settings") version "1.5.4"
}

配置示例

配置子项目

  • 目录结构:
+---rest
+---sdk
\---service
  • 配置:
Kotlin
import pub.ihub.plugin.IHubSettingsExtension

configure<IHubSettingsExtension> {
    includeProjects("rest", "sdk", "service")
}

配置三级子项目

  • 目录结构:
+---rest
+---service
+---test
\---other
    +---a
    +---b
    \---c
  • 配置:
Kotlin
import pub.ihub.plugin.IHubSettingsExtension

configure<IHubSettingsExtension> {
    includeProjects("rest", "service").suffix("-suffix")
    includeProjects("test").noPrefix
    includeProjects("other").prefix("prefix-").skippedDirs("c").subproject
    includeProjects("subproject").prefix("prefix-").suffix("-suffix").onlySubproject
}

注意

插件默认排除了常见非项目目录,build, src, conf, libs, logs, docs, classes, target, out, node_modules, db, gradle
没有配置指定子项目时,自动添加所有子项目

默认插件仓库

私有仓库、自定义仓库配置参见扩展属性

NameDescriptionUrl
ProjectDirs项目本地插件{rootProject.projectDir}/gradle/plugins
MavenLocal本地仓库{local}/.m2/repository
AliYunGradle阿里云Gradle代理仓库https://maven.aliyun.com/repository/gradle-pluginopen in new window
ReleaseRepo私有Release仓库https://repo.xxx.com/releaseopen in new window
SnapshotRepo私有Snapshot仓库https://repo.xxx.com/snapshotopen in new window
CustomizeRepo自定义仓库仓库https://repo.xxx.com/repoopen in new window

默认版本

插件配置了ihub系列插件及以下插件默认版本:

PluginVersion
com.gradle.plugin-publish1.2.0open in new window
pub.ihub.plugin.*1.4.1open in new window
io.freefair.*8.0.1open in new window

使用插件时可以不用加版本号,配置如下:

Kotlin
plugins {
    id("pub.ihub.plugin")
    id("com.gradle.plugin-publish")
}

配置catalog

  • 配置默认版本目录组件ihubLibs
dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }
    versionCatalogs {
        ihubLibs {
            from "pub.ihub.lib:ihub-libs:${IHubLibsVersion.version}"
        }
    }
}
  • gradle/libs.versions.toml为标准配置,gradle会自动导入
  • 本插件也会自动配置gradle/libs/目录下的其他.versions.toml文件,如:myLibs.versions.toml,一般使用标准配置即可
  • 支持基于iHub.profile属性配置,根据profile替换libs.versions.toml里的versions配置,配置文件路径gradle/libs/profiles,如:gradle/libs/profiles/dev.versions.toml

  1. Settings:配置类型插件,配置与settings.gradle文件,类型说明详见open in new window ↩︎