-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jar Jar Abrams is an experimental Scala extension of Jar Jar Links.
- Loading branch information
Showing
35 changed files
with
1,170 additions
and
300 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version = 2.3.2 | ||
edition = 2019-10 | ||
maxColumn = 100 | ||
project.git = true | ||
project.excludeFilters = [ "\\Wsbt-test\\W", "\\Winput_sources\\W", "\\Wcontraband-scala\\W" ] | ||
|
||
# http://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style. | ||
# scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala | ||
docstrings = JavaDoc | ||
|
||
# This also seems more idiomatic to include whitespace in import x.{ yyy } | ||
spaces.inImportCurlyBraces = true | ||
|
||
# This is more idiomatic Scala. | ||
# http://docs.scala-lang.org/style/indentation.html#methods-with-numerous-arguments | ||
align.openParenCallSite = false | ||
align.openParenDefnSite = false | ||
|
||
# For better code clarity | ||
danglingParentheses = true | ||
|
||
trailingCommas = preserve |
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,18 @@ | ||
dist: xenial | ||
|
||
language: scala | ||
|
||
script: | ||
- sbt "+test" "scripted" | ||
|
||
before_cache: | ||
- find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete | ||
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete | ||
- find $HOME/.sbt -name "*.lock" -delete | ||
|
||
cache: | ||
directories: | ||
- $HOME/.cache/coursier/v1 | ||
- $HOME/.ivy2/cache | ||
- $HOME/.sbt/boot | ||
- $HOME/.jabba |
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,18 @@ | ||
Jar Jar Abrams | ||
============== | ||
|
||
Jar Jar Abrams is an experimental Scala extension of [Jar Jar Links][links] a utility to shade Java libraries. | ||
|
||
## License | ||
|
||
Licensed under the Apache License, Version 2.0. | ||
|
||
## Credits | ||
|
||
- [Jar Jar Links][links] was created by herbyderby (Chris Nokleberg) in 2004. | ||
- Pants build team has been maintaining a fork [pantsbuild/jarjar][pj] since 2015. | ||
- In 2015, Wu Xiang added shading support in [sbt-assembly#162](https://github.com/sbt/sbt-assembly/pull/162). | ||
- In 2020, Jeroen ter Voorde added Scala signature processor in [sbt-assembly#393](https://github.com/sbt/sbt-assembly/pull/393). | ||
|
||
[links]: https://code.google.com/archive/p/jarjar/ | ||
[pj]: https://github.com/pantsbuild/jarjar |
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,52 @@ | ||
import Dependencies._ | ||
|
||
ThisBuild / scalaVersion := scala212 | ||
ThisBuild / organization := "com.eed3si9n.jarjarabrams" | ||
ThisBuild / version := "0.1.0-SNAPSHOT" | ||
ThisBuild / description := "utility to shade Scala libraries" | ||
ThisBuild / licenses := Seq("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")) | ||
|
||
lazy val core = project | ||
.enablePlugins(ContrabandPlugin) | ||
.settings(nocomma { | ||
name := "jarjar-abrams-core" | ||
|
||
crossScalaVersions := Vector(scala212, scala213, scala211, scala210) | ||
|
||
libraryDependencies += jarjar | ||
libraryDependencies ++= { | ||
if (scalaVersion.value.startsWith("2.10.")) Nil | ||
else Vector(verify % Test) | ||
} | ||
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value | ||
|
||
Compile / managedSourceDirectories += (Compile / generateContrabands / sourceManaged).value | ||
Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "contraband-scala" | ||
Test / sources := { | ||
val orig = (Test / sources).value | ||
if (scalaVersion.value.startsWith("2.10.")) Nil | ||
else orig | ||
} | ||
|
||
testFrameworks += new TestFramework("verify.runner.Framework") | ||
|
||
Compile / scalacOptions ++= { | ||
if (scalaVersion.value.startsWith("2.13.")) Vector("-Xlint") | ||
else Vector("-Xlint", "-Xfatal-warnings") | ||
} | ||
}) | ||
|
||
lazy val sbtplugin = project | ||
.enablePlugins(SbtPlugin) | ||
.dependsOn(core) | ||
.settings(nocomma { | ||
name := "sbt-jarjar-abrams" | ||
|
||
Compile / scalacOptions ++= Vector("-Xlint", "-Xfatal-warnings") | ||
|
||
scriptedLaunchOpts := { | ||
scriptedLaunchOpts.value ++ | ||
Vector("-Xmx1024M", "-Dplugin.version=" + version.value) | ||
} | ||
scriptedBufferLog := false | ||
}) |
41 changes: 41 additions & 0 deletions
41
core/src/main/contraband-scala/com/eed3si9n/jarjarabrams/ModuleCoordinate.scala
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,41 @@ | ||
/** | ||
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. | ||
*/ | ||
|
||
// DO NOT EDIT MANUALLY | ||
package com.eed3si9n.jarjarabrams | ||
/** stand-in for sbt's ModuleID */ | ||
final class ModuleCoordinate private ( | ||
val organization: String, | ||
val name: String, | ||
val version: String) extends Serializable { | ||
|
||
|
||
|
||
override def equals(o: Any): Boolean = o match { | ||
case x: ModuleCoordinate => (this.organization == x.organization) && (this.name == x.name) && (this.version == x.version) | ||
case _ => false | ||
} | ||
override def hashCode: Int = { | ||
37 * (37 * (37 * (37 * (17 + "com.eed3si9n.jarjarabrams.ModuleCoordinate".##) + organization.##) + name.##) + version.##) | ||
} | ||
override def toString: String = { | ||
"ModuleCoordinate(" + organization + ", " + name + ", " + version + ")" | ||
} | ||
private[this] def copy(organization: String = organization, name: String = name, version: String = version): ModuleCoordinate = { | ||
new ModuleCoordinate(organization, name, version) | ||
} | ||
def withOrganization(organization: String): ModuleCoordinate = { | ||
copy(organization = organization) | ||
} | ||
def withName(name: String): ModuleCoordinate = { | ||
copy(name = name) | ||
} | ||
def withVersion(version: String): ModuleCoordinate = { | ||
copy(version = version) | ||
} | ||
} | ||
object ModuleCoordinate { | ||
|
||
def apply(organization: String, name: String, version: String): ModuleCoordinate = new ModuleCoordinate(organization, name, version) | ||
} |
47 changes: 47 additions & 0 deletions
47
core/src/main/contraband-scala/com/eed3si9n/jarjarabrams/ShadeRule.scala
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,47 @@ | ||
/** | ||
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. | ||
*/ | ||
|
||
// DO NOT EDIT MANUALLY | ||
package com.eed3si9n.jarjarabrams | ||
final class ShadeRule private ( | ||
val shadePattern: com.eed3si9n.jarjarabrams.ShadePattern, | ||
val targets: Vector[ShadeTarget]) extends Serializable { | ||
def inAll: ShadeRule = this.withTargets(targets :+ ShadeTarget.inAll) | ||
def inProject: ShadeRule = this.withTargets(targets :+ ShadeTarget.inProject) | ||
def inModuleCoordinates(moduleId: ModuleCoordinate*): ShadeRule = | ||
this.withTargets(targets ++ (moduleId.toSeq map ShadeTarget.inModuleCoordinate)) | ||
def isApplicableToAll: Boolean = targets.exists(_.inAll) | ||
def isApplicableToCompiling: Boolean = targets.exists(_.inAll) || targets.exists(_.inProject) | ||
def isApplicableTo(mod: ModuleCoordinate): Boolean = | ||
targets.exists(_.inAll) || targets.exists(_.isApplicableTo(mod)) | ||
|
||
|
||
override def equals(o: Any): Boolean = o match { | ||
case x: ShadeRule => (this.shadePattern == x.shadePattern) && (this.targets == x.targets) | ||
case _ => false | ||
} | ||
override def hashCode: Int = { | ||
37 * (37 * (37 * (17 + "com.eed3si9n.jarjarabrams.ShadeRule".##) + shadePattern.##) + targets.##) | ||
} | ||
override def toString: String = { | ||
"ShadeRule(" + shadePattern + ", " + targets + ")" | ||
} | ||
private[this] def copy(shadePattern: com.eed3si9n.jarjarabrams.ShadePattern = shadePattern, targets: Vector[ShadeTarget] = targets): ShadeRule = { | ||
new ShadeRule(shadePattern, targets) | ||
} | ||
def withShadePattern(shadePattern: com.eed3si9n.jarjarabrams.ShadePattern): ShadeRule = { | ||
copy(shadePattern = shadePattern) | ||
} | ||
def withTargets(targets: Vector[ShadeTarget]): ShadeRule = { | ||
copy(targets = targets) | ||
} | ||
} | ||
object ShadeRule { | ||
import ShadePattern._ | ||
def rename(patterns: (String, String)*): ShadePattern = Rename(patterns.toSeq.toList) | ||
def moveUnder(from: String, to: String): ShadePattern = rename(s"$from.**" -> s"$to.$from.@1") | ||
def zap(patterns: String*): ShadePattern = Zap(patterns.toSeq.toList) | ||
def keep(patterns: String*): ShadePattern = Keep(patterns.toSeq.toList) | ||
def apply(shadePattern: com.eed3si9n.jarjarabrams.ShadePattern, targets: Vector[ShadeTarget]): ShadeRule = new ShadeRule(shadePattern, targets) | ||
} |
36 changes: 36 additions & 0 deletions
36
core/src/main/contraband-scala/com/eed3si9n/jarjarabrams/ShadeRuleDelegate.scala
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,36 @@ | ||
/** | ||
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. | ||
*/ | ||
|
||
// DO NOT EDIT MANUALLY | ||
package com.eed3si9n.jarjarabrams | ||
final class ShadeRule private ( | ||
val shadePattern: com.eed3si9n.jarjarabrams.ShadePattern, | ||
val targets: Vector[ShadeTarget]) extends Serializable { | ||
|
||
|
||
|
||
override def equals(o: Any): Boolean = o match { | ||
case x: ShadeRule => (this.shadePattern == x.shadePattern) && (this.targets == x.targets) | ||
case _ => false | ||
} | ||
override def hashCode: Int = { | ||
37 * (37 * (37 * (17 + "com.eed3si9n.jarjarabrams.ShadeRule".##) + shadePattern.##) + targets.##) | ||
} | ||
override def toString: String = { | ||
"ShadeRule(" + shadePattern + ", " + targets + ")" | ||
} | ||
private[this] def copy(shadePattern: com.eed3si9n.jarjarabrams.ShadePattern = shadePattern, targets: Vector[ShadeTarget] = targets): ShadeRule = { | ||
new ShadeRule(shadePattern, targets) | ||
} | ||
def withShadePattern(shadePattern: com.eed3si9n.jarjarabrams.ShadePattern): ShadeRule = { | ||
copy(shadePattern = shadePattern) | ||
} | ||
def withTargets(targets: Vector[ShadeTarget]): ShadeRule = { | ||
copy(targets = targets) | ||
} | ||
} | ||
object ShadeRule { | ||
|
||
def apply(shadePattern: com.eed3si9n.jarjarabrams.ShadePattern, targets: Vector[ShadeTarget]): ShadeRule = new ShadeRule(shadePattern, targets) | ||
} |
52 changes: 52 additions & 0 deletions
52
core/src/main/contraband-scala/com/eed3si9n/jarjarabrams/ShadeTarget.scala
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,52 @@ | ||
/** | ||
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. | ||
*/ | ||
|
||
// DO NOT EDIT MANUALLY | ||
package com.eed3si9n.jarjarabrams | ||
/** | ||
* This is a categorization to denote which rules are applied to what. | ||
* Used internally in sbt-assembly. There's nothing in Shader.shadeDirectory | ||
* that would enforce these target categorization. | ||
*/ | ||
final class ShadeTarget private ( | ||
val inAll: Boolean, | ||
val inProject: Boolean, | ||
val moduleId: Option[ModuleCoordinate]) extends Serializable { | ||
def isApplicableTo(mod: ModuleCoordinate): Boolean = inAll || (moduleId == Some(mod)) | ||
|
||
|
||
override def equals(o: Any): Boolean = o match { | ||
case x: ShadeTarget => (this.inAll == x.inAll) && (this.inProject == x.inProject) && (this.moduleId == x.moduleId) | ||
case _ => false | ||
} | ||
override def hashCode: Int = { | ||
37 * (37 * (37 * (37 * (17 + "com.eed3si9n.jarjarabrams.ShadeTarget".##) + inAll.##) + inProject.##) + moduleId.##) | ||
} | ||
override def toString: String = { | ||
"ShadeTarget(" + inAll + ", " + inProject + ", " + moduleId + ")" | ||
} | ||
private[this] def copy(inAll: Boolean = inAll, inProject: Boolean = inProject, moduleId: Option[ModuleCoordinate] = moduleId): ShadeTarget = { | ||
new ShadeTarget(inAll, inProject, moduleId) | ||
} | ||
def withInAll(inAll: Boolean): ShadeTarget = { | ||
copy(inAll = inAll) | ||
} | ||
def withInProject(inProject: Boolean): ShadeTarget = { | ||
copy(inProject = inProject) | ||
} | ||
def withModuleId(moduleId: Option[ModuleCoordinate]): ShadeTarget = { | ||
copy(moduleId = moduleId) | ||
} | ||
def withModuleId(moduleId: ModuleCoordinate): ShadeTarget = { | ||
copy(moduleId = Option(moduleId)) | ||
} | ||
} | ||
object ShadeTarget { | ||
private[jarjarabrams] def inAll: ShadeTarget = ShadeTarget(inAll = true, inProject = false, None) | ||
private[jarjarabrams] def inProject: ShadeTarget = ShadeTarget(inAll = false, inProject = true, None) | ||
private[jarjarabrams] def inModuleCoordinate(moduleId: ModuleCoordinate): ShadeTarget = | ||
ShadeTarget(inAll = false, inProject = false, moduleId = Some(moduleId)) | ||
def apply(inAll: Boolean, inProject: Boolean, moduleId: Option[ModuleCoordinate]): ShadeTarget = new ShadeTarget(inAll, inProject, moduleId) | ||
def apply(inAll: Boolean, inProject: Boolean, moduleId: ModuleCoordinate): ShadeTarget = new ShadeTarget(inAll, inProject, Option(moduleId)) | ||
} |
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,46 @@ | ||
package com.eed3si9n.jarjarabrams | ||
@target(Scala) | ||
|
||
type ShadeRule { | ||
shadePattern: com.eed3si9n.jarjarabrams.ShadePattern! | ||
targets: [ShadeTarget] | ||
|
||
#x def inAll: ShadeRule = this.withTargets(targets :+ ShadeTarget.inAll) | ||
#x def inProject: ShadeRule = this.withTargets(targets :+ ShadeTarget.inProject) | ||
#x def inModuleCoordinates(moduleId: ModuleCoordinate*): ShadeRule = | ||
#x this.withTargets(targets ++ (moduleId.toSeq map ShadeTarget.inModuleCoordinate)) | ||
|
||
#x def isApplicableToAll: Boolean = targets.exists(_.inAll) | ||
#x def isApplicableToCompiling: Boolean = targets.exists(_.inAll) || targets.exists(_.inProject) | ||
#x def isApplicableTo(mod: ModuleCoordinate): Boolean = | ||
#x targets.exists(_.inAll) || targets.exists(_.isApplicableTo(mod)) | ||
|
||
#xcompanion import ShadePattern._ | ||
#xcompanion def rename(patterns: (String, String)*): ShadePattern = Rename(patterns.toSeq.toList) | ||
#xcompanion def moveUnder(from: String, to: String): ShadePattern = rename(s"$from.**" -> s"$to.$from.@1") | ||
#xcompanion def zap(patterns: String*): ShadePattern = Zap(patterns.toSeq.toList) | ||
#xcompanion def keep(patterns: String*): ShadePattern = Keep(patterns.toSeq.toList) | ||
} | ||
|
||
## This is a categorization to denote which rules are applied to what. | ||
## Used internally in sbt-assembly. There's nothing in Shader.shadeDirectory | ||
## that would enforce these target categorization. | ||
type ShadeTarget { | ||
inAll: Boolean! = false | ||
inProject: Boolean! = false | ||
moduleId: ModuleCoordinate | ||
|
||
#x def isApplicableTo(mod: ModuleCoordinate): Boolean = inAll || (moduleId == Some(mod)) | ||
|
||
#xcompanion private[jarjarabrams] def inAll: ShadeTarget = ShadeTarget(inAll = true, inProject = false, None) | ||
#xcompanion private[jarjarabrams] def inProject: ShadeTarget = ShadeTarget(inAll = false, inProject = true, None) | ||
#xcompanion private[jarjarabrams] def inModuleCoordinate(moduleId: ModuleCoordinate): ShadeTarget = | ||
#xcompanion ShadeTarget(inAll = false, inProject = false, moduleId = Some(moduleId)) | ||
} | ||
|
||
## stand-in for sbt's ModuleID | ||
type ModuleCoordinate { | ||
organization: String! | ||
name: String! | ||
version: String! | ||
} |
Oops, something went wrong.