1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
package cbt
import java.io._
import java.nio.file._
import java.net._
import scala.collection.immutable.Seq
import java.util.concurrent.ConcurrentHashMap
object `package`{
private val lib = new BaseLib
implicit class FileExtensionMethods( file: File ){
def ++( s: String ): File = {
if(s endsWith "/") throw new Exception(
"""Trying to append a String that ends in "/" to a File would loose it. Use .stripSuffix("/") if you need to."""
)
new File( file.toString ++ s )
}
def parent = lib.realpath(file ++ "/..")
def string = file.toString
}
implicit class URLExtensionMethods( url: URL ){
def ++( s: String ): URL = new URL( url.toString ++ s )
def string = url.toString
}
implicit class BuildInterfaceExtensions(build: BuildInterface){
import build._
def triggerLoopFiles: Seq[File] = triggerLoopFilesArray.to
def crossScalaVersions: Seq[String] = crossScalaVersionsArray.to
}
implicit class ArtifactInfoExtensions(subject: ArtifactInfo){
import subject._
def str = s"$groupId:$artifactId:$version"
def show = this.getClass.getSimpleName ++ s"($str)"
}
implicit class DependencyExtensions(subject: Dependency){
import subject._
def dependencyClasspath: ClassPath = ClassPath(dependencyClasspathArray.to)
def exportedClasspath: ClassPath = ClassPath(exportedClasspathArray.to)
def classpath = exportedClasspath ++ dependencyClasspath
def dependencies: Seq[Dependency] = dependenciesArray.to
def needsUpdate: Boolean = needsUpdateCompat
}
implicit class ContextExtensions(subject: Context){
import subject._
val paths = Paths(cbtHome, cache)
implicit def logger: Logger = new Logger(enabledLoggers, start)
def classLoaderCache: ClassLoaderCache = new ClassLoaderCache(
logger,
permanentKeys,
permanentClassLoaders
)
def cbtDependency = {
import paths._
CbtDependency(cbtHasChanged, mavenCache, nailgunTarget, stage1Target, stage2Target, compatibilityTarget)
}
def args: Seq[String] = argsArray.to
def enabledLoggers: Set[String] = enabledLoggersArray.to
def scalaVersion = Option(scalaVersionOrNull)
def version = Option(versionOrNull)
def parentBuild = Option(parentBuildOrNull)
def start: scala.Long = startCompat
def cbtHasChanged: scala.Boolean = cbtHasChangedCompat
def copy(
projectDirectory: File = projectDirectory,
args: Seq[String] = args,
enabledLoggers: Set[String] = enabledLoggers,
cbtHasChanged: Boolean = cbtHasChanged,
version: Option[String] = version,
scalaVersion: Option[String] = scalaVersion,
cache: File = cache,
cbtHome: File = cbtHome,
parentBuild: Option[BuildInterface] = None
): Context = ContextImplementation(
projectDirectory,
cwd,
args.to,
enabledLoggers.to,
startCompat,
cbtHasChangedCompat,
version.getOrElse(null),
scalaVersion.getOrElse(null),
permanentKeys,
permanentClassLoaders,
cache,
cbtHome,
compatibilityTarget,
parentBuild.getOrElse(null)
)
}
}
|