Skip to content

Commit

Permalink
Merge pull request #216 from erizocosmico/fix/fatjar-not-include-deps…
Browse files Browse the repository at this point in the history
…-in-pom

build: not include not provided deps on pom.xml, scala as provided
  • Loading branch information
erizocosmico authored Nov 27, 2017
2 parents f39c8a9 + bd51832 commit cd19a4d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
41 changes: 40 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ libraryDependencies += bblfsh % Compile
libraryDependencies += commonsIO % Compile
libraryDependencies += commonsPool % Compile
libraryDependencies += enry % Compile
libraryDependencies += scalaLib % Provided

assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)

testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oUT")

Expand All @@ -31,7 +34,9 @@ logBuffered in Test := false

assemblyShadeRules in assembly := Seq(
ShadeRule.rename("com.google.common.**" -> "com.google.shadedcommon.@1").inAll,
ShadeRule.rename("io.netty.**" -> "io.shadednetty.@1").inAll
ShadeRule.rename("io.netty.**" -> "io.shadednetty.@1").inAll,
ShadeRule.rename("org.apache.commons.**" -> "org.apache.shadedcommons.@1").inAll,
ShadeRule.rename("org.eclipse.jgit.**" -> "org.eclipse.shadedjgit.@1").inAll
)

assemblyMergeStrategy in assembly := {
Expand Down Expand Up @@ -69,6 +74,40 @@ pomIncludeRepository := (_ => false)
crossPaths := false
publishMavenStyle := true

pomPostProcess := { (node: scala.xml.Node) =>
import scala.xml._
import scala.xml.transform._

object DependencyEraser extends RewriteRule {
override def transform(n: Node): Seq[Node] = n match {
case e: Elem if e.label == "dependencies" =>
<dependencies>
{e.child}<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>
{scalaVersion.value}
</version>
<scope>provided</scope>
</dependency>
</dependencies>
case e: Elem if e.label == "dependency"
&& e.child.exists(child => child.label == "scope" && child.text == "provided") =>
e
case e: Elem if e.label == "dependency" =>
val organization = e.child.filter(_.label == "groupId").flatMap(_.text).mkString
val artifact = e.child.filter(_.label == "artifactId").flatMap(_.text).mkString
val version = e.child.filter(_.label == "version").flatMap(_.text).mkString
Comment(s" not provided dependency $organization#$artifact;$version has been omitted ")
case other => other
}
}

object eraseDependencies extends RuleTransformer(DependencyEraser)

eraseDependencies(node)
}

val SONATYPE_USERNAME = scala.util.Properties.envOrElse("SONATYPE_USERNAME", "NOT_SET")
val SONATYPE_PASSWORD = scala.util.Properties.envOrElse("SONATYPE_PASSWORD", "NOT_SET")
credentials += Credentials(
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ object Dependencies {
lazy val enry = "tech.sourced" % "enry-java" % "1.6.1"
lazy val commonsIO = "commons-io" % "commons-io" % "2.5"
lazy val commonsPool = "org.apache.commons" % "commons-pool2" % "2.4.3"

lazy val scalaLib = "org.scala-lang" % "scala-library" % "2.11.11"
}

0 comments on commit cd19a4d

Please sign in to comment.