Fix additional warnings

This commit is contained in:
Pierre DAL-PRA 2015-08-07 00:23:14 +02:00
parent b184c111b7
commit 1b90c865d1
3 changed files with 14 additions and 21 deletions

View File

@ -7,14 +7,14 @@ import java.util.Date
import org.apache.ivy.core.settings.IvySettings import org.apache.ivy.core.settings.IvySettings
import org.apache.ivy.core.{ IvyContext, LogOptions } import org.apache.ivy.core.{ IvyContext, LogOptions }
import org.apache.ivy.core.module.descriptor.{ Artifact => IArtifact, DefaultModuleDescriptor, DefaultDependencyDescriptor, ModuleDescriptor, DependencyDescriptor } import org.apache.ivy.core.module.descriptor.{ Artifact => IArtifact, DefaultModuleDescriptor, ModuleDescriptor, DependencyDescriptor }
import org.apache.ivy.core.resolve.{ ResolvedModuleRevision, ResolveData } import org.apache.ivy.core.resolve.{ ResolvedModuleRevision, ResolveData }
import org.apache.ivy.plugins.latest.LatestStrategy import org.apache.ivy.plugins.latest.LatestStrategy
import org.apache.ivy.plugins.repository.file.{ FileRepository => IFileRepository, FileResource } import org.apache.ivy.plugins.repository.file.{ FileRepository => IFileRepository, FileResource }
import org.apache.ivy.plugins.repository.url.URLResource import org.apache.ivy.plugins.repository.url.URLResource
import org.apache.ivy.plugins.resolver._ import org.apache.ivy.plugins.resolver._
import org.apache.ivy.plugins.resolver.util.{ HasLatestStrategy, ResolvedResource } import org.apache.ivy.plugins.resolver.util.{ HasLatestStrategy, ResolvedResource }
import org.apache.ivy.util.{ Message, MessageLogger, StringUtils => IvyStringUtils } import org.apache.ivy.util.{ Message, StringUtils => IvyStringUtils }
private[sbt] case class SbtChainResolver( private[sbt] case class SbtChainResolver(
name: String, name: String,
@ -88,9 +88,9 @@ private[sbt] case class SbtChainResolver(
// - If `isReturnFirst` is true, you return the first value found // - If `isReturnFirst` is true, you return the first value found
// - If not, we will ATTEMPT to look at the publish date, which is not correctly discovered for Maven modules and // - If not, we will ATTEMPT to look at the publish date, which is not correctly discovered for Maven modules and
// leads to undefined behavior. // leads to undefined behavior.
val useLatest = (dd.isChanging || (IvySbt.isChanging(dd.getDependencyRevisionId))) && updateOptions.latestSnapshots val useLatest = (dd.isChanging || IvySbt.isChanging(dd.getDependencyRevisionId)) && updateOptions.latestSnapshots
if (useLatest) { if (useLatest) {
Message.verbose(s"${getName} is changing. Checking all resolvers on the chain") Message.verbose(s"$getName is changing. Checking all resolvers on the chain")
} }
val data = new ResolveData(data0, doValidate(data0)) val data = new ResolveData(data0, doValidate(data0))
// Returns the value if we've already been resolved from some other branch of the resolution tree. // Returns the value if we've already been resolved from some other branch of the resolution tree.
@ -146,7 +146,7 @@ private[sbt] case class SbtChainResolver(
Left(ex) Left(ex)
} finally { } finally {
oldLatest map { _ => doSetLatestStrategy(resolver, oldLatest) } oldLatest map { _ => doSetLatestStrategy(resolver, oldLatest) }
checkInterrupted checkInterrupted()
} }
} }
} }
@ -179,7 +179,7 @@ private[sbt] case class SbtChainResolver(
} }
}).reverse.headOption map { }).reverse.headOption map {
case (rmr, resolver) => case (rmr, resolver) =>
Message.warn(s"Choosing ${resolver} for ${rmr.getId}") Message.warn(s"Choosing $resolver for ${rmr.getId}")
// Now that we know the real latest revision, let's force Ivy to use it // Now that we know the real latest revision, let's force Ivy to use it
val artifactOpt = findFirstArtifactRef(rmr.getDescriptor, dd, data, resolver) val artifactOpt = findFirstArtifactRef(rmr.getDescriptor, dd, data, resolver)
artifactOpt match { artifactOpt match {
@ -191,7 +191,7 @@ private[sbt] case class SbtChainResolver(
case Some(artifactRef) => case Some(artifactRef) =>
val systemMd = toSystem(rmr.getDescriptor) val systemMd = toSystem(rmr.getDescriptor)
getRepositoryCacheManager.cacheModuleDescriptor(resolver, artifactRef, getRepositoryCacheManager.cacheModuleDescriptor(resolver, artifactRef,
toSystem(dd), systemMd.getAllArtifacts().head, None.orNull, getCacheOptions(data)) toSystem(dd), systemMd.getAllArtifacts.head, None.orNull, getCacheOptions(data))
} }
rmr rmr
} }
@ -223,7 +223,7 @@ private[sbt] case class SbtChainResolver(
case r: FileResource => case r: FileResource =>
try { try {
val parser = rmr.getDescriptor.getParser val parser = rmr.getDescriptor.getParser
val md = parser.parseDescriptor(settings, r.getFile.toURL, r, false) val md = parser.parseDescriptor(settings, r.getFile.toURI.toURL, r, false)
Some(new ResolvedModuleRevision(resolver, resolver, md, rmr.getReport, true)) Some(new ResolvedModuleRevision(resolver, resolver, md, rmr.getReport, true))
} catch { } catch {
case _: ParseException => None case _: ParseException => None
@ -246,7 +246,7 @@ private[sbt] case class SbtChainResolver(
Option(artifact.getUrl) map { url => Option(artifact.getUrl) map { url =>
Message.verbose("\tusing url for " + artifact + ": " + url) Message.verbose("\tusing url for " + artifact + ": " + url)
val resource = val resource =
if ("file" == url.getProtocol) new FileResource(new IFileRepository(), new File(url.getPath())) if ("file" == url.getProtocol) new FileResource(new IFileRepository(), new File(url.getPath))
else new URLResource(url) else new URLResource(url)
new ResolvedResource(resource, artifact.getModuleRevisionId.getRevision) new ResolvedResource(resource, artifact.getModuleRevisionId.getRevision)
} }
@ -262,7 +262,7 @@ private[sbt] case class SbtChainResolver(
artifactRef(af, data.getDate).toIterator artifactRef(af, data.getDate).toIterator
} }
} }
if (artifactRefs.hasNext) Some(artifactRefs.next) if (artifactRefs.hasNext) Some(artifactRefs.next())
else None else None
} }
/** Ported from ChainResolver#forcedRevision. */ /** Ported from ChainResolver#forcedRevision. */

