Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
[#21] Fixes following code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Catalin Buleandra committed Mar 1, 2015
1 parent df7b739 commit cc76e6e
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 37 deletions.
12 changes: 6 additions & 6 deletions src/main/groovy/com/ofg/uptodate/UptodatePlugin.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.ofg.uptodate

import com.ofg.uptodate.finder.*
import com.ofg.uptodate.finder.Dependency
import com.ofg.uptodate.finder.JCenterNewVersionFinderFactory
import com.ofg.uptodate.finder.MavenNewVersionFinderFactory
import com.ofg.uptodate.finder.NewVersionFinderInAllRepositories
import groovy.util.logging.Slf4j
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -9,9 +12,6 @@ import org.gradle.api.artifacts.Configuration

import javax.inject.Inject

import static com.ofg.uptodate.finder.NewVersionFinder.jCenterNewVersionFinder
import static com.ofg.uptodate.finder.NewVersionFinder.mavenNewVersionFinder

@Slf4j
class UptodatePlugin implements Plugin<Project> {
public static final String TASK_NAME = 'uptodate'
Expand All @@ -35,8 +35,8 @@ class UptodatePlugin implements Plugin<Project> {
printMissingJCenterRepoIfApplicable(uptodatePluginExtension, project)
NewVersionFinderInAllRepositories newVersionFinder = new NewVersionFinderInAllRepositories(loggerProxy,
[
mavenNewVersionFinder(loggerProxy, uptodatePluginExtension),
jCenterNewVersionFinder(loggerProxy, uptodatePluginExtension)
new MavenNewVersionFinderFactory(loggerProxy).build(uptodatePluginExtension),
new JCenterNewVersionFinderFactory(loggerProxy).build(uptodatePluginExtension)
])
List<Dependency> dependencies = getDependencies(project)
Set<Dependency> dependenciesWithNewVersions = newVersionFinder.findNewer(dependencies)
Expand Down
25 changes: 21 additions & 4 deletions src/main/groovy/com/ofg/uptodate/finder/FinderConfiguration.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
package com.ofg.uptodate.finder

import com.ofg.uptodate.UptodatePluginExtension
import groovy.transform.PackageScope

@PackageScope
class FinderConfiguration {

boolean ignore
HttpConnectionSettings httpConnectionSettings
List<String> excludedVersionPatterns
final boolean ignore
final HttpConnectionSettings httpConnectionSettings
final List<String> excludedVersionPatterns

FinderConfiguration(RepositorySettings repositorySettings,
UptodatePluginExtension uptodatePluginExtension) {

ignore = repositorySettings.ignoreRepo
httpConnectionSettings = new HttpConnectionSettings(
url: repositorySettings.repoUrl,
proxySettings: new ProxySettings(
hostname: uptodatePluginExtension.proxyHostname,
port: uptodatePluginExtension.proxyPort,
scheme: uptodatePluginExtension.proxyScheme
),
poolSize: uptodatePluginExtension.simultaneousHttpConnections,
timeout: uptodatePluginExtension.connectionTimeout
)
excludedVersionPatterns = uptodatePluginExtension.excludedVersionPatterns
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.ofg.uptodate.finder

import groovy.transform.Immutable
import groovy.transform.PackageScope

@PackageScope
@Immutable
class HttpConnectionSettings {

String url
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ofg.uptodate.finder

import com.ofg.uptodate.LoggerProxy
import com.ofg.uptodate.UptodatePluginExtension
import groovy.transform.PackageScope

@PackageScope
class JCenterNewVersionFinderFactory implements NewVersionFinderFactory {

final LoggerProxy loggerProxy

JCenterNewVersionFinderFactory(LoggerProxy loggerProxy) {
this.loggerProxy = loggerProxy
}

@Override
NewVersionFinder build(UptodatePluginExtension uptodatePluginExtension) {
return new NewVersionFinder(loggerProxy, new JCenterRepositorySettingsProvider(), new JCenterLatestDependenciesProvider(loggerProxy), uptodatePluginExtension);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ofg.uptodate.finder

import com.ofg.uptodate.LoggerProxy
import com.ofg.uptodate.UptodatePluginExtension
import groovy.transform.PackageScope

@PackageScope
class MavenNewVersionFinderFactory implements NewVersionFinderFactory {

final LoggerProxy loggerProxy

MavenNewVersionFinderFactory(LoggerProxy loggerProxy) {
this.loggerProxy = loggerProxy
}

@Override
NewVersionFinder build(UptodatePluginExtension uptodatePluginExtension) {
return new NewVersionFinder(loggerProxy, new MavenRepositorySettingsProvider(), new MavenLatestDependenciesProvider(loggerProxy), uptodatePluginExtension)
}
}
32 changes: 5 additions & 27 deletions src/main/groovy/com/ofg/uptodate/finder/NewVersionFinder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,12 @@ class NewVersionFinder {
private final FinderConfiguration finderConfiguration
private final LoggerProxy loggerProxy

private NewVersionFinder(LoggerProxy loggerProxy,
RepositorySettingsProvider repositorySettingsProvider,
LatestDependenciesProvider latestDependenciesProvider,
UptodatePluginExtension uptodatePluginExtension) {
NewVersionFinder(LoggerProxy loggerProxy,
RepositorySettingsProvider repositorySettingsProvider,
LatestDependenciesProvider latestDependenciesProvider,
UptodatePluginExtension uptodatePluginExtension) {

RepositorySettings repositorySettings = repositorySettingsProvider.getFrom(uptodatePluginExtension)
finderConfiguration = new FinderConfiguration(
ignore: repositorySettings.ignoreRepo,
httpConnectionSettings: new HttpConnectionSettings(
url: repositorySettings.repoUrl,
proxySettings: new ProxySettings(
hostname: uptodatePluginExtension.proxyHostname,
port: uptodatePluginExtension.proxyPort,
scheme: uptodatePluginExtension.proxyScheme
),
poolSize: uptodatePluginExtension.simultaneousHttpConnections,
timeout: uptodatePluginExtension.connectionTimeout
),
excludedVersionPatterns: uptodatePluginExtension.excludedVersionPatterns
)
finderConfiguration = new FinderConfiguration(repositorySettingsProvider.getFrom(uptodatePluginExtension), uptodatePluginExtension)
this.latestDependenciesProvider = latestDependenciesProvider
this.loggerProxy = loggerProxy
}
Expand All @@ -46,12 +32,4 @@ class NewVersionFinder {
loggerProxy.debug(log, "Newer dependencies found in $finderConfiguration.httpConnectionSettings.url $newerDependencies")
return newerDependencies
}

static NewVersionFinder mavenNewVersionFinder(LoggerProxy loggerProxy, UptodatePluginExtension uptodatePluginExtension) {
return new NewVersionFinder(loggerProxy, new MavenRepositorySettingsProvider(), new MavenLatestDependenciesProvider(loggerProxy), uptodatePluginExtension);
}

static NewVersionFinder jCenterNewVersionFinder(LoggerProxy loggerProxy, UptodatePluginExtension uptodatePluginExtension) {
return new NewVersionFinder(loggerProxy, new JCenterRepositorySettingsProvider(), new JCenterLatestDependenciesProvider(loggerProxy), uptodatePluginExtension);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.ofg.uptodate.finder

import com.ofg.uptodate.UptodatePluginExtension

interface NewVersionFinderFactory {

NewVersionFinder build(UptodatePluginExtension uptodatePluginExtension)
}
2 changes: 2 additions & 0 deletions src/main/groovy/com/ofg/uptodate/finder/ProxySettings.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.ofg.uptodate.finder

import groovy.transform.Immutable
import groovy.transform.PackageScope

@PackageScope
@Immutable
class ProxySettings {

String hostname
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.ofg.uptodate.finder

import groovy.transform.Immutable
import groovy.transform.PackageScope

@PackageScope
@Immutable
class RepositorySettings {

String repoUrl
Expand Down

0 comments on commit cc76e6e

Please sign in to comment.