-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start modularizing cbt into libraries
this extracts certain parts of cbt into stand-alone libraries, which can be published to maven and used outside of cbt. This also adds scalariform for these parts of the code. This slows down cbt’s own build a lot because of the number of projects involved! So we’ll follow this by a bunch of performance tweak commits.
- Loading branch information
Showing
46 changed files
with
819 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cbt_internal | ||
import cbt._ | ||
import java.io._ | ||
import scala.concurrent._ | ||
import scala.concurrent.duration._ | ||
trait Library extends Scalariform with GoogleJavaFormat with DynamicOverrides with AdvancedScala{ | ||
def inceptionYear: Int | ||
def description: String | ||
def version = ??? | ||
override def compile = { | ||
googleJavaFormat() | ||
scalariform() | ||
super.compile | ||
} | ||
|
||
def publishIfChanged = newBuild[PublishIfChanged]({s""" | ||
def inceptionYear = $inceptionYear | ||
def description = ${description.quote} | ||
def apply = if(changedInMaster) publish | ||
"""}) | ||
} | ||
|
||
trait PublishIfChanged extends PackageJars with DynamicOverrides with Shared{ | ||
override def url = super.url ++ "/libraries/" ++ name | ||
|
||
def gitHash = { | ||
val p = new ProcessBuilder( | ||
"git rev-parse HEAD".split(" "): _* | ||
) | ||
.directory( projectDirectory ) | ||
.start | ||
|
||
val sout = new InputStreamReader(p.getInputStream); | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
val out = Future(blocking(Iterator.continually(sout.read).takeWhile(_ != -1).map(_.toChar).mkString)) | ||
p.waitFor | ||
val revision = Await.result( out, Duration.Inf ).trim | ||
revision | ||
} | ||
override def version = "rev-"++gitHash | ||
|
||
def changedInMaster = ( | ||
0 === | ||
new ProcessBuilder( | ||
"git diff --exit-code --quiet master..master^ .".split(" "): _* | ||
) | ||
.directory( projectDirectory ) | ||
.start | ||
.waitFor | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package cbt_build.cbt_internal.library_build_plugin | ||
import cbt._ | ||
class Build(val context: Context) extends Plugin with CbtInternal{ | ||
override def dependencies = ( | ||
super.dependencies :+ cbtInternal.shared :+ plugins.scalariform :+ plugins.googleJavaFormat | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
package cbt_build.cbt.capture_args | ||
import cbt._ | ||
class Build(val context: Context) extends BaseBuild{ | ||
import cbt_internal._ | ||
class Build(val context: Context) extends Library{ | ||
def description = ( | ||
"macro that allows you to extract a functions arguments" | ||
++" as strings in order to programmatically pass them to a stringly typed" | ||
++" api such as a process call, http or a .main method" | ||
) | ||
|
||
def inceptionYear = 2017 | ||
|
||
override def dependencies = ( | ||
super.dependencies ++ // don't forget super.dependencies here for scala-library, etc. | ||
Resolver( mavenCentral ).bind( | ||
MavenDependency( "org.scala-lang", "scala-reflect", scalaVersion ) | ||
) | ||
) | ||
|
||
override def scalacOptions = super.scalacOptions :+ "-language:experimental.macros" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package cbt_build.cbt.capture_args.build | ||
import cbt._ | ||
class Build(val context: Context) extends BuildBuild with CbtInternal{ | ||
override def dependencies = super.dependencies :+ cbtInternal.library | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.