Skip to content

Commit

Permalink
Mark compat functions private
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Jan 5, 2025
1 parent 61bdb2b commit 2a20c60
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
40 changes: 20 additions & 20 deletions src/main/scala-2.12/com/typesafe/sbt/packager/PluginCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,36 @@ object PluginCompat {
type Out = java.io.File
type IncludeArtifact = Artifact => Boolean

val artifactStr = sbt.Keys.artifact.key
val moduleIDStr = sbt.Keys.moduleID.key
def parseModuleIDStrAttribute(m: ModuleID): ModuleID = m
def moduleIDToStr(m: ModuleID): ModuleID = m
def parseArtifactStrAttribute(a: Artifact): Artifact = a
def artifactToStr(art: Artifact): Artifact = art
private[packager] val artifactStr = sbt.Keys.artifact.key
private[packager] val moduleIDStr = sbt.Keys.moduleID.key
private[packager] def parseModuleIDStrAttribute(m: ModuleID): ModuleID = m
private[packager] def moduleIDToStr(m: ModuleID): ModuleID = m
private[packager] def parseArtifactStrAttribute(a: Artifact): Artifact = a
private[packager] def artifactToStr(art: Artifact): Artifact = art

def toNioPath(a: Attributed[File])(implicit conv: FileConverter): NioPath =
private[packager] def toNioPath(a: Attributed[File])(implicit conv: FileConverter): NioPath =
a.data.toPath()
def toNioPath(ref: File)(implicit conv: FileConverter): NioPath =
private[packager] def toNioPath(ref: File)(implicit conv: FileConverter): NioPath =
ref.toPath()
def toFile(a: Attributed[File])(implicit conv: FileConverter): File =
private[packager] def toFile(a: Attributed[File])(implicit conv: FileConverter): File =
a.data
def toFile(ref: File)(implicit conv: FileConverter): File =
private[packager] def toFile(ref: File)(implicit conv: FileConverter): File =
ref
def artifactPathToFile(ref: File)(implicit conv: FileConverter): File =
private[packager] def artifactPathToFile(ref: File)(implicit conv: FileConverter): File =
ref
def toArtifactPath(f: File)(implicit conv: FileConverter): ArtifactPath = f
def toNioPaths(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[NioPath] =
private[packager] def toArtifactPath(f: File)(implicit conv: FileConverter): ArtifactPath = f
private[packager] def toNioPaths(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[NioPath] =
cp.map(_.data.toPath()).toVector
def toFiles(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[File] =
private[packager] def toFiles(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[File] =
cp.map(_.data).toVector
def toFileRefsMapping(mappings: Seq[(File, String)])(implicit conv: FileConverter): Seq[(FileRef, String)] =
private[packager] def toFileRefsMapping(mappings: Seq[(File, String)])(implicit conv: FileConverter): Seq[(FileRef, String)] =
mappings
def toFileRef(x: File)(implicit conv: FileConverter): FileRef =
private[packager] def toFileRef(x: File)(implicit conv: FileConverter): FileRef =
x
def getName(ref: File): String =
private[packager] def getName(ref: File): String =
ref.getName()
def getArtifactPathName(ref: File): String =
private[packager] def getArtifactPathName(ref: File): String =
ref.getName()
def classpathAttr = Attributes.Name.CLASS_PATH
def mainclassAttr = Attributes.Name.MAIN_CLASS
private[packager] def classpathAttr = Attributes.Name.CLASS_PATH
private[packager] def mainclassAttr = Attributes.Name.MAIN_CLASS
}
44 changes: 22 additions & 22 deletions src/main/scala-3/com/typesafe/sbt/packager/PluginCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,52 @@ import sbt.*
import xsbti.{FileConverter, HashedVirtualFileRef, VirtualFile, VirtualFileRef}
import sbt.internal.RemoteCache

object PluginCompat:
object PluginCompat {
type FileRef = HashedVirtualFileRef
type ArtifactPath = VirtualFileRef
type Out = VirtualFile
type IncludeArtifact = Any => Boolean

val artifactStr = Keys.artifactStr
val moduleIDStr = Keys.moduleIDStr
def parseModuleIDStrAttribute(str: String): ModuleID =
private[packager] val artifactStr = Keys.artifactStr
private[packager] val moduleIDStr = Keys.moduleIDStr
private[packager] def parseModuleIDStrAttribute(str: String): ModuleID =
Classpaths.moduleIdJsonKeyFormat.read(str)
def moduleIDToStr(m: ModuleID): String =
private[packager] def moduleIDToStr(m: ModuleID): String =
Classpaths.moduleIdJsonKeyFormat.write(m)

def parseArtifactStrAttribute(str: String): Artifact =
private[packager] def parseArtifactStrAttribute(str: String): Artifact =
import sbt.librarymanagement.LibraryManagementCodec.ArtifactFormat
import sjsonnew.support.scalajson.unsafe.*
Converter.fromJsonUnsafe[Artifact](Parser.parseUnsafe(str))
def artifactToStr(art: Artifact): String =
private[packager] def artifactToStr(art: Artifact): String =
import sbt.librarymanagement.LibraryManagementCodec.ArtifactFormat
import sjsonnew.support.scalajson.unsafe.*
CompactPrinter(Converter.toJsonUnsafe(art))

def toNioPath(a: Attributed[HashedVirtualFileRef])(using conv: FileConverter): NioPath =
private[packager] def toNioPath(a: Attributed[HashedVirtualFileRef])(using conv: FileConverter): NioPath =
conv.toPath(a.data)
def toNioPath(ref: HashedVirtualFileRef)(using conv: FileConverter): NioPath =
private[packager] def toNioPath(ref: HashedVirtualFileRef)(using conv: FileConverter): NioPath =
conv.toPath(ref)
inline def toFile(a: Attributed[HashedVirtualFileRef])(using conv: FileConverter): File =
private[packager] def toFile(a: Attributed[HashedVirtualFileRef])(using conv: FileConverter): File =
toNioPath(a).toFile()
inline def toFile(ref: HashedVirtualFileRef)(using conv: FileConverter): File =
private[packager] def toFile(ref: HashedVirtualFileRef)(using conv: FileConverter): File =
toNioPath(ref).toFile()
def artifactPathToFile(ref: VirtualFileRef)(using conv: FileConverter): File =
private[packager] def artifactPathToFile(ref: VirtualFileRef)(using conv: FileConverter): File =
conv.toPath(ref).toFile()
def toArtifactPath(f: File)(using conv: FileConverter): ArtifactPath =
private[packager] def toArtifactPath(f: File)(using conv: FileConverter): ArtifactPath =
conv.toVirtualFile(f.toPath())
def toNioPaths(cp: Seq[Attributed[HashedVirtualFileRef]])(using conv: FileConverter): Vector[NioPath] =
private[packager] def toNioPaths(cp: Seq[Attributed[HashedVirtualFileRef]])(using conv: FileConverter): Vector[NioPath] =
cp.map(toNioPath).toVector
inline def toFiles(cp: Seq[Attributed[HashedVirtualFileRef]])(using conv: FileConverter): Vector[File] =
private[packager] def toFiles(cp: Seq[Attributed[HashedVirtualFileRef]])(using conv: FileConverter): Vector[File] =
toNioPaths(cp).map(_.toFile())
def toFileRefsMapping(mappings: Seq[(File, String)])(using conv: FileConverter): Seq[(FileRef, String)] =
private[packager] def toFileRefsMapping(mappings: Seq[(File, String)])(using conv: FileConverter): Seq[(FileRef, String)] =
mappings.map { case (f, name) => toFileRef(f) -> name }
def toFileRef(x: File)(using conv: FileConverter): FileRef =
private[packager] def toFileRef(x: File)(using conv: FileConverter): FileRef =
conv.toVirtualFile(x.toPath())
def getName(ref: FileRef): String =
private[packager] def getName(ref: FileRef): String =
ref.name()
def getArtifactPathName(ref: ArtifactPath): String =
private[packager] def getArtifactPathName(ref: ArtifactPath): String =
ref.name()
def classpathAttr: String = Attributes.Name.CLASS_PATH.toString()
def mainclassAttr: String = Attributes.Name.MAIN_CLASS.toString()
end PluginCompat
private[packager] def classpathAttr: String = Attributes.Name.CLASS_PATH.toString()
private[packager] def mainclassAttr: String = Attributes.Name.MAIN_CLASS.toString()
}

0 comments on commit 2a20c60

Please sign in to comment.