From 403383d7cfb9da66278248b9a98b94ea27427d20 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Tue, 28 Feb 2012 15:18:46 +0530 Subject: [PATCH] Added support for providing basic SCM info Sonatype OSS repo (where many libraries are expected to migrate) requires populating SCM info in additional to what is already provisioned for populating in SBT. We now support populating the basic SCM info as thus: ``` // Usual scmInfo := Some(ScmInfo(url("https://github.com/foo/project"), "scm:git:https://github.com/foo/project.git")) // Also add scmInfo := Some(ScmInfo(url("https://github.com/foo/project"), "scm:git:https://github.com/foo/project.git", Some("dev_connection"))) ``` For anything more esoteric than the basic info, there is always `pomPostProcess` :) --- ivy/IvyInterface.scala | 10 ++++++---- ivy/MakePom.scala | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ivy/IvyInterface.scala b/ivy/IvyInterface.scala index 5b90fd141..be3d2cd3d 100644 --- a/ivy/IvyInterface.scala +++ b/ivy/IvyInterface.scala @@ -17,9 +17,9 @@ final case class ModuleID(organization: String, name: String, revision: String, (if(extraAttributes.isEmpty) "" else " " + extraString) def extraString = extraAttributes.map { case (k,v) => k + "=" + v } mkString("(",", ",")") - @deprecated("Use the variant accepting a CrossVersion value constructed by a member of the CrossVersion object.", "0.12.0") + @deprecated("Use `cross(CrossVersion)`, the variant accepting a CrossVersion value constructed by a member of the CrossVersion object instead.", "0.12.0") def cross(v: Boolean): ModuleID = cross(if(v) CrossVersion.binary else CrossVersion.Disabled) - @deprecated("Use the variant accepting a CrossVersion value constructed by a member of the CrossVersion object.", "0.12.0") + @deprecated("Use `cross(CrossVersion)`, the variant accepting a CrossVersion value constructed by a member of the CrossVersion object instead.", "0.12.0") def cross(v: Boolean, verRemap: String => String): ModuleID = cross(if(v) CrossVersion.binaryMapped(verRemap) else CrossVersion.Disabled) def cross(v: CrossVersion): ModuleID = copy(crossVersion = v) @@ -49,13 +49,15 @@ object ModuleID if(key.startsWith("e:")) (key, value) else ("e:" + key, value) } /** Additional information about a project module */ -case class ModuleInfo(nameFormal: String, description: String = "", homepage: Option[URL] = None, startYear: Option[Int] = None, licenses: Seq[(String, URL)] = Nil, organizationName: String = "", organizationHomepage: Option[URL] = None) +case class ModuleInfo(nameFormal: String, description: String = "", homepage: Option[URL] = None, startYear: Option[Int] = None, licenses: Seq[(String, URL)] = Nil, organizationName: String = "", organizationHomepage: Option[URL] = None, scmInfo: Option[ScmInfo] = None) { def formally(name: String) = copy(nameFormal = name) def describing(desc: String, home: Option[URL]) = copy(description = desc, homepage = home) def licensed(lics: (String, URL)*) = copy(licenses = lics) def organization(name: String, home: Option[URL]) = copy(organizationName = name, organizationHomepage = home) } +/** Basic SCM information for a project module */ +case class ScmInfo(browseUrl: URL, connection: String, devConnection: Option[String] = None) /** Rule to exclude unwanted dependencies pulled in transitively by a module. */ case class ExclusionRule(organization: String = "*", name: String = "*", artifact: String = "*", configurations: Seq[String] = Nil) sealed trait Resolver @@ -428,7 +430,7 @@ object Artifact } def artifactName(scalaVersion: ScalaVersion, module: ModuleID, artifact: Artifact): String = { - import artifact._ + import artifact._ val classifierStr = classifier match { case None => ""; case Some(c) => "-" + c } val cross = CrossVersion(module.crossVersion, scalaVersion.full, scalaVersion.binary) val base = CrossVersion.applyCross(artifact.name, cross) diff --git a/ivy/MakePom.scala b/ivy/MakePom.scala index e2b5f1778..31a83a705 100644 --- a/ivy/MakePom.scala +++ b/ivy/MakePom.scala @@ -44,6 +44,7 @@ class MakePom(val log: Logger) {moduleInfo.nameFormal} { makeStartYear(moduleInfo) } { makeOrganization(moduleInfo) } + { makeScmInfo(moduleInfo) } { extra } { val deps = depsInConfs(module, configurations) @@ -83,6 +84,21 @@ class MakePom(val log: Logger) }} } + def makeScmInfo(moduleInfo: ModuleInfo): NodeSeq = + { + moduleInfo.scmInfo match { + case Some(s) => + + {s.browseUrl} + {s.connection} + {s.devConnection match { + case Some(d) => {d} + case _ => NodeSeq.Empty + }} + + case _ => NodeSeq.Empty + } + } def makeProperties(module: ModuleDescriptor, dependencies: Seq[DependencyDescriptor]): NodeSeq = { val extra = IvySbt.getExtraAttributes(module)