Skip to content

Commit

Permalink
Add baseVersion where missing
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob committed Feb 27, 2022
1 parent d507c92 commit 40f9be1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class PmdPluginTest : BaseIntgTest() {
apply plugin: 'net.twisterrob.pmd'
pmd {
toolVersion = '5.6.1'
if (GradleVersion.version("6.0.0") <= GradleVersion.current()) {
if (GradleVersion.version("6.0.0") <= GradleVersion.current().baseVersion) {
incrementalAnalysis.set(false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PmdTaskTest_ConfigLocation : BaseIntgTest() {
apply plugin: 'net.twisterrob.pmd'
apply plugin: 'pmd' // TODO figure out why this is needed to set toolVersion when Pmd task works anyway
pmd {
if (GradleVersion.version("6.0.0") <= GradleVersion.current()) {
if (GradleVersion.version("6.0.0") <= GradleVersion.current().baseVersion) {
incrementalAnalysis.set(false)
}
}
Expand Down
4 changes: 4 additions & 0 deletions docs/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ When running integration tests, the same is true, but `GradleRunnerRule` will us

This version is accessible from JUnit test code via `val gradle: GradleRunnerRule`'s `gradle.gradleVersion` property. This will contain what's in the property, if any.

### GradleVersion.current()
When accessing this, it should be done with `GradleVersion.current().baseVersion`, so that `<=` and similar comparisons work correctly.
They would otherwise break on rc/snapshot versons.

### Testception
There's some craziness happening in `TestPluginTest`, it uses `GradleRunnerRule` to set up a Gradle project that uses `GradleRunnerRule`. This applies `TestPlugin` which adds `gradleApi()` to the classpath. Since this test build is running via an outer `GradleRunnerRule`, that project's Gradle version will be added to the inner build's classpath.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.gradle.api.initialization.resolve.RepositoriesMode
import org.gradle.util.GradleVersion

fun shouldAddAutoRepositoriesTo(project: Project): Boolean {
if (GradleVersion.version("6.8") <= GradleVersion.current()) {
if (GradleVersion.version("6.8") <= GradleVersion.current().baseVersion) {
@Suppress("WHEN_ENUM_CAN_BE_NULL_IN_JAVA", "UnstableApiUsage")
return when (project.settings.dependencyResolutionManagement.repositoriesMode.get()) {
RepositoriesMode.PREFER_PROJECT -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TestPluginTest : BaseIntgTest() {
// make /test/build/libs/X-0.0.jar available as 'net.twisterrob.gradle:X:0.0'
url '${artifactPath.replace("\\", "\\\\")}'
// patternLayout(Action) was introduced in 5.0, layout(String, Closure) was removed in 7.0.
if (GradleVersion.current() < GradleVersion.version("5.0.0")) {
if (GradleVersion.current().baseVersion < GradleVersion.version("5.0.0")) {
layout('pattern') {
artifact '[artifact]-[revision].[ext]'
m2compatible = true
Expand Down

0 comments on commit 40f9be1

Please sign in to comment.