Skip to content

Commit

Permalink
Fix #49 and consistent indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Jan 30, 2015
1 parent d603bad commit 60dcf4f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 102 deletions.
17 changes: 10 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ apply plugin: 'nexus'
apply plugin: 'codenarc'

group = 'com.github.ben-manes'
version = '0.7'
version = '0.8'

sourceCompatibility = "1.6"
sourceCompatibility = '1.6'

buildscript {
repositories {
mavenCentral()
jcenter()
}

Expand All @@ -23,19 +22,19 @@ repositories {
}

codenarcMain {
configFile = file('config/codenarc/rules.groovy')
configFile = file('config/codenarc/rules.groovy')
}

codenarcTest {
configFile = file('config/codenarc/testrules.groovy')
configFile = file('config/codenarc/testrules.groovy')
}

codenarc {
toolVersion = 0.21
toolVersion = 0.21
}

tasks.withType(CodeNarc) { codeNarcTask ->
codeNarcTask.ignoreFailures = true
codeNarcTask.ignoreFailures = true
}

dependencies {
Expand Down Expand Up @@ -100,6 +99,10 @@ modifyPom {
name 'Zenedith'
email '[email protected]'
}
developer {
id 'jochenberger'
name 'Jochen Berger'
}
}
}
}
24 changes: 0 additions & 24 deletions examples/analyze/build.gradle

This file was deleted.

4 changes: 2 additions & 2 deletions examples/updates/build.gradle → examples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'versions'
apply plugin: 'com.github.ben-manes.versions'

defaultTasks 'dependencyUpdates'

buildscript {
repositories {
// Use 'gradle install' to install latest
mavenCentral()
jcenter()
mavenLocal()
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-rc-1-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class DependencyUpdates {
'org.gradle.api.internal.artifacts.version.LatestVersionSemanticComparator'
static final String COMPARATOR_18 =
'org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.ResolverStrategy'
static final String COMPARATOR_23 =
'org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.StaticVersionComparator'

Project project
String revision
Expand Down Expand Up @@ -186,11 +188,15 @@ class DependencyUpdates {
@TypeChecked(SKIP)
Comparator getVersionComparator() {
def classLoader = Thread.currentThread().getContextClassLoader()
def gradleVersion = project.gradle.gradleVersion

if (project.gradle.gradleVersion =~ /^1\.[0-7](?:[^\d]|$)/) {
if (gradleVersion =~ /^1\.[0-7](?:[^\d]|$)/) {
classLoader.loadClass(COMPARATOR_17).newInstance()
} else {
} else if ( (gradleVersion =~ /^1\.[8-9](?:[^\d]|$)/) ||
gradleVersion =~ /^2\.[0-2](?:[^\d]|$)/) {
classLoader.loadClass(COMPARATOR_18).newInstance().getVersionMatcher()
} else {
classLoader.loadClass(COMPARATOR_23).newInstance()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,85 +182,83 @@ class DependencyUpdatesSpec extends Specification {

def 'Version ranges are correctly evaluated'() {
given:
def project = singleProject()
addRepositoryTo(project)
project.configurations {
upToDate
}
project.dependencies.upToDate 'backport-util-concurrent:backport-util-concurrent:3.+'
when:
def reporter = evaluate(project)
reporter.write()
then:
with(reporter) {
unresolved.isEmpty()
upgradeVersions.isEmpty()
upToDateVersions.size() == 1
downgradeVersions.isEmpty()
}

def project = singleProject()
addRepositoryTo(project)
project.configurations {
upToDate
}
project.dependencies.upToDate 'backport-util-concurrent:backport-util-concurrent:3.+'
when:
def reporter = evaluate(project)
reporter.write()
then:
with(reporter) {
unresolved.isEmpty()
upgradeVersions.isEmpty()
upToDateVersions.size() == 1
downgradeVersions.isEmpty()
}
}

@Issue('https://github.com/ben-manes/gradle-versions-plugin/issues/26')
def 'Dependencies without versions do not cause a NPE'() {
given:
def project = singleProject()
addRepositoryTo(project)
project.configurations {
upgradesFound
}
project.dependencies.upgradesFound 'backport-util-concurrent:backport-util-concurrent'
when:
def reporter = evaluate(project)
reporter.write()
then:
with(reporter) {
unresolved.size() == 1
upgradeVersions.isEmpty()
upToDateVersions.isEmpty()
downgradeVersions.isEmpty()
}

def project = singleProject()
addRepositoryTo(project)
project.configurations {
upgradesFound
}
project.dependencies.upgradesFound 'backport-util-concurrent:backport-util-concurrent'
when:
def reporter = evaluate(project)
reporter.write()
then:
with(reporter) {
unresolved.size() == 1
upgradeVersions.isEmpty()
upToDateVersions.isEmpty()
downgradeVersions.isEmpty()
}
}

def 'Single project with a custom Reporter'() {
given:
def project = singleProject()
addRepositoryTo(project)
addDependenciesTo(project)
Reporter customReporter = Mock()
when:
def reporter = evaluate(project, 'release', customReporter)
reporter.write()
then:
1 * customReporter.write(_) { Result result ->
result.current.count == 2
result.outdated.count == 2
result.exceeded.count == 2
result.unresolved.count == 2
}
given:
def project = singleProject()
addRepositoryTo(project)
addDependenciesTo(project)
Reporter customReporter = Mock()
when:
def reporter = evaluate(project, 'release', customReporter)
reporter.write()
then:
1 * customReporter.write(_) { Result result ->
result.current.count == 2
result.outdated.count == 2
result.exceeded.count == 2
result.unresolved.count == 2
}
}

def 'Single project with a Closure as Reporter'() {
given:
def project = singleProject()
addRepositoryTo(project)
addDependenciesTo(project)
int current = -1
int outdated = -1
int exceeded = -1
int unresolved = -1

def customReporter = { result ->
current = result.current.count
outdated = result.outdated.count
exceeded = result.exceeded.count
unresolved = result.unresolved.count

}
def project = singleProject()
addRepositoryTo(project)
addDependenciesTo(project)
int current = -1
int outdated = -1
int exceeded = -1
int unresolved = -1
def customReporter = { result ->
current = result.current.count
outdated = result.outdated.count
exceeded = result.exceeded.count
unresolved = result.unresolved.count
}
when:
def reporter = evaluate(project, 'release', customReporter)
reporter.write()
def reporter = evaluate(project, 'release', customReporter)
reporter.write()
then:
current == 2
outdated == 2
Expand Down

0 comments on commit 60dcf4f

Please sign in to comment.