Skip to content

Commit

Permalink
build(java): 不再兼容Java8 (#676)
Browse files Browse the repository at this point in the history
Signed-off-by: henry <[email protected]>
  • Loading branch information
henry-hub authored Oct 14, 2023
1 parent 0256124 commit c3a7fc5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

## ✅ 项目状态

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -172,6 +174,12 @@ abstract class IHubProjectPluginAware<T extends IHubExtensionAware> implements P
}
}

private static void setExtensionProperty(Property property, Class type, Provider<String> 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 {
Expand All @@ -195,15 +203,15 @@ abstract class IHubProjectPluginAware<T extends IHubExtensionAware> 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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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+$/
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -53,9 +51,6 @@ class IHubPluginsPlugin extends IHubProjectPluginAware<IHubPluginsExtension> {
// 默认应用IHubBom插件
applyPlugin IHubBomPlugin

// 默认应用IHubProfiles插件
applyPlugin IHubProfilesPlugin

project.subprojects {
pluginManager.apply IHubPluginsPlugin
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
* 组件发布插件
Expand All @@ -56,7 +56,7 @@ class IHubPublishPlugin extends IHubProjectPluginAware<IHubPublishExtension> {
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
Expand Down

0 comments on commit c3a7fc5

Please sign in to comment.