From b639453a2483da1cba2a1b23f1dd955d05ff6ab8 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Tue, 27 Jun 2017 18:31:07 +0300 Subject: Library sources --- stage2/plugins/ExportBuildInformation.scala | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/stage2/plugins/ExportBuildInformation.scala b/stage2/plugins/ExportBuildInformation.scala index be61609..597b7d8 100644 --- a/stage2/plugins/ExportBuildInformation.scala +++ b/stage2/plugins/ExportBuildInformation.scala @@ -33,8 +33,8 @@ object BuildInformation { parentBuild: Option[String], scalacOptions: Seq[String] ) - - case class Library( name: String, jars: Seq[File] ) + + case class Library( name: String, jars: Seq[LibraryJar] ) case class BinaryDependency( name: String ) @@ -42,6 +42,14 @@ object BuildInformation { case class ScalaCompiler( version: String, jars: Seq[File] ) + case class LibraryJar( jar: File, jarType: JarType.JarType ) + + object JarType extends Enumeration { + type JarType = Value + val Binary = Value("binary") + val Source = Value("source") + } + object Project { def apply(build: BaseBuild): Project = new BuildInformationExporter(build).exportBuildInformation @@ -161,15 +169,25 @@ object BuildInformation { .flatten .distinct - private def exportLibrary(mavenDependency: BoundMavenDependency) = { - val name = formatMavenDependency(mavenDependency.mavenDependency) - val jars = (mavenDependency +: mavenDependency.transitiveDependencies) - .map(_.asInstanceOf[BoundMavenDependency].jar) - Library(name, jars) + private def exportLibrary(dependency: BoundMavenDependency) = { + val name = formatMavenDependency(dependency.mavenDependency) + val jars = (dependency +: dependency.transitiveDependencies) + .map(_.asInstanceOf[BoundMavenDependency]) + val binaryJars = jars + .map(_.jar) + .map(LibraryJar(_, JarType.Binary)) + + implicit val logger: Logger = rootBuild.context.logger + implicit val transientCache: java.util.Map[AnyRef, AnyRef] = rootBuild.context.transientCache + implicit val classLoaderCache: ClassLoaderCache = rootBuild.context.classLoaderCache + val sourceJars = jars + .map { d => d.copy(mavenDependency = d.mavenDependency.copy(classifier = Classifier.sources)).jar } + .map(LibraryJar(_, JarType.Source)) + Library(name, binaryJars ++ sourceJars) } private def exportLibrary(file: File) = - Library("CBT:" + file.getName.stripSuffix(".jar"), Seq(file)) + Library("CBT:" + file.getName.stripSuffix(".jar"), Seq(LibraryJar(file, JarType.Binary))) private def collectParentBuilds(build: BaseBuild): Seq[BaseBuild] = build.context.parentBuild @@ -245,7 +263,7 @@ object BuildInformationSerializer { private def serialize(library: BuildInformation.Library): Node = - {library.jars.map(j => {j})} + {library.jars.map(j => {j.jar})} private def serialize(compiler: BuildInformation.ScalaCompiler): Node = -- cgit v1.2.3