From c3a7fc5303ed6fd142ba78332f5ade6098dff303 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 14 Oct 2023 15:06:51 +0800 Subject: [PATCH] =?UTF-8?q?build(java):=20=E4=B8=8D=E5=86=8D=E5=85=BC?= =?UTF-8?q?=E5=AE=B9Java8=20(#676)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: henry --- README.md | 19 ++++++++++--------- .../pub/ihub/plugin/IHubLibsVersions.groovy | 4 +--- .../ihub/plugin/IHubProjectPluginAware.groovy | 16 ++++++++++++---- .../ihub/plugin/IHubLibsVersionsTest.groovy | 5 ++--- .../pub/ihub/plugin/IHubPluginsPlugin.groovy | 5 ----- .../plugin/publish/IHubPublishPlugin.groovy | 4 ++-- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 7b165e8c..63988807 100644 --- a/README.md +++ b/README.md @@ -96,15 +96,16 @@ iHub.mavenAliYunEnabled=true 详细版本历史见 [Releases](https://github.com/ihub-pub/plugins/releases),兼容性版本说明如下: -| Version | Java | Gradle | -|---------|------|--------| -| 1.4.0 | 8~20 | 8.2.1 | -| 1.3.1+ | 17 | 8.0 | -| 1.3.0 | 17 | 7.5.1 | -| 1.2.4+ | 11 | 7.4.1 | -| 1.2.3 | 11 | 7.4 | -| 1.1.1 | 11 | 7.2 | -| 1.1.0 | 11 | 7.0 | +| Version | Java | Gradle | +|---------|-------|--------| +| 1.5.0+ | 11~21 | 8.0 | +| 1.4.0+ | 8~20 | 8.0 | +| 1.3.1+ | 17 | 8.0 | +| 1.3.0 | 17 | 7.5.1 | +| 1.2.4+ | 11 | 7.4.1 | +| 1.2.3 | 11 | 7.4 | +| 1.1.1 | 11 | 7.2 | +| 1.1.0 | 11 | 7.0 | ## ✅ 项目状态 diff --git a/ihub-base/src/main/groovy/pub/ihub/plugin/IHubLibsVersions.groovy b/ihub-base/src/main/groovy/pub/ihub/plugin/IHubLibsVersions.groovy index 0409a7f0..7a6c31d6 100644 --- a/ihub-base/src/main/groovy/pub/ihub/plugin/IHubLibsVersions.groovy +++ b/ihub-base/src/main/groovy/pub/ihub/plugin/IHubLibsVersions.groovy @@ -36,9 +36,7 @@ class IHubLibsVersions { } static String getCompatibleLibsVersion(String name) { - current().isCompatibleWith(JavaVersion.VERSION_17) ? getLibsVersion(name) : - current().java11Compatible ? getLibsVersion(name) + '-java11' : - current().java8Compatible ? getLibsVersion(name) + '-java1.8' : '' + current().isCompatibleWith(JavaVersion.VERSION_17) ? getLibsVersion(name) : getLibsVersion(name) + '-java11' } } diff --git a/ihub-base/src/main/groovy/pub/ihub/plugin/IHubProjectPluginAware.groovy b/ihub-base/src/main/groovy/pub/ihub/plugin/IHubProjectPluginAware.groovy index f17e7a9e..24827359 100644 --- a/ihub-base/src/main/groovy/pub/ihub/plugin/IHubProjectPluginAware.groovy +++ b/ihub-base/src/main/groovy/pub/ihub/plugin/IHubProjectPluginAware.groovy @@ -22,6 +22,8 @@ import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.logging.Logger import org.gradle.api.provider.Property +import org.gradle.api.provider.Provider +import org.gradle.api.provider.ProviderFactory import org.gradle.api.tasks.TaskProvider import static groovy.transform.TypeCheckingMode.SKIP @@ -172,6 +174,12 @@ abstract class IHubProjectPluginAware implements P } } + private static void setExtensionProperty(Property property, Class type, Provider value) { + if (value.present) { + setExtensionProperty property, type, value.get().replaceAll('\\\\n', '\n') + } + } + private static void setExtensionProperty(Property property, Class type, value) { if (value) { property.set value.toString().with { @@ -195,15 +203,15 @@ abstract class IHubProjectPluginAware implements P } // 环境配置、系统配置要在项目扩展配置后执行,确保优先级高于扩展配置 afterEvaluate { + ProviderFactory providers = project.providers // 获取环境属性 if (type().contains(ENV)) { - setExtensionProperty property, genericType(), - System.getenv(fieldName.replaceAll(/([A-Z])/, '_$1').toUpperCase())?.replaceAll('\\\\n', '\n') + setExtensionProperty property, genericType(), providers + .environmentVariable(fieldName.replaceAll(/([A-Z])/, '_$1').toUpperCase()) } // 获取系统属性 if (type().contains(SYSTEM)) { - setExtensionProperty property, genericType(), - System.getProperty(propertyName)?.replaceAll('\\\\n', '\n') + setExtensionProperty property, genericType(), providers.systemProperty(propertyName) } } } diff --git a/ihub-base/src/test/groovy/pub/ihub/plugin/IHubLibsVersionsTest.groovy b/ihub-base/src/test/groovy/pub/ihub/plugin/IHubLibsVersionsTest.groovy index f7123d99..04b8d31d 100644 --- a/ihub-base/src/test/groovy/pub/ihub/plugin/IHubLibsVersionsTest.groovy +++ b/ihub-base/src/test/groovy/pub/ihub/plugin/IHubLibsVersionsTest.groovy @@ -37,11 +37,10 @@ class IHubLibsVersionsTest extends Specification { where: javaVersion | expected - '5' | '' - '8' | /^\d+.\d+.\d+-java1.8/ + '8' | /^\d+.\d+.\d+-java11/ '11' | /^\d+.\d+.\d+-java11/ '17' | /^\d+.\d+.\d+$/ - '19' | /^\d+.\d+.\d+$/ + '21' | /^\d+.\d+.\d+$/ } } diff --git a/ihub-plugins/src/main/groovy/pub/ihub/plugin/IHubPluginsPlugin.groovy b/ihub-plugins/src/main/groovy/pub/ihub/plugin/IHubPluginsPlugin.groovy index 90bd1497..a866bcd0 100644 --- a/ihub-plugins/src/main/groovy/pub/ihub/plugin/IHubPluginsPlugin.groovy +++ b/ihub-plugins/src/main/groovy/pub/ihub/plugin/IHubPluginsPlugin.groovy @@ -15,9 +15,7 @@ */ package pub.ihub.plugin - import pub.ihub.plugin.bom.IHubBomPlugin -import pub.ihub.plugin.profiles.IHubProfilesPlugin import pub.ihub.plugin.version.IHubVersionPlugin import static pub.ihub.plugin.IHubPluginMethods.printLineConfigContent @@ -53,9 +51,6 @@ class IHubPluginsPlugin extends IHubProjectPluginAware { // 默认应用IHubBom插件 applyPlugin IHubBomPlugin - // 默认应用IHubProfiles插件 - applyPlugin IHubProfilesPlugin - project.subprojects { pluginManager.apply IHubPluginsPlugin } diff --git a/ihub-publish/src/main/groovy/pub/ihub/plugin/publish/IHubPublishPlugin.groovy b/ihub-publish/src/main/groovy/pub/ihub/plugin/publish/IHubPublishPlugin.groovy index d20e8110..466eda3c 100644 --- a/ihub-publish/src/main/groovy/pub/ihub/plugin/publish/IHubPublishPlugin.groovy +++ b/ihub-publish/src/main/groovy/pub/ihub/plugin/publish/IHubPublishPlugin.groovy @@ -43,7 +43,7 @@ import pub.ihub.plugin.bom.IHubBomExtension import pub.ihub.plugin.bom.IHubBomPlugin import static cn.hutool.http.HttpUtil.get -import static io.freefair.gradle.util.GitUtil.githubActions +import static io.freefair.gradle.util.GitUtil.isGithubActions /** * 组件发布插件 @@ -56,7 +56,7 @@ class IHubPublishPlugin extends IHubProjectPluginAware { void apply() { afterEvaluate { // 引入GithubPom插件 - if (extension.applyGithubPom.get() && githubActions) { + if (extension.applyGithubPom.get() && isGithubActions(project.providers)) { applyPlugin GithubPomPlugin withExtension(PublishingExtension) { it.publications.withType MavenPublication, this::configurePomDevelopers