Add workaround (and warning message) for when ChainResolver gets a null publication date while we investigate other issues.

* Attempt to set publication date to last modified time, if the stars align
* Issue warning about undefined resolution behavior otherwise
* Add scripted test which exercises the NPE issue in resolving -SNAPSHOTs.
* Commit scalariform style edit in Act.scala

* After parsing and transforming the pom, check for pub date.
* If we don't have a pub date, try to grab lastModified from the URL
* If we can't do anything, issue a warning about the problem artifact.
This commit is contained in:
Josh Suereth 2014-09-24 14:41:32 -04:00
parent 704d823849
commit 7e100a0fe0
2 changed files with 24 additions and 3 deletions

View File

@ -54,7 +54,8 @@ object CustomPomParser {
lazy val registerDefault: Unit = ModuleDescriptorParserRegistry.getInstance.addParser(default) lazy val registerDefault: Unit = ModuleDescriptorParserRegistry.getInstance.addParser(default)
def defaultTransform(parser: ModuleDescriptorParser, md: ModuleDescriptor): ModuleDescriptor = def defaultTransform(parser: ModuleDescriptorParser, md: ModuleDescriptor): ModuleDescriptor =
if (transformedByThisVersion(md)) md else defaultTransformImpl(parser, md) if (transformedByThisVersion(md)) md
else defaultTransformImpl(parser, md)
private[this] def transformedByThisVersion(md: ModuleDescriptor): Boolean = private[this] def transformedByThisVersion(md: ModuleDescriptor): Boolean =
{ {

View File

@ -7,7 +7,7 @@ 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.{ ModuleDescriptor, DependencyDescriptor, Artifact => IArtifact } import org.apache.ivy.core.module.descriptor.{ Artifact => IArtifact, DefaultModuleDescriptor, DefaultDependencyDescriptor, 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 }
@ -94,6 +94,23 @@ class SbtChainResolver(name: String, resolvers: Seq[DependencyResolver], setting
} }
else temp map { x => (forcedRevision(x), resolver) } else temp map { x => (forcedRevision(x), resolver) }
) )
retval match {
case Right(Some((rmr, _))) =>
rmr.getDescriptor.getPublicationDate match {
case null =>
val ivf = resolver.findIvyFileRef(dd, data)
val lmd = new java.util.Date(ivf.getLastModified)
rmr.getDescriptor match {
case dmd: DefaultModuleDescriptor =>
Message.info(s"Getting null publication date from resolver: ${resolver} for ${rmr.getId}, setting to: ${lmd}")
dmd.setPublicationDate(lmd)
case _ =>
Message.warn(s"Getting null publication date from resolver: ${resolver} for ${rmr.getId}, resolution order is undefined!")
}
case _ => // All other cases ok
}
case _ =>
}
retval retval
} catch { } catch {
case ex: Exception => case ex: Exception =>
@ -111,7 +128,10 @@ class SbtChainResolver(name: String, resolvers: Seq[DependencyResolver], setting
val sorted = val sorted =
if (useLatest) (foundRevisions.sortBy { if (useLatest) (foundRevisions.sortBy {
case (rmr, _) => case (rmr, _) =>
rmr.getDescriptor.getPublicationDate.getTime rmr.getDescriptor.getPublicationDate match {
case null => 0L
case d => d.getTime
}
}).reverse.headOption map { }).reverse.headOption map {
case (rmr, resolver) => case (rmr, resolver) =>
// 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