Permalink
Browse files

Fixes from mark's suggestions.

* Puppies may rest easy from the removal of Option.get calls.
* better names for config values
* Added a helper method to avoid any possible code duplication, besides repeated def, val, match and for keywords.
  Looking for ways to remove this duplciation ASAP.
* Moved from pattern match to ._1, my most hated member.
  • Loading branch information...
1 parent 8bca690 commit 76d24091fa2a81ff6ed3d51f99a4ffed452b1eef @jsuereth jsuereth committed with May 31, 2012
@@ -47,7 +47,7 @@ object ConfigurationParser
}
class ConfigurationParser
{
- def apply(file: File): LaunchConfiguration = Using(new InputStreamReader(new FileInputStream(file), "UTF-8"))(apply)
+ def apply(file: File): LaunchConfiguration = Using(newReader(file))(apply)
def apply(s: String): LaunchConfiguration = Using(new StringReader(s))(apply)
def apply(reader: Reader): LaunchConfiguration = Using(new BufferedReader(reader))(apply)
private def apply(in: BufferedReader): LaunchConfiguration =
@@ -57,16 +57,15 @@ class ConfigurationParser
case null => accum.reverse
case line => readLine(in, ParseLine(line,index) ::: accum, index+1)
}
+ private def newReader(file: File) = new InputStreamReader(new FileInputStream(file), "UTF-8")
def readRepositoriesConfig(file: File): List[xsbti.Repository] =
- Using(new InputStreamReader(new FileInputStream(file), "UTF-8"))(readRepositoriesConfig)
+ Using(newReader(file))(readRepositoriesConfig)
def readRepositoriesConfig(reader: Reader): List[xsbti.Repository] =
Using(new BufferedReader(reader))(readRepositoriesConfig)
private def readRepositoriesConfig(in: BufferedReader): List[xsbti.Repository] =
processRepositoriesConfig(processLines(readLine(in, Nil, 0)))
def processRepositoriesConfig(sections: SectionMap): List[xsbti.Repository] =
- processSection(sections, "repositories", getRepositories) match {
- case (repositories, _) => repositories
- }
+ processSection(sections, "repositories", getRepositories)._1
// section -> configuration instance processing
def processSections(sections: SectionMap): LaunchConfiguration =
{
@@ -135,8 +134,8 @@ class ConfigurationParser
{
val (ivyHome, m1) = optfile(m, "ivy-home")
val (checksums, m2) = ids(m1, "checksums", BootConfiguration.DefaultChecksums)
- val (overrideRepos, m3) = bool(m2, "override-build", false)
- val (repoConfig, m4) = optfile(m3, "resolver-config")
+ val (overrideRepos, m3) = bool(m2, "override-build-repos", false)
+ val (repoConfig, m4) = optfile(m3, "repository-config")
check(m4, "label")
(ivyHome, checksums, overrideRepos, repoConfig filter (_.exists))
}
@@ -21,5 +21,5 @@ ${{repositories}}
[ivy]
ivy-home: ${sbt.ivy.home-${user.home}/.ivy2/}
checksums: ${sbt.checksums-sha1,md5}
- override-build: ${sbt.override.build.repos-false}
- resolver-config: ${sbt.resolver.config-${sbt.global.base-${user.home}/.sbt}/repositories}
+ override-build-repos: ${sbt.override.build.repos-false}
+ repository-config: ${sbt.resolver.config-${sbt.global.base-${user.home}/.sbt}/repositories}
View
@@ -786,10 +786,11 @@ object Classpaths
},
bootResolvers <<= appConfiguration map bootRepositories,
fullResolvers <<= (projectResolver,externalResolvers,sbtPlugin,sbtResolver,bootResolvers,overrideBuildResolvers) map { (proj,rs,isPlugin,sbtr, boot, overrideFlag) =>
- if(overrideFlag && boot.isDefined) boot.get
- else {
- val base = if(isPlugin) sbtr +: sbtPluginReleases +: rs else rs
- proj +: base
+ boot match {
+ case Some(repos) if overrideFlag => repos
+ case _ =>
+ val base = if(isPlugin) sbtr +: sbtPluginReleases +: rs else rs
+ proj +: base
}
},
offline in GlobalScope :== false,

0 comments on commit 76d2409

Please sign in to comment.