View File

@ -4,7 +4,6 @@ import Path._, Configurations._
import java.io.File import java.io.File
import org.specs2._ import org.specs2._
import cross.CrossVersionUtil import cross.CrossVersionUtil
import sbt.PublishConfiguration
import sbt.ivyint.SbtChainResolver import sbt.ivyint.SbtChainResolver
trait BaseIvySpecification extends Specification { trait BaseIvySpecification extends Specification {
@ -59,15 +58,9 @@ trait BaseIvySpecification extends Specification {
IvyActions.updateEither(module, config, UnresolvedWarningConfiguration(), LogicalClock.unknown, Some(currentDependency), log) IvyActions.updateEither(module, config, UnresolvedWarningConfiguration(), LogicalClock.unknown, Some(currentDependency), log)
} }
def cleanIvyCache: Unit = def cleanIvyCache(): Unit = IO.delete(currentTarget / "cache")
{
IO.delete(currentTarget / "cache")
}
def cleanCachedResolutionCache(module: IvySbt#Module): Unit = def cleanCachedResolutionCache(module: IvySbt#Module): Unit = IvyActions.cleanCachedResolutionCache(module, log)
{
IvyActions.cleanCachedResolutionCache(module, log)
}
def ivyUpdate(module: IvySbt#Module) = def ivyUpdate(module: IvySbt#Module) =
ivyUpdateEither(module) match { ivyUpdateEither(module) match {

View File

@ -28,7 +28,7 @@ class CachedResolutionSpec extends BaseIvySpecification {
import ShowLines._ import ShowLines._
def e1 = { def e1 = {
cleanIvyCache cleanIvyCache()
val m = module(ModuleID("com.example", "foo", "0.1.0", Some("compile")), val m = module(ModuleID("com.example", "foo", "0.1.0", Some("compile")),
Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true)) Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true))
val report = ivyUpdate(m) val report = ivyUpdate(m)
@ -67,7 +67,7 @@ class CachedResolutionSpec extends BaseIvySpecification {
// #2046 says that netty:3.2.0.Final is incorrectly evicted by netty:3.2.1.Final // #2046 says that netty:3.2.0.Final is incorrectly evicted by netty:3.2.1.Final
def e3 = { def e3 = {
// log.setLevel(Level.Debug) // log.setLevel(Level.Debug)
cleanIvyCache cleanIvyCache()
val m = module(ModuleID("com.example", "foo", "0.3.0", Some("compile")), val m = module(ModuleID("com.example", "foo", "0.3.0", Some("compile")),
Seq(avro177, dataAvro1940, netty320), Seq(avro177, dataAvro1940, netty320),
Some("2.10.2"), UpdateOptions().withCachedResolution(true)) Some("2.10.2"), UpdateOptions().withCachedResolution(true))