Refactoring code.

* remove debugging statements
* Move each class so it's one name-per-file
* Migrate out of org.apache namespace into sbt.mavenint
This commit is contained in:
Josh Suereth 2015-01-12 14:48:23 -05:00
parent e9085b79d1
commit a0f6662500
5 changed files with 13 additions and 12 deletions

View File

@ -1,9 +1,9 @@
package sbt;
package sbt.mavenint;
/**
* Extra properties we dump from Aether into the properties list.
*/
public class SbtExtraProperties {
public class SbtPomExtraProperties {
public static final String MAVEN_PACKAGING_KEY = "sbt.pom.packaging";
public static final String SCALA_VERSION_KEY = "sbt.pom.scalaversion";

View File

@ -12,8 +12,7 @@ import org.apache.ivy.util.extendable.ExtendableItem
import java.io.{ File, InputStream }
import java.net.URL
import java.util.regex.Pattern
import org.apache.maven.repository.internal.{ PomExtraDependencyAttributes }
import sbt.mavenint.{ PomExtraDependencyAttributes, SbtPomExtraProperties }
@deprecated("0.13.8", "We now use an Aether-based pom parser.")
final class CustomPomParser(delegate: ModuleDescriptorParser, transform: (ModuleDescriptorParser, ModuleDescriptor) => ModuleDescriptor) extends ModuleDescriptorParser {
@ -36,8 +35,8 @@ object CustomPomParser {
ReplaceMavenConfigurationMappings.init()
/** The key prefix that indicates that this is used only to store extra information and is not intended for dependency resolution.*/
val InfoKeyPrefix = SbtExtraProperties.POM_INFO_KEY_PREFIX
val ApiURLKey = SbtExtraProperties.POM_API_KEY
val InfoKeyPrefix = SbtPomExtraProperties.POM_INFO_KEY_PREFIX
val ApiURLKey = SbtPomExtraProperties.POM_API_KEY
val SbtVersionKey = PomExtraDependencyAttributes.SbtVersionKey
val ScalaVersionKey = PomExtraDependencyAttributes.ScalaVersionKey

View File

@ -9,7 +9,7 @@ package sbt
import java.io.File
import org.apache.maven.repository.internal.PomExtraDependencyAttributes
import sbt.mavenint.PomExtraDependencyAttributes
// Node needs to be renamed to XNode because the task subproject contains a Node type that will shadow
// scala.xml.Node when generating aggregated API documentation

View File

@ -5,6 +5,8 @@ package sbt
import java.net.URL
import sbt.mavenint.SbtPomExtraProperties
final case class ModuleID(organization: String, name: String, revision: String, configurations: Option[String] = None, isChanging: Boolean = false, isTransitive: Boolean = true, isForce: Boolean = false, explicitArtifacts: Seq[Artifact] = Nil, exclusions: Seq[ExclusionRule] = Nil, extraAttributes: Map[String, String] = Map.empty, crossVersion: CrossVersion = CrossVersion.Disabled) {
override def toString: String =
organization + ":" + name + ":" + revision +
@ -15,7 +17,7 @@ final case class ModuleID(organization: String, name: String, revision: String,
def extraString: String = extraDependencyAttributes.map { case (k, v) => k + "=" + v } mkString ("(", ", ", ")")
/** Returns the extra attributes except for ones marked as information only (ones that typically would not be used for dependency resolution). */
def extraDependencyAttributes: Map[String, String] = extraAttributes.filterKeys(!_.startsWith(SbtExtraProperties.POM_INFO_KEY_PREFIX))
def extraDependencyAttributes: Map[String, String] = extraAttributes.filterKeys(!_.startsWith(SbtPomExtraProperties.POM_INFO_KEY_PREFIX))
@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)

View File

@ -1,4 +1,4 @@
package org.apache.maven.repository.internal
package sbt.mavenint
import java.util.Properties
import java.util.regex.Pattern
@ -31,7 +31,7 @@ object PomExtraDependencyAttributes {
* A map of module id to extra dependency attributes associated with dependencies on that module.
*/
def readFromAether(props: java.util.Map[String, AnyRef]): Map[ModuleRevisionId, Map[String, String]] = {
import collection.JavaConverters._
import scala.collection.JavaConverters._
(props.asScala get ExtraAttributesKey) match {
case None => Map.empty
case Some(str) =>
@ -71,7 +71,7 @@ object PomExtraDependencyAttributes {
}
def qualifiedExtra(item: ExtendableItem): Map[String, String] = {
import collection.JavaConverters._
import scala.collection.JavaConverters._
item.getQualifiedExtraAttributes.asInstanceOf[java.util.Map[String, String]].asScala.toMap
}
def filterCustomExtra(item: ExtendableItem, include: Boolean): Map[String, String] =
@ -83,7 +83,7 @@ object PomExtraDependencyAttributes {
// This makes the id suitable as a key to associate a dependency parsed from a <dependency> element
// with the extra attributes from the <properties> section
def simplify(id: ModuleRevisionId): ModuleRevisionId = {
import collection.JavaConverters._
import scala.collection.JavaConverters._
ModuleRevisionId.newInstance(id.getOrganisation, id.getName, id.getBranch, id.getRevision, filterCustomExtra(id, include = false).asJava)
}