Skip to content

Commit

Permalink
fix(groovy): groovy插件不能与Lombok同时使用 (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
henry-hub authored Jul 28, 2024
1 parent 15dc2ae commit cc85aca
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class IHubBomPluginTest extends IHubSpecification {
def result = gradleBuilder.build()

then: '检查结果'
result.output.matches '[\\s\\S]+│ pub.ihub.lib + │ ihub-bom + │ 1.0.12 + │[\\s\\S]+'
result.output.contains '│ pub.ihub.lib │ ihub-process │ 1.0.12'
result.output.contains '│ pub.ihub.lib │ ihub-core │ 1.0.12'
result.output.contains '│ pub.ihub.lib │ 1.0.12'
result.output.matches '[\\s\\S]+│ pub.ihub.lib + │ ihub-bom + │ 1.4.6 + │[\\s\\S]+'
result.output.contains '│ pub.ihub.lib │ ihub-process │ 1.4.6 '
result.output.contains '│ pub.ihub.lib │ ihub-core │ 1.4.6 '
result.output.contains '│ pub.ihub.lib │ 1.4.6 '
result.output.contains '│ org.slf4j │ slf4j-api │'
result.output.contains '│ pub.ihub │ all │'
result.output.contains '│ api │ pub.ihub.lib:ihub-core │'
Expand All @@ -56,7 +56,7 @@ class IHubBomPluginTest extends IHubSpecification {
}
iHubBom {
groupVersions {
group 'pub.ihub.lib' version '1.0.17'
group 'pub.ihub.lib' version '1.4.6'
}
capabilities {
requireCapability 'pub.ihub.lib:ihub-boot-cloud-spring-boot-starter', 'pub.ihub.lib:reactor-support'
Expand Down Expand Up @@ -90,9 +90,9 @@ class IHubBomPluginTest extends IHubSpecification {

then: '检查结果'
!result.output.contains('ihub-bom')
result.output.contains '│ pub.ihub.lib │ ihub-process │ 1.0.12'
result.output.contains '│ pub.ihub.lib │ ihub-core │ 1.0.12'
result.output.contains '│ pub.ihub.lib │ 1.0.12'
result.output.contains '│ pub.ihub.lib │ ihub-process │ 1.4.6 '
result.output.contains '│ pub.ihub.lib │ ihub-core │ 1.4.6 '
result.output.contains '│ pub.ihub.lib │ 1.4.6 '
result.output.contains '│ org.slf4j │ slf4j-api │'
result.output.contains '│ pub.ihub │ all │'
result.output.contains '│ api │ pub.ihub.lib:ihub-core │'
Expand All @@ -108,10 +108,10 @@ class IHubBomPluginTest extends IHubSpecification {
def result = gradleBuilder.build()

then: '检查结果'
result.output.matches '[\\s\\S]+│ pub.ihub.lib + │ ihub-bom + │ 1.0.12 + │[\\s\\S]+'
result.output.matches '[\\s\\S]+│ pub.ihub.lib + │ ihub-bom + │ 1.4.6 + │[\\s\\S]+'
!result.output.contains('│ ihub-process')
!result.output.contains('│ ihub-core')
result.output.contains '│ pub.ihub.lib │ 1.0.12'
result.output.contains '│ pub.ihub.lib │ 1.4.6 '
result.output.contains '│ org.slf4j │ slf4j-api │'
result.output.contains '│ pub.ihub │ all │'
result.output.contains '│ api │ pub.ihub.lib:ihub-core │'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import net.bytebuddy.build.gradle.ByteBuddyPlugin
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.ApplicationPlugin
import org.gradle.api.plugins.GroovyPlugin
import org.gradle.api.plugins.JavaApplication
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.plugins.JavaPlugin
Expand All @@ -48,7 +49,7 @@ import static pub.ihub.plugin.IHubProjectPluginAware.EvaluateStage.BEFORE
*/
@IHubPlugin(value = IHubJavaExtension, beforeApplyPlugins = [
IHubPluginsPlugin, IHubBomPlugin, JavaPlugin, JavaLibraryPlugin, ProjectReportsPlugin,
BuildDashboardPlugin, ByteBuddyPlugin, LombokPlugin
BuildDashboardPlugin, ByteBuddyPlugin
])
class IHubJavaPlugin extends IHubProjectPluginAware<IHubJavaExtension> {

Expand Down Expand Up @@ -166,6 +167,10 @@ class IHubJavaPlugin extends IHubProjectPluginAware<IHubJavaExtension> {
}

withExtension(AFTER) {
if (!hasPlugin(GroovyPlugin)) {
applyPlugin LombokPlugin
}

// 配置Jar属性
withTask Jar, JAR_CONFIG.curry(project)

Expand Down
6 changes: 3 additions & 3 deletions samples/sample-extensions/bom.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ description = 'BOM插件DSL扩展配置样例'
iHubBom {
// 导入mavenBom
importBoms {
group 'pub.ihub.lib' module 'ihub-bom' version '1.0.12'
group 'pub.ihub.lib' module 'ihub-bom' version '1.4.6'
}
// 配置依赖默认版本
dependencyVersions {
group 'pub.ihub.lib' modules 'ihub-core', 'ihub-process' version '1.0.12'
group 'pub.ihub.lib' modules 'ihub-core', 'ihub-process' version '1.4.6'
}
// 配置组版本策略
groupVersions {
group 'pub.ihub.lib' version '1.0.12'
group 'pub.ihub.lib' version '1.4.6'
}
// 排除组件依赖
excludeModules {
Expand Down

0 comments on commit cc85aca

Please sign in to comment.