-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guard constraint resolution by a property since it isn't really possi…
…ble to know if a constraint is added by a plugin and out of user control or not.
- Loading branch information
Showing
6 changed files
with
167 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
src/test/groovy/com/github/benmanes/gradle/versions/ConstraintsSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package com.github.benmanes.gradle.versions | ||
|
||
import org.gradle.testkit.runner.GradleRunner | ||
import org.junit.Rule | ||
import org.junit.rules.TemporaryFolder | ||
import spock.lang.Specification | ||
|
||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||
|
||
final class ConstraintsSpec extends Specification { | ||
|
||
@Rule TemporaryFolder testProjectDir = new TemporaryFolder() | ||
private File buildFile | ||
|
||
def "Show updates for an api dependency constraint"() { | ||
given: | ||
def mavenRepoUrl = getClass().getResource('/maven/').toURI() | ||
buildFile = testProjectDir.newFile('build.gradle') | ||
buildFile << | ||
""" | ||
plugins { | ||
id 'java-library' | ||
id 'com.github.ben-manes.versions' | ||
} | ||
tasks.dependencyUpdates { | ||
checkConstraints = true | ||
} | ||
repositories { | ||
maven { | ||
url '${mavenRepoUrl}' | ||
} | ||
} | ||
dependencies { | ||
constraints { | ||
api 'com.google.inject:guice:2.0' | ||
} | ||
} | ||
""".stripIndent() | ||
|
||
when: | ||
def result = GradleRunner.create() | ||
.withProjectDir(testProjectDir.root) | ||
.withArguments('dependencyUpdates') | ||
.withPluginClasspath() | ||
.build() | ||
|
||
then: | ||
result.output.contains('com.google.inject:guice [2.0 -> 3.1]') | ||
result.task(':dependencyUpdates').outcome == SUCCESS | ||
} | ||
|
||
def "Does not override explicit dependency with constraint"() { | ||
given: | ||
def mavenRepoUrl = getClass().getResource('/maven/').toURI() | ||
buildFile = testProjectDir.newFile('build.gradle') | ||
buildFile << | ||
""" | ||
plugins { | ||
id 'java-library' | ||
id 'com.github.ben-manes.versions' | ||
} | ||
tasks.dependencyUpdates { | ||
checkConstraints = true | ||
} | ||
repositories { | ||
maven { | ||
url '${mavenRepoUrl}' | ||
} | ||
} | ||
dependencies { | ||
api 'com.google.inject:guice:3.0' | ||
constraints { | ||
api 'com.google.inject:guice:2.0' | ||
} | ||
} | ||
""".stripIndent() | ||
|
||
when: | ||
def result = GradleRunner.create() | ||
.withProjectDir(testProjectDir.root) | ||
.withArguments('dependencyUpdates') | ||
.withPluginClasspath() | ||
.build() | ||
|
||
then: | ||
result.output.contains('com.google.inject:guice [3.0 -> 3.1]') | ||
result.task(':dependencyUpdates').outcome == SUCCESS | ||
} | ||
|
||
def "Does not show updates for an api dependency constraint when disabled"() { | ||
given: | ||
def mavenRepoUrl = getClass().getResource('/maven/').toURI() | ||
buildFile = testProjectDir.newFile('build.gradle') | ||
buildFile << | ||
""" | ||
plugins { | ||
id 'java-library' | ||
id 'com.github.ben-manes.versions' | ||
} | ||
repositories { | ||
maven { | ||
url '${mavenRepoUrl}' | ||
} | ||
} | ||
dependencies { | ||
constraints { | ||
api 'com.google.inject:guice:2.0' | ||
} | ||
} | ||
""".stripIndent() | ||
|
||
when: | ||
def result = GradleRunner.create() | ||
.withProjectDir(testProjectDir.root) | ||
.withArguments('dependencyUpdates') | ||
.withPluginClasspath() | ||
.build() | ||
|
||
then: | ||
result.output.contains('No dependencies found.') | ||
result.task(':dependencyUpdates').outcome == SUCCESS | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters