Skip to content

Commit

Permalink
fix(java): Groovy增量编译与Java注释处理器不能同时使用 (#309)
Browse files Browse the repository at this point in the history
* fix(java): Groovy增量编译与Java注释处理器不能同时使用

* fix(test): 修正测试用例
  • Loading branch information
henry-hub authored Aug 26, 2022
1 parent f9e8944 commit 136136a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 24 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@

## 👨‍💻 开源贡献指南

请阅读 [贡献指南](https://github.com/ihub-pub/.github/blob/main/CONTRIBUTING.md) 为该项目做出贡献
请阅读 [贡献指南](https://github.com/ihub-pub/.github/blob/main/CONTRIBUTING.md) 为该项目做出贡献

## ⭐ Stargazers & Forkers

[![Stargazers repo roster for @ihub-pub/plugins](https://reporoster.com/stars/ihub-pub/plugins)](https://github.com/ihub-pub/plugins/stargazers)

[![Forkers repo roster for @ihub-pub/plugins](https://reporoster.com/forks/ihub-pub/plugins)](https://github.com/ihub-pub/plugins/network/members)
8 changes: 4 additions & 4 deletions docs/iHubJava.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
| Extension | Description | Default | Ext | Prj | Sys | Env |
| --------- |-------------------------------------------------------------| ------- | --- | ------- | ------ | --- |
| `defaultDependencies` | 默认依赖(“,”分割)[详见](iHubJava?id=默认依赖),可以设置`false`关闭默认配置 | `false` | ||||
| `compileEncoding` | Java编译编码 | `UTF-8` | ||||
| `compatibility` | Java兼容性配置 || ||||
| `gradleCompilationIncremental` | gradle增量编译 | `true` | ||||
| `defaultDependencies` | 默认依赖(“,”分割)[详见](iHubJava?id=默认依赖),可以设置`false`关闭默认配置 | `log` | ||||
| `compileEncoding` | Java编译编码 | `UTF-8` | ||||
| `compatibility` | Java兼容性配置 || ||||
| `gradleCompilationIncremental` | gradle增量编译 | `true` | ||||
| `applyOpenapiPlugin` | 启用 [SpringDoc](https://github.com/springdoc/springdoc-openapi-gradle-plugin) 插件 | `false` |||||
| `jmoleculesArchitecture` | JMolecules架构(可选类型:cqrs、layered、onion)[详见](https://jmolecules.org) | `onion` |||||

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ package pub.ihub.plugin.bom
import io.spring.gradle.dependencymanagement.DependencyManagementPlugin
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import org.gradle.api.Action
import org.gradle.api.plugins.GroovyPlugin
import pub.ihub.core.IHubLibsVersion
import pub.ihub.plugin.IHubPlugin
import pub.ihub.plugin.IHubPluginsPlugin
import pub.ihub.plugin.IHubProjectPluginAware
import pub.ihub.plugin.java.IHubJavaExtension

import static pub.ihub.plugin.IHubProjectPluginAware.EvaluateStage.AFTER

Expand Down Expand Up @@ -50,6 +52,12 @@ class IHubBomPlugin extends IHubProjectPluginAware<IHubBomExtension> {
withExtension(AFTER) { ext ->
configVersions ext

// Groovy增量编译与Java注释处理器不能同时使用
if (hasPlugin(GroovyPlugin) && withExtension(IHubJavaExtension).gradleCompilationIncremental) {
ext.dependencies.removeIf {
it.type == 'annotationProcessor'
}
}
configProject ext

ext.refreshCommonSpecs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class IHubJavaExtension implements IHubProjectExtensionAware {
* 默认依赖(“,”分割)
*/
@IHubProperty
String defaultDependencies = 'false'
String defaultDependencies = 'log'

/**
* Java编译编码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import net.bytebuddy.build.gradle.AbstractByteBuddyTask
import net.bytebuddy.build.gradle.AbstractByteBuddyTaskExtension
import net.bytebuddy.build.gradle.ByteBuddyPlugin
import org.gradle.api.JavaVersion
import org.gradle.api.plugins.GroovyPlugin
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.ProjectReportsPlugin
Expand All @@ -44,8 +45,7 @@ import static pub.ihub.plugin.IHubProjectPluginAware.EvaluateStage.BEFORE
* @author henry
*/
@IHubPlugin(value = IHubJavaExtension, beforeApplyPlugins = [
IHubBomPlugin, JavaPlugin, JavaLibraryPlugin, LombokPlugin, ProjectReportsPlugin, BuildDashboardPlugin,
ByteBuddyPlugin
IHubBomPlugin, JavaPlugin, JavaLibraryPlugin, ProjectReportsPlugin, BuildDashboardPlugin, ByteBuddyPlugin
])
class IHubJavaPlugin extends IHubProjectPluginAware<IHubJavaExtension> {

Expand Down Expand Up @@ -148,6 +148,9 @@ class IHubJavaPlugin extends IHubProjectPluginAware<IHubJavaExtension> {
if (it.applyOpenapiPlugin) {
applyPlugin ProcessesPlugin, OpenApiGradlePlugin
}
if (!hasPlugin(GroovyPlugin)) {
applyPlugin LombokPlugin
}
}

// 配置Jar属性
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,24 @@ class IHubBomPluginTest extends IHubSpecification {
result.output.contains '│ org.codehaus.groovy │ groovy-bom │ 2.5.14 │'
result.output.contains '│ pub.ihub.lib │ ihub-bom │ 1.0.7 │'
result.output.contains '│ pub.ihub.lib │ 1.0.7 │'
result.output.contains '│ api │ :a │'
result.output.contains '│ api │ :b │'
result.output.contains '│ api │ :c │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-xml │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-dateutil │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-templates │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-nio │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-json │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-groovydoc │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-sql │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-datetime │'
result.output.contains '│ annotationProcessor │ org.springframework.boot:spring-boot-configuration-processor │'
result.output.contains '│ compileOnlyApi │ pub.ihub.lib:ihub-core │'
result.output.contains '│ testCompileOnly │ pub.ihub.lib:ihub-process │'
result.output.contains '│ api │ :a │'
result.output.contains '│ api │ :b │'
result.output.contains '│ api │ :c │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-xml │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-dateutil │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-templates │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-nio │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-json │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-groovydoc │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-sql │'
result.output.contains '│ implementation │ org.codehaus.groovy:groovy-datetime │'
result.output.contains '│ compileOnlyApi │ pub.ihub.lib:ihub-core │'
result.output.contains '│ testCompileOnly │ pub.ihub.lib:ihub-process │'
result.output.contains '│ compileOnlyApi │ pub.ihub.lib:ihub-process │'
result.output.contains '│ testRuntimeOnly │ pub.ihub.lib:ihub-core │'
result.output.contains '│ testImplementation │ pub.ihub.lib:ihub-core │'
result.output.contains '│ pub.ihub.lib │ core '
result.output.contains '│ pub.ihub.lib │ core'
result.output.contains '│ pub.ihub.lib │ all │'
result.output.contains '│ pub.ihub.lib │ ihub-core │'
result.output.contains '│ pub.ihub.lib │ all │'
Expand Down

0 comments on commit 136136a

Please sign in to comment.