Skip to content

Commit d232684

Browse files
committed
minor review remarks
1 parent 2c80e4b commit d232684

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

libs/groovylib/src/mill/groovylib/GroovyModule.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait GroovyModule extends JavaModule with GroovyModuleApi { outer =>
3131
*/
3232
def groovyLanguageVersion: T[String] = Task { groovyVersion().split("[.]").take(2).mkString(".") }
3333

34-
private def isGroovyBomAvailable: T[Boolean] = Task {
34+
private def useGroovyBom: T[Boolean] = Task {
3535
if (groovyVersion().isBlank) {
3636
false
3737
} else {
@@ -41,7 +41,7 @@ trait GroovyModule extends JavaModule with GroovyModuleApi { outer =>
4141

4242
override def bomMvnDeps: T[Seq[Dep]] = super.bomMvnDeps() ++
4343
Seq(groovyVersion())
44-
.filter(_.nonEmpty && isGroovyBomAvailable())
44+
.filter(_.nonEmpty && useGroovyBom())
4545
.map(v => mvn"org.apache.groovy:groovy-bom:$v")
4646

4747
/**
@@ -54,15 +54,15 @@ trait GroovyModule extends JavaModule with GroovyModuleApi { outer =>
5454
/**
5555
* Specifiy the bytecode version for the Groovy compiler.
5656
* {{{
57-
* def targetBytecode = Some("17")
57+
* def groovyCompileTargetBytecode = Some("17")
5858
* }}}
5959
*/
60-
def targetBytecode: T[Option[String]] = None
60+
def groovyCompileTargetBytecode: T[Option[String]] = None
6161

6262
/**
6363
* Specify if the Groovy compiler should enable preview features.
6464
*/
65-
def enablePreview: T[Boolean] = false
65+
def groovyCompileEnablePreview: T[Boolean] = false
6666

6767
/**
6868
* Specify which global AST transformations should be disabled. Be aware that transformations
@@ -153,8 +153,8 @@ trait GroovyModule extends JavaModule with GroovyModuleApi { outer =>
153153
val updateCompileOutput = upstreamCompileOutput()
154154

155155
val config = GroovyCompilerConfiguration(
156-
enablePreview = enablePreview(),
157-
targetBytecode = targetBytecode(),
156+
enablePreview = groovyCompileEnablePreview(),
157+
targetBytecode = groovyCompileTargetBytecode(),
158158
disabledGlobalAstTransformations = disabledGlobalAstTransformations()
159159
)
160160

libs/groovylib/src/mill/groovylib/JavaMavenModuleWithGroovyTests.scala

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@ import mill.*
44
import mill.javalib.{JavaModule, MavenModule}
55

66
/**
7-
* Convenience trait for projects using Java for production and Groovy for tests in a Maven setup
7+
* Convenience trait for projects using Java for production and Groovy for tests in a Maven setup.
8+
*
9+
* Since [[GroovyModule.GroovyTests]] is only available as a child-trait, it is necessary to have
10+
* the main module as a [[GroovyModule]], which would implicitly add Groovy dependencies to the
11+
* module.
12+
* This trait explicitly uses Java with a Maven layout for the main module and enables `src/test/groovy`
13+
* as a source folder for Groovy tests.
14+
*
15+
* {{{
16+
* object `package` extends JavaMavenModuleWithGroovyTests {
17+
*
18+
* object `test` extends GroovyMavenTests with TestModule.Spock {
19+
* override def groovyVersion: T[String] = "4.0.28"
20+
* override def spockVersion: T[String] = "2.3-groovy-4"
21+
* }
22+
* }
23+
* }}}
24+
*
25+
* Note: for non-Maven layouts this is not necessary, since the test module can just be a [[GroovyModule]].
826
*/
927
@mill.api.experimental
1028
trait JavaMavenModuleWithGroovyTests extends JavaModule with MavenModule {

libs/groovylib/test/src/mill/groovylib/HelloGroovyTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ object HelloGroovyTests extends TestSuite {
107107
object compileroptions extends GroovyModule {
108108
def javaVersion = "11"
109109
override def groovyVersion: T[String] = crossValue
110-
override def targetBytecode: Task.Simple[Option[String]] = Some(javaVersion)
111-
override def enablePreview: Task.Simple[Boolean] = true
110+
override def groovyCompileTargetBytecode: Task.Simple[Option[String]] = Some(javaVersion)
111+
override def groovyCompileEnablePreview: Task.Simple[Boolean] = true
112112
override def mainClass = Some("compileroptions.HelloCompilerOptions")
113113
}
114114
}

libs/javalib/src/mill/javalib/TestModule.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ object TestModule {
372372
/** The JUnit Jupiter version to use, or empty, if you want to provide the dependencies yourself. */
373373
def jupiterVersion: T[String] = Task { "" }
374374

375-
private def isJupiterBomAvailable: T[Boolean] = Task {
375+
private def useJupiterBom: T[Boolean] = Task {
376376
if (jupiterVersion().isBlank) {
377377
false
378378
} else {
@@ -385,7 +385,7 @@ object TestModule {
385385
override def bomMvnDeps: T[Seq[Dep]] = Task {
386386
super.bomMvnDeps() ++
387387
Seq(jupiterVersion())
388-
.filter(!_.isBlank() && isJupiterBomAvailable())
388+
.filter(!_.isBlank() && useJupiterBom())
389389
.flatMap(v =>
390390
Seq(
391391
mvn"org.junit:junit-bom:${v.trim()}"
@@ -399,7 +399,7 @@ object TestModule {
399399
Seq(junitPlatformVersion()).flatMap(v => {
400400
if (!v.isBlank) {
401401
Some(mvn"org.junit.platform:junit-platform-launcher:${v.trim()}")
402-
} else if (isJupiterBomAvailable()) {
402+
} else if (useJupiterBom()) {
403403
Some(mvn"org.junit.platform:junit-platform-launcher")
404404
} else {
405405
None

0 commit comments

Comments
 (0)