Skip to content

Commit

Permalink
Introduce a "base" module plugin (#217)
Browse files Browse the repository at this point in the history
Some modules may not want to add the standard dependencies, because they are
not runtime modules. A typical example is that AOT module which doesn't use
annotation processing and will never be found on a user classpath.
  • Loading branch information
melix authored Oct 19, 2021
1 parent e587f99 commit 736ccad
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ gradlePlugin {
id = 'io.micronaut.build.internal.common'
implementationClass = 'io.micronaut.build.MicronautBuildCommonPlugin'
}
'base-module' {
id = 'io.micronaut.build.internal.base-module'
implementationClass = 'io.micronaut.build.MicronautBaseModulePlugin'
}
module {
id = 'io.micronaut.build.internal.module'
implementationClass = 'io.micronaut.build.MicronautModulePlugin'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.micronaut.build

import groovy.transform.CompileStatic
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.tasks.testing.Test

/**
* Configures a project as a typical Micronaut module project:
* - with dependency updates plugin
* - published on a Maven repository
* - with JUnit platform testing
*/
@CompileStatic
class MicronautBaseModulePlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.pluginManager.apply(MicronautBuildCommonPlugin)
project.pluginManager.apply(MicronautDependencyUpdatesPlugin)
project.pluginManager.apply(MicronautPublishingPlugin)
configureJUnit(project)
}

private static void configureJUnit(Project project) {
project.tasks.withType(Test).configureEach { Test test ->
test.useJUnitPlatform()
}
}

}
11 changes: 1 addition & 10 deletions src/main/groovy/io/micronaut/build/MicronautModulePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,8 @@ import org.gradle.api.tasks.testing.Test
class MicronautModulePlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.pluginManager.apply(MicronautBuildCommonPlugin)
project.pluginManager.apply(MicronautDependencyUpdatesPlugin)
project.pluginManager.apply(MicronautPublishingPlugin)
project.pluginManager.apply(MicronautBaseModulePlugin)
configureStandardDependencies(project)
configureJUnit(project)
}

private static void configureJUnit(Project project) {
project.tasks.withType(Test).configureEach { Test test ->
test.useJUnitPlatform()
}
}

private static Dependency configureStandardDependencies(Project project) {
Expand Down

0 comments on commit 736ccad

Please sign in to comment.