Skip to content

Commit

Permalink
Merge pull request #398 from sbt/wip/jarjarabrams
Browse files Browse the repository at this point in the history
switch to jar jar abrams 0.1.0
  • Loading branch information
eed3si9n authored Jun 22, 2020
2 parents db69ab5 + 2da035d commit 074d652
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 745 deletions.
16 changes: 6 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
lazy val commonSettings: Seq[Setting[_]] = Seq(
version in ThisBuild := "0.14.11-SNAPSHOT",
organization in ThisBuild := "com.eed3si9n"
)
ThisBuild / version := "0.14.11-SNAPSHOT"
ThisBuild / organization := "com.eed3si9n"

lazy val root = (project in file(".")).
// enablePlugins(GitVersioning).
settings(commonSettings: _*).
settings(
sbtPlugin := true,
lazy val root = (project in file("."))
.enablePlugins(SbtPlugin)
.settings(
name := "sbt-assembly",
description := "sbt plugin to create a single fat jar",
licenses := Seq("MIT License" -> url("https://github.com/sbt/sbt-assembly/blob/master/LICENSE")),
scalacOptions := Seq("-deprecation", "-unchecked", "-Dscalac.patmat.analysisBudget=1024", "-Xfuture"),
libraryDependencies ++= Seq(
"org.scalactic" %% "scalactic" % "3.0.8",
"org.pantsbuild" % "jarjar" % "1.7.2",
"com.eed3si9n.jarjarabrams" %% "jarjar-abrams-core" % "0.1.0",
"org.scalatest" %% "scalatest" % "3.1.1" % Test,
),
crossSbtVersions := Seq("0.13.18", "1.2.8"), // https://github.com/sbt/sbt/issues/5049
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.6
sbt.version=1.3.12
99 changes: 0 additions & 99 deletions src/main/scala/org/pantsbuild/jarjar/JJProcessor.scala

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/scala/org/pantsbuild/jarjar/ScalaSigProcessor.scala

This file was deleted.

17 changes: 14 additions & 3 deletions src/main/scala/sbtassembly/Assembly.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package sbtassembly

import sbt._
import Keys._
import Path.relativeTo
import java.security.MessageDigest
import java.io.{IOException, File}
import scala.collection.mutable
import Def.Initialize
import PluginCompat._
import com.eed3si9n.jarjarabrams._

object Assembly {
import AssemblyPlugin.autoImport.{ Assembly => _, _ }
Expand Down Expand Up @@ -217,15 +219,21 @@ object Assembly {
dest.mkdir()
IO.copyDirectory(dir.data, dest)
if (dirRules.nonEmpty) {
Shader.shadeDirectory(dirRules, dest, log, ao.level)
val mappings = ((dest ** (-DirectoryFilter)).get pair relativeTo(dest)) map {
case (k, v) => k.toPath -> v
}
Shader.shadeDirectory(dirRules, dest.toPath, mappings, ao.level == Level.Debug)
}
dest
}
val jarDirs =
(for(jar <- libsFiltered.par) yield {
val jarName = jar.data.asFile.getName
val jarRules = shadeRules
.filter(r => (r.isApplicableToAll || jar.metadata.get(moduleID.key).exists(r.isApplicableTo)))
.filter(r => (r.isApplicableToAll ||
jar.metadata.get(moduleID.key)
.map(m => ModuleCoordinate(m.organization, m.name, m.revision))
.exists(r.isApplicableTo)))
val hash = sha1name(jar.data) + "_" + sha1content(jar.data) + "_" + sha1rules(jarRules)
val jarNamePath = tempDir / (hash + ".jarName")
val dest = tempDir / hash
Expand All @@ -238,7 +246,10 @@ object Assembly {
AssemblyUtils.unzip(jar.data, dest, log)
IO.delete(ao.excludedFiles(Seq(dest)))
if (jarRules.nonEmpty) {
Shader.shadeDirectory(jarRules, dest, log, ao.level)
val mappings = ((dest ** (-DirectoryFilter)).get pair relativeTo(dest)) map {
case (k, v) => k.toPath -> v
}
Shader.shadeDirectory(dirRules, dest.toPath, mappings, ao.level == Level.Debug)
}

// Write the jarNamePath at the end to minimise the chance of having a
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/sbtassembly/AssemblyKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sbtassembly

import sbt._
import Keys._
import com.eed3si9n.jarjarabrams

trait AssemblyKeys {
lazy val assembly = taskKey[File]("Builds a deployable fat jar.")
Expand Down Expand Up @@ -37,7 +38,7 @@ trait AssemblyKeys {
@deprecated("Use assemblyMergeStrategy", "0.12.0")
lazy val mergeStrategy = assemblyMergeStrategy

lazy val assemblyShadeRules = settingKey[Seq[ShadeRule]]("shading rules backed by jarjar")
lazy val assemblyShadeRules = settingKey[Seq[jarjarabrams.ShadeRule]]("shading rules backed by jarjar")
}
object AssemblyKeys extends AssemblyKeys

Expand Down
10 changes: 8 additions & 2 deletions src/main/scala/sbtassembly/AssemblyPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sbtassembly

import sbt._
import Keys._
import com.eed3si9n.jarjarabrams

object AssemblyPlugin extends sbt.AutoPlugin {
override def requires = plugins.JvmPlugin
Expand All @@ -12,7 +13,12 @@ object AssemblyPlugin extends sbt.AutoPlugin {
val MergeStrategy = sbtassembly.MergeStrategy
val PathList = sbtassembly.PathList
val baseAssemblySettings = AssemblyPlugin.baseAssemblySettings
val ShadeRule = sbtassembly.ShadeRule
val ShadeRule = com.eed3si9n.jarjarabrams.ShadeRule
implicit class RichShadePattern(pattern: jarjarabrams.ShadePattern) {
def inLibrary(moduleId: ModuleID*): jarjarabrams.ShadeRule =
pattern.inModuleCoordinates(moduleId.toVector
.map(m => jarjarabrams.ModuleCoordinate(m.organization, m.name, m.revision)): _*)
}
}
import autoImport.{ Assembly => _, baseAssemblySettings => _, _ }

Expand Down Expand Up @@ -151,6 +157,6 @@ case class AssemblyOption(assemblyDirectory: File,
appendContentHash: Boolean = false,
prependShellScript: Option[Seq[String]] = None,
maxHashLength: Option[Int] = None,
shadeRules: Seq[ShadeRule] = Seq(),
shadeRules: Seq[jarjarabrams.ShadeRule] = Seq(),
scalaVersion: String = "",
level: Level.Value)
109 changes: 0 additions & 109 deletions src/main/scala/sbtassembly/Shader.scala

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/scala/sbtassembly/scalasig/ByteArrayReader.scala

This file was deleted.

Loading

0 comments on commit 074d652

Please sign in to comment.