diff --git a/.gitignore b/.gitignore index 0ee5c852..35962dcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ bin build out +.java-version .classpath .settings .project diff --git a/build.gradle b/build.gradle index e017bd41..e275cc8b 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ apply plugin: 'nexus' apply plugin: 'codenarc' group = 'com.github.ben-manes' -version = '0.23.0' +version = '0.24.0' sourceCompatibility = '1.6' diff --git a/src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyUpdatesTask.groovy b/src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyUpdatesTask.groovy index 66551056..92606ac7 100644 --- a/src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyUpdatesTask.groovy +++ b/src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyUpdatesTask.groovy @@ -22,6 +22,8 @@ import org.gradle.api.DefaultTask import org.gradle.api.tasks.Input import org.gradle.api.tasks.Optional import org.gradle.api.tasks.TaskAction +import org.gradle.util.ConfigureUtil +import org.gradle.util.SingleMessageLogger; import static com.github.benmanes.gradle.versions.updates.gradle.GradleReleaseChannel.* @@ -53,7 +55,9 @@ class DependencyUpdatesTask extends DefaultTask { boolean checkForGradleUpdate = true Object outputFormatter = 'plain' - Action resolutionStrategyAction = null + + Closure resolutionStrategy = null; + private Action resolutionStrategyAction = null DependencyUpdatesTask() { description = 'Displays the dependency updates for the project.' @@ -66,6 +70,12 @@ class DependencyUpdatesTask extends DefaultTask { def dependencyUpdates() { project.evaluationDependsOnChildren() + if (resolutionStrategy != null) { + resolutionStrategy(ConfigureUtil.configureUsing(resolutionStrategy)) + SingleMessageLogger.nagUserWith('dependencyUpdates.resolutionStrategy', /* removalDetails */ '', + 'Remove the assignment operator, \'=\', when setting this task property', /* contextualAdvice */ null); + } + def evaluator = new DependencyUpdates(project, resolutionStrategyAction, revisionLevel(), outputFormatterProp(), outputDirectory(), getReportfileName(), checkForGradleUpdate, gradleReleaseChannelLevel()) DependencyUpdatesReporter reporter = evaluator.run() @@ -78,6 +88,7 @@ class DependencyUpdatesTask extends DefaultTask { */ void resolutionStrategy(final Action resolutionStrategy) { this.resolutionStrategyAction = resolutionStrategy + this.resolutionStrategy = null } /** Returns the resolution revision level. */ diff --git a/src/test/groovy/com/github/benmanes/gradle/versions/ComponentSelectionRuleSourceSpec.groovy b/src/test/groovy/com/github/benmanes/gradle/versions/ComponentSelectionRuleSourceSpec.groovy index fbfb93dd..bc90aace 100644 --- a/src/test/groovy/com/github/benmanes/gradle/versions/ComponentSelectionRuleSourceSpec.groovy +++ b/src/test/groovy/com/github/benmanes/gradle/versions/ComponentSelectionRuleSourceSpec.groovy @@ -23,7 +23,7 @@ final class ComponentSelectionRuleSourceSpec extends Specification { } @Unroll - def 'component selection works with rule-source'() { + def 'component selection works with rule-source (#assignment)'() { given: def classpathString = pluginClasspath .collect { it.absolutePath.replace('\\', '\\\\') } // escape backslashes in Windows paths @@ -55,15 +55,15 @@ final class ComponentSelectionRuleSourceSpec extends Specification { dependencies { compile 'com.google.inject:guice:2.0' } - - dependencyUpdates.resolutionStrategy { + + dependencyUpdates.resolutionStrategy ${assignment} { componentSelection { all(new Rule()) } } - + class Rule { - + @Mutate void select(ComponentSelectionWithCurrent selection) { if (selection.candidate.version == "3.1" && selection.currentVersion == "2.0") { @@ -83,5 +83,8 @@ final class ComponentSelectionRuleSourceSpec extends Specification { then: result.output.contains('com.google.inject:guice [2.0 -> 3.0]') srdErrWriter.toString().empty + + where: + assignment << [' ', '='] } }