Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around Gradle 6.0 deprecations. #359

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import groovy.transform.TypeChecked
import org.gradle.api.Action
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import org.gradle.util.ConfigureUtil
Expand Down Expand Up @@ -54,14 +55,26 @@ class DependencyUpdatesTask extends DefaultTask {
return (outputFormatter instanceof String) ? ((String) outputFormatter) : null
}

@Input
// Groovy generates both get/is accessors for boolean properties unless we manually define some.
// Gradle will reject this behavior starting in 7.0 so we make sure to define accessors ourselves.
boolean checkForGradleUpdate = true

@Input
boolean checkConstraints = false

@Input
boolean getCheckForGradleUpdate() {
return checkForGradleUpdate
}

@Input
boolean getCheckConstraints() {
return checkConstraints
}

@Internal
Object outputFormatter = 'plain'

@Internal
Closure resolutionStrategy = null;
private Action<? super ResolutionStrategyWithCurrent> resolutionStrategyAction = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,22 @@ final class DifferentGradleVersionsSpec extends Specification {
apply plugin: 'java'
apply plugin: "com.github.ben-manes.versions"

// Gradle 7.0+ do not allow directly using compile configuration so we monkey patch
// an implementation configuration in for older Gradle versions.
if (configurations.findByName('implementation') == null) {
configurations.create('implementation') {
extendsFrom configurations.compile
}
}

repositories {
maven {
url '${mavenRepoUrl}'
}
}

dependencies {
compile 'com.google.inject:guice:2.0'
implementation 'com.google.inject:guice:2.0'
}

dependencyUpdates.resolutionStrategy {
Expand All @@ -68,10 +76,15 @@ final class DifferentGradleVersionsSpec extends Specification {
""".stripIndent()

when:
def arguments = ['dependencyUpdates']
// Warning mode reporting only supported on recent versions.
if (gradleVersion.substring(0, gradleVersion.indexOf('.')).toInteger() >= 6) {
arguments.add('--warning-mode=fail')
}
def result = GradleRunner.create()
.withGradleVersion(gradleVersion)
.withProjectDir(testProjectDir.root)
.withArguments('dependencyUpdates')
.withArguments(arguments)
.forwardStdError(srdErrWriter)
.build()

Expand Down Expand Up @@ -102,6 +115,7 @@ final class DifferentGradleVersionsSpec extends Specification {
'5.4.1',
'5.5.1',
'5.6',
'6.0'
]
}

Expand Down