2010-09-22 04:10:21 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
|
|
|
|
* Copyright 2009,2010 Mark Harrah
|
|
|
|
|
*/
|
|
|
|
|
package sbt
|
|
|
|
|
package impl
|
|
|
|
|
|
2011-11-16 09:34:16 +01:00
|
|
|
import StringUtilities.nonEmpty
|
2010-09-22 04:10:21 +02:00
|
|
|
|
|
|
|
|
trait DependencyBuilders
|
|
|
|
|
{
|
|
|
|
|
final implicit def toGroupID(groupID: String): GroupID =
|
|
|
|
|
{
|
|
|
|
|
nonEmpty(groupID, "Group ID")
|
|
|
|
|
new GroupID(groupID)
|
|
|
|
|
}
|
|
|
|
|
final implicit def toRepositoryName(name: String): RepositoryName =
|
|
|
|
|
{
|
|
|
|
|
nonEmpty(name, "Repository name")
|
|
|
|
|
new RepositoryName(name)
|
|
|
|
|
}
|
|
|
|
|
final implicit def moduleIDConfigurable(m: ModuleID): ModuleIDConfigurable =
|
|
|
|
|
{
|
|
|
|
|
require(m.configurations.isEmpty, "Configurations already specified for module " + m)
|
|
|
|
|
new ModuleIDConfigurable(m)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final class GroupID private[sbt] (groupID: String)
|
|
|
|
|
{
|
2011-11-16 09:34:16 +01:00
|
|
|
def % (artifactID: String) = groupArtifact(artifactID, None)
|
|
|
|
|
def %% (artifactID: String, crossVersion: String => String = identity) = groupArtifact(artifactID, Some(crossVersion))
|
|
|
|
|
def %% (artifactID: String, alternatives: (String, String)*) = groupArtifact(artifactID, Some(Map(alternatives: _*) orElse { case s => s }))
|
|
|
|
|
private def groupArtifact(artifactID: String, cross: Option[String => String]) =
|
2010-09-22 04:10:21 +02:00
|
|
|
{
|
|
|
|
|
nonEmpty(artifactID, "Artifact ID")
|
|
|
|
|
new GroupArtifactID(groupID, artifactID, cross)
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-16 09:34:16 +01:00
|
|
|
final class GroupArtifactID private[sbt] (groupID: String, artifactID: String, crossVersion: Option[String => String])
|
|
|
|
|
{
|
2010-09-22 04:10:21 +02:00
|
|
|
def % (revision: String): ModuleID =
|
|
|
|
|
{
|
|
|
|
|
nonEmpty(revision, "Revision")
|
2011-11-16 09:34:16 +01:00
|
|
|
ModuleID(groupID, artifactID, revision).cross(!crossVersion.isEmpty, crossVersion.getOrElse(identity))
|
2010-09-22 04:10:21 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
final class ModuleIDConfigurable private[sbt] (moduleID: ModuleID)
|
|
|
|
|
{
|
|
|
|
|
def % (configurations: String): ModuleID =
|
|
|
|
|
{
|
|
|
|
|
nonEmpty(configurations, "Configurations")
|
|
|
|
|
val c = configurations
|
|
|
|
|
moduleID.copy(configurations = Some(c))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
final class RepositoryName private[sbt] (name: String)
|
|
|
|
|
{
|
|
|
|
|
def at (location: String) =
|
|
|
|
|
{
|
|
|
|
|
nonEmpty(location, "Repository location")
|
|
|
|
|
new MavenRepository(name, location)
|
|
|
|
|
}
|
|
|
|
|
}
|