mirror of https://github.com/sbt/sbt.git
Merge pull request #228 from alexarchambault/remove-sbt-shading
Remove sbt-shading sources
This commit is contained in:
commit
d38e523663
|
|
@ -14,7 +14,6 @@ jobs:
|
||||||
include:
|
include:
|
||||||
- env: SBT_COURSIER=1 TEST_GROUP=1
|
- env: SBT_COURSIER=1 TEST_GROUP=1
|
||||||
- env: SBT_COURSIER=1 TEST_GROUP=2
|
- env: SBT_COURSIER=1 TEST_GROUP=2
|
||||||
- env: SBT_SHADING=1
|
|
||||||
- env: SBT_PGP_COURSIER=1
|
- env: SBT_PGP_COURSIER=1
|
||||||
- env: LM_COURSIER=1 TEST_GROUP=1
|
- env: LM_COURSIER=1 TEST_GROUP=1
|
||||||
- env: LM_COURSIER=1 TEST_GROUP=2
|
- env: LM_COURSIER=1 TEST_GROUP=2
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ build_script:
|
||||||
- cmd: .\metadata\coursier fetch io.get-coursier:http-server_2.12:1.0.0
|
- cmd: .\metadata\coursier fetch io.get-coursier:http-server_2.12:1.0.0
|
||||||
- ps: Start-Job -filepath .\metadata\scripts\start-it-auth-server.ps1 -ArgumentList $pwd\metadata, $env:TEST_REPOSITORY_HOST, $env:TEST_REPOSITORY_PORT, $env:TEST_REPOSITORY_USER, $env:TEST_REPOSITORY_PASSWORD
|
- ps: Start-Job -filepath .\metadata\scripts\start-it-auth-server.ps1 -ArgumentList $pwd\metadata, $env:TEST_REPOSITORY_HOST, $env:TEST_REPOSITORY_PORT, $env:TEST_REPOSITORY_USER, $env:TEST_REPOSITORY_PASSWORD
|
||||||
test_script:
|
test_script:
|
||||||
- sbt ++2.12.7 "sbt-lm-coursier/scripted shared-2/simple" sbt-coursier/scripted sbt-shading/scripted
|
- sbt ++2.12.7 "sbt-lm-coursier/scripted shared-2/simple" sbt-coursier/scripted
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
|
||||||
53
build.sbt
53
build.sbt
|
|
@ -45,28 +45,27 @@ lazy val `lm-coursier-shaded` = project
|
||||||
Mima.lmCoursierFilters,
|
Mima.lmCoursierFilters,
|
||||||
Mima.lmCoursierShadedFilters,
|
Mima.lmCoursierShadedFilters,
|
||||||
unmanagedSourceDirectories.in(Compile) := unmanagedSourceDirectories.in(Compile).in(`lm-coursier`).value,
|
unmanagedSourceDirectories.in(Compile) := unmanagedSourceDirectories.in(Compile).in(`lm-coursier`).value,
|
||||||
shading,
|
shadedModules += "io.get-coursier" %% "coursier",
|
||||||
shadingNamespace := "lmcoursier.internal.shaded",
|
validNamespaces += "lmcoursier",
|
||||||
shadeNamespaces ++= Set(
|
shadingRules ++= {
|
||||||
"coursier",
|
val toShade = Seq(
|
||||||
"shapeless",
|
"coursier",
|
||||||
"argonaut",
|
"shapeless",
|
||||||
"org.fusesource",
|
"argonaut",
|
||||||
"macrocompat",
|
"org.fusesource",
|
||||||
"io.github.alexarchambault.windowsansi"
|
"macrocompat",
|
||||||
),
|
"io.github.alexarchambault.windowsansi"
|
||||||
|
)
|
||||||
|
for (ns <- toShade)
|
||||||
|
yield ShadingRule.moveUnder(ns, "lmcoursier.internal.shaded")
|
||||||
|
},
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"io.get-coursier" %% "coursier" % coursierVersion0 % "shaded",
|
"io.get-coursier" %% "coursier" % coursierVersion0,
|
||||||
"io.github.alexarchambault" %% "data-class" % "0.2.3" % Provided,
|
"io.github.alexarchambault" %% "data-class" % "0.2.3" % Provided,
|
||||||
"org.scala-lang.modules" %% "scala-xml" % "1.3.0", // depending on that one so that it doesn't get shaded
|
"org.scala-lang.modules" %% "scala-xml" % "1.3.0", // depending on that one so that it doesn't get shaded
|
||||||
"org.scala-sbt" %% "librarymanagement-ivy" % "1.3.2",
|
"org.scala-sbt" %% "librarymanagement-ivy" % "1.3.2",
|
||||||
"org.scalatest" %% "scalatest" % "3.1.2" % Test
|
"org.scalatest" %% "scalatest" % "3.1.2" % Test
|
||||||
),
|
)
|
||||||
packageBin.in(Shading) := {
|
|
||||||
val jar = packageBin.in(Shading).value
|
|
||||||
Check.onlyNamespace("lmcoursier", jar)
|
|
||||||
jar
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val `sbt-coursier-shared` = project
|
lazy val `sbt-coursier-shared` = project
|
||||||
|
|
@ -145,23 +144,6 @@ lazy val `sbt-pgp-coursier` = project
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val `sbt-shading` = project
|
|
||||||
.in(file("modules/sbt-shading"))
|
|
||||||
.enablePlugins(ScriptedPlugin)
|
|
||||||
.disablePlugins(MimaPlugin)
|
|
||||||
.dependsOn(`sbt-coursier`)
|
|
||||||
.settings(
|
|
||||||
plugin,
|
|
||||||
libraryDependencies += ("ch.epfl.scala" % "jarjar" % "1.7.2-patched")
|
|
||||||
.exclude("org.apache.maven", "maven-plugin-api")
|
|
||||||
.exclude("org.apache.ant", "ant"),
|
|
||||||
scriptedDependencies := {
|
|
||||||
scriptedDependencies.value
|
|
||||||
// TODO Get dependency projects automatically
|
|
||||||
scriptedDependencies.in(`sbt-coursier`).value
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
lazy val `sbt-coursier-root` = project
|
lazy val `sbt-coursier-root` = project
|
||||||
.in(file("."))
|
.in(file("."))
|
||||||
.disablePlugins(MimaPlugin)
|
.disablePlugins(MimaPlugin)
|
||||||
|
|
@ -172,8 +154,7 @@ lazy val `sbt-coursier-root` = project
|
||||||
`sbt-coursier-shared`,
|
`sbt-coursier-shared`,
|
||||||
`sbt-coursier-shared-shaded`,
|
`sbt-coursier-shared-shaded`,
|
||||||
`sbt-lm-coursier`,
|
`sbt-lm-coursier`,
|
||||||
`sbt-pgp-coursier`,
|
`sbt-pgp-coursier`
|
||||||
`sbt-shading`
|
|
||||||
)
|
)
|
||||||
.settings(
|
.settings(
|
||||||
shared,
|
shared,
|
||||||
|
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
package org.pantsbuild.jarjar.util;
|
|
||||||
|
|
||||||
// adapted from https://github.com/pantsbuild/jarjar/blob/57845dc73d3e2c9b916ae4a788cfa12114fd7df1/src/main/java/org/pantsbuild/jarjar/util/StandaloneJarProcessor.java
|
|
||||||
// - made it accepted a List<File> rather than a single File
|
|
||||||
// - added argument ignoreDuplicateEntries
|
|
||||||
|
|
||||||
import java.util.jar.JarEntry;
|
|
||||||
import java.util.jar.JarFile;
|
|
||||||
import java.util.jar.JarOutputStream;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class CoursierJarProcessor
|
|
||||||
{
|
|
||||||
public static void run(File[] from, File to, JarProcessor proc, boolean ignoreDuplicateEntries) throws IOException {
|
|
||||||
byte[] buf = new byte[0x2000];
|
|
||||||
|
|
||||||
final File tmpTo = File.createTempFile("jarjar", ".jar");
|
|
||||||
Set<String> entries = new HashSet<>();
|
|
||||||
|
|
||||||
FileOutputStream fos = null;
|
|
||||||
JarOutputStream out = null;
|
|
||||||
try {
|
|
||||||
fos = new FileOutputStream(tmpTo);
|
|
||||||
BufferedOutputStream buffered = new BufferedOutputStream(fos);
|
|
||||||
out = new JarOutputStream(buffered);
|
|
||||||
|
|
||||||
for (File from0 : from) {
|
|
||||||
JarFile in = null;
|
|
||||||
try {
|
|
||||||
in = new JarFile(from0);
|
|
||||||
Enumeration<JarEntry> e = in.entries();
|
|
||||||
while (e.hasMoreElements()) {
|
|
||||||
EntryStruct struct = new EntryStruct();
|
|
||||||
JarEntry entry = e.nextElement();
|
|
||||||
struct.name = entry.getName();
|
|
||||||
struct.time = entry.getTime();
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
IoUtil.pipe(in.getInputStream(entry), baos, buf);
|
|
||||||
struct.data = baos.toByteArray();
|
|
||||||
if (proc.process(struct)) {
|
|
||||||
if (entries.add(struct.name)) {
|
|
||||||
entry = new JarEntry(struct.name);
|
|
||||||
entry.setTime(struct.time);
|
|
||||||
entry.setCompressedSize(-1);
|
|
||||||
out.putNextEntry(entry);
|
|
||||||
out.write(struct.data);
|
|
||||||
} else if (struct.name.endsWith("/")) {
|
|
||||||
// TODO(chrisn): log
|
|
||||||
} else if (!ignoreDuplicateEntries) {
|
|
||||||
throw new DuplicateJarEntryException(from0.getAbsolutePath(), struct.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (in != null)
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (out != null)
|
|
||||||
out.close();
|
|
||||||
if (fos != null)
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete the empty directories
|
|
||||||
IoUtil.copyZipWithoutEmptyDirectories(tmpTo, to);
|
|
||||||
tmpTo.delete();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,212 +0,0 @@
|
||||||
package coursier
|
|
||||||
|
|
||||||
import java.io.{File, FileInputStream}
|
|
||||||
import java.util.jar.JarInputStream
|
|
||||||
import java.util.zip.{ZipEntry, ZipInputStream}
|
|
||||||
|
|
||||||
import coursier.core.{Configuration, Orders}
|
|
||||||
import coursier.util.Artifact
|
|
||||||
import org.pantsbuild.jarjar._
|
|
||||||
import org.pantsbuild.jarjar.util.CoursierJarProcessor
|
|
||||||
|
|
||||||
object Shading {
|
|
||||||
|
|
||||||
// FIXME Also vaguely in cli
|
|
||||||
def zipEntries(zipStream: ZipInputStream): Iterator[ZipEntry] =
|
|
||||||
new Iterator[ZipEntry] {
|
|
||||||
var nextEntry = Option.empty[ZipEntry]
|
|
||||||
def update() =
|
|
||||||
nextEntry = Option(zipStream.getNextEntry)
|
|
||||||
|
|
||||||
update()
|
|
||||||
|
|
||||||
def hasNext = nextEntry.nonEmpty
|
|
||||||
def next() = {
|
|
||||||
val ent = nextEntry.get
|
|
||||||
update()
|
|
||||||
ent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def jarClassNames(jar: File): Seq[String] = {
|
|
||||||
|
|
||||||
var fis: FileInputStream = null
|
|
||||||
var zis: JarInputStream = null
|
|
||||||
|
|
||||||
try {
|
|
||||||
fis = new FileInputStream(jar)
|
|
||||||
zis = new JarInputStream(fis)
|
|
||||||
|
|
||||||
zipEntries(zis)
|
|
||||||
.map(_.getName)
|
|
||||||
.filter(_.endsWith(".class"))
|
|
||||||
.map(_.stripSuffix(".class").replace('/', '.'))
|
|
||||||
.toVector
|
|
||||||
} finally {
|
|
||||||
if (zis != null)
|
|
||||||
zis.close()
|
|
||||||
if (fis != null)
|
|
||||||
fis.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def toShadeJars(
|
|
||||||
currentProject: Project,
|
|
||||||
res: Resolution,
|
|
||||||
configs: Map[Configuration, Set[Configuration]],
|
|
||||||
artifactFilesOrErrors: Map[Artifact, File],
|
|
||||||
classpathTypes: Set[Type],
|
|
||||||
baseConfig: Configuration,
|
|
||||||
shadedConf: Configuration,
|
|
||||||
log: sbt.Logger
|
|
||||||
): Seq[File] = {
|
|
||||||
|
|
||||||
def configDependencies(config: Configuration) = {
|
|
||||||
|
|
||||||
def minDependencies(dependencies: Seq[Dependency]): Seq[Dependency] =
|
|
||||||
Orders.minDependencies(
|
|
||||||
dependencies.toSet,
|
|
||||||
dep =>
|
|
||||||
res
|
|
||||||
.projectCache
|
|
||||||
.get(dep)
|
|
||||||
.map(_._2.configurations)
|
|
||||||
.getOrElse(Map.empty)
|
|
||||||
).toSeq // sort so that this is deterministic?
|
|
||||||
|
|
||||||
val includedConfigs = configs.getOrElse(config, Set.empty) + config
|
|
||||||
|
|
||||||
minDependencies(
|
|
||||||
currentProject
|
|
||||||
.dependencies
|
|
||||||
.collect {
|
|
||||||
case (cfg, dep) if includedConfigs(cfg) =>
|
|
||||||
dep
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val dependencyArtifacts = res
|
|
||||||
.dependencyArtifacts(None, classpathOrder = false)
|
|
||||||
.filter { case (_, attr, _) => classpathTypes(attr.`type`) }
|
|
||||||
.groupBy(_._1)
|
|
||||||
.mapValues(_.map(t => (t._2, t._3)))
|
|
||||||
.iterator
|
|
||||||
.toMap
|
|
||||||
|
|
||||||
val artifactFilesOrErrors0 = artifactFilesOrErrors
|
|
||||||
.collect {
|
|
||||||
case (a, f) => a.url -> f
|
|
||||||
}
|
|
||||||
|
|
||||||
val compileDeps = configDependencies(baseConfig)
|
|
||||||
val shadedDeps = configDependencies(shadedConf)
|
|
||||||
|
|
||||||
val compileOnlyDeps = compileDeps.filterNot(shadedDeps.toSet)
|
|
||||||
|
|
||||||
log.debug(
|
|
||||||
s"Found ${compileDeps.size} dependencies in $baseConfig\n" +
|
|
||||||
compileDeps.toVector.map(" " + _).sorted.mkString("\n")
|
|
||||||
)
|
|
||||||
log.debug(
|
|
||||||
s"Found ${compileOnlyDeps.size} dependencies only in $baseConfig\n" +
|
|
||||||
compileOnlyDeps.toVector.map(" " + _).sorted.mkString("\n")
|
|
||||||
)
|
|
||||||
log.debug(
|
|
||||||
s"Found ${shadedDeps.size} dependencies in $shadedConf\n" +
|
|
||||||
shadedDeps.toVector.map(" " + _).sorted.mkString("\n")
|
|
||||||
)
|
|
||||||
|
|
||||||
def files(deps: Seq[Dependency]) = res
|
|
||||||
.subset(deps)
|
|
||||||
.minDependencies
|
|
||||||
.toSeq
|
|
||||||
.flatMap(dependencyArtifacts.get)
|
|
||||||
.flatten
|
|
||||||
.map(_._2.url)
|
|
||||||
.flatMap(artifactFilesOrErrors0.get)
|
|
||||||
|
|
||||||
val noShadeJars = files(compileOnlyDeps)
|
|
||||||
val allShadedConfJars = files(shadedDeps)
|
|
||||||
|
|
||||||
log.debug(
|
|
||||||
s"Found ${noShadeJars.length} JAR(s) only in $baseConfig\n" +
|
|
||||||
noShadeJars.map(" " + _).sorted.mkString("\n")
|
|
||||||
)
|
|
||||||
log.debug(
|
|
||||||
s"Found ${allShadedConfJars.length} JAR(s) in $shadedConf\n" +
|
|
||||||
allShadedConfJars.map(" " + _).sorted.mkString("\n")
|
|
||||||
)
|
|
||||||
|
|
||||||
allShadedConfJars.filterNot(noShadeJars.toSet)
|
|
||||||
}
|
|
||||||
|
|
||||||
def toShadeClasses(
|
|
||||||
shadeNamespaces: Set[String],
|
|
||||||
toShadeJars: Seq[File],
|
|
||||||
log: sbt.Logger
|
|
||||||
): Seq[String] = {
|
|
||||||
|
|
||||||
log.info(
|
|
||||||
s"Shading ${toShadeJars.length} JAR(s):\n" +
|
|
||||||
toShadeJars.map(" " + _).sorted.mkString("\n")
|
|
||||||
)
|
|
||||||
|
|
||||||
val toShadeClasses0 = toShadeJars.flatMap(jarClassNames)
|
|
||||||
|
|
||||||
log.info(s"Found ${toShadeClasses0.length} class(es) in JAR(s) to be shaded")
|
|
||||||
log.debug(toShadeClasses0.map(" " + _).sorted.mkString("\n"))
|
|
||||||
|
|
||||||
val toShadeClasses = shadeNamespaces.toVector.sorted.foldLeft(toShadeClasses0) {
|
|
||||||
(toShade, namespace) =>
|
|
||||||
val prefix = namespace + "."
|
|
||||||
val (filteredOut, remaining) = toShade.partition(_.startsWith(prefix))
|
|
||||||
|
|
||||||
log.info(s"${filteredOut.length} classes already filtered out by shaded namespace $namespace")
|
|
||||||
log.debug(filteredOut.map(" " + _).sorted.mkString("\n"))
|
|
||||||
|
|
||||||
remaining
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shadeNamespaces.nonEmpty) {
|
|
||||||
log.info(s"${toShadeClasses.length} remaining class(es) to be shaded")
|
|
||||||
log.debug(toShadeClasses.map(" " + _).sorted.mkString("\n"))
|
|
||||||
}
|
|
||||||
|
|
||||||
toShadeClasses
|
|
||||||
}
|
|
||||||
|
|
||||||
def createPackage(
|
|
||||||
baseJar: File,
|
|
||||||
shadingNamespace: String,
|
|
||||||
shadeNamespaces: Set[String],
|
|
||||||
toShadeClasses: Seq[String],
|
|
||||||
toShadeJars: Seq[File]
|
|
||||||
) = {
|
|
||||||
|
|
||||||
val outputJar = new File(
|
|
||||||
baseJar.getParentFile,
|
|
||||||
baseJar.getName.stripSuffix(".jar") + "-shading.jar"
|
|
||||||
)
|
|
||||||
|
|
||||||
def rename(from: String, to: String): Rule = {
|
|
||||||
val rule = new Rule
|
|
||||||
rule.setPattern(from)
|
|
||||||
rule.setResult(to)
|
|
||||||
rule
|
|
||||||
}
|
|
||||||
|
|
||||||
val nsRules = shadeNamespaces.toVector.sorted.map { namespace =>
|
|
||||||
rename(namespace + ".**", shadingNamespace + ".@0")
|
|
||||||
}
|
|
||||||
val clsRules = toShadeClasses.map { cls =>
|
|
||||||
rename(cls, shadingNamespace + ".@0")
|
|
||||||
}
|
|
||||||
|
|
||||||
val processor = JJProcessor(nsRules ++ clsRules, verbose = false, skipManifest = false)
|
|
||||||
CoursierJarProcessor.run((baseJar +: toShadeJars).toArray, outputJar, processor.proc, true)
|
|
||||||
|
|
||||||
outputJar
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,164 +0,0 @@
|
||||||
package coursier
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
import coursier.core.Configuration
|
|
||||||
import coursier.ivy.IvyXml.{mappings => ivyXmlMappings}
|
|
||||||
import lmcoursier.definitions.{ToCoursier, Configuration => DConfiguration}
|
|
||||||
import coursier.sbtcoursier.{CoursierPlugin, InputsTasks, Keys}
|
|
||||||
import coursier.sbtcoursiershared.{IvyXml, SbtCoursierShared}
|
|
||||||
import sbt.Keys._
|
|
||||||
import sbt.{AutoPlugin, Compile, SettingKey, TaskKey, inConfig}
|
|
||||||
|
|
||||||
object ShadingPlugin extends AutoPlugin {
|
|
||||||
|
|
||||||
override def trigger = noTrigger
|
|
||||||
|
|
||||||
override def requires = CoursierPlugin
|
|
||||||
|
|
||||||
private val baseSbtConfiguration = Compile
|
|
||||||
val Shading = sbt.Configuration.of(
|
|
||||||
id = "Shading",
|
|
||||||
name = "shading",
|
|
||||||
description = "",
|
|
||||||
isPublic = false,
|
|
||||||
Vector(baseSbtConfiguration),
|
|
||||||
transitive = true
|
|
||||||
)
|
|
||||||
|
|
||||||
private val baseDependencyConfiguration = Configuration("compile")
|
|
||||||
val Shaded = sbt.Configuration.of(
|
|
||||||
id = "Shaded",
|
|
||||||
name = "shaded",
|
|
||||||
description = "",
|
|
||||||
isPublic = true,
|
|
||||||
Vector(),
|
|
||||||
transitive = true
|
|
||||||
)
|
|
||||||
|
|
||||||
val shadingNamespace = SettingKey[String]("shading-namespace")
|
|
||||||
|
|
||||||
val shadeNamespaces = SettingKey[Set[String]]("shade-namespaces")
|
|
||||||
|
|
||||||
val toShadeJars = TaskKey[Seq[File]]("to-shade-jars")
|
|
||||||
val toShadeClasses = TaskKey[Seq[String]]("to-shade-classes")
|
|
||||||
|
|
||||||
object autoImport {
|
|
||||||
|
|
||||||
/** Scope for shading related tasks */
|
|
||||||
val Shading = ShadingPlugin.Shading
|
|
||||||
|
|
||||||
/** Ivy configuration for shaded dependencies */
|
|
||||||
val Shaded = ShadingPlugin.Shaded
|
|
||||||
|
|
||||||
/** Namespace under which shaded things will be moved */
|
|
||||||
val shadingNamespace = ShadingPlugin.shadingNamespace
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Assume everything under these namespaces is to be shaded.
|
|
||||||
*
|
|
||||||
* Allows to speed the shading phase, if everything under some namespaces is to be shaded.
|
|
||||||
*/
|
|
||||||
val shadeNamespaces = ShadingPlugin.shadeNamespaces
|
|
||||||
|
|
||||||
val toShadeJars = ShadingPlugin.toShadeJars
|
|
||||||
val toShadeClasses = ShadingPlugin.toShadeClasses
|
|
||||||
}
|
|
||||||
|
|
||||||
// same as similar things under sbt.Classpaths, tweaking a bit the configuration scope
|
|
||||||
lazy val shadingDefaultArtifactTasks =
|
|
||||||
makePom +: Seq(packageBin, packageSrc, packageDoc).map(_.in(Shading))
|
|
||||||
lazy val shadingJvmPublishSettings = Seq(
|
|
||||||
artifacts := sbt.Classpaths.artifactDefs(shadingDefaultArtifactTasks).value,
|
|
||||||
packagedArtifacts := sbt.Classpaths.packaged(shadingDefaultArtifactTasks).value
|
|
||||||
)
|
|
||||||
|
|
||||||
import coursier.sbtcoursier.CoursierPlugin.autoImport._
|
|
||||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
|
||||||
|
|
||||||
override lazy val buildSettings = super.buildSettings ++ Seq(
|
|
||||||
shadeNamespaces := Set()
|
|
||||||
)
|
|
||||||
|
|
||||||
override lazy val projectSettings =
|
|
||||||
Seq(
|
|
||||||
coursierConfigurations := InputsTasks.coursierConfigurationsTask(
|
|
||||||
Some(baseDependencyConfiguration.value -> Configuration(Shaded.name))
|
|
||||||
).value,
|
|
||||||
ivyConfigurations := Shaded +: ivyConfigurations.value.map {
|
|
||||||
conf =>
|
|
||||||
if (conf.name == "compile")
|
|
||||||
conf.extend(Shaded)
|
|
||||||
else
|
|
||||||
conf
|
|
||||||
}
|
|
||||||
) ++
|
|
||||||
inConfig(Shading)(
|
|
||||||
sbt.Defaults.configSettings ++
|
|
||||||
sbt.Classpaths.ivyBaseSettings ++
|
|
||||||
sbt.Classpaths.ivyPublishSettings ++
|
|
||||||
shadingJvmPublishSettings ++
|
|
||||||
SbtCoursierShared.settings(pubSettings = false) ++
|
|
||||||
CoursierPlugin.coursierSettings(
|
|
||||||
Some(baseDependencyConfiguration.value -> Configuration(Shaded.name))
|
|
||||||
) ++
|
|
||||||
IvyXml.generateIvyXmlSettings(Some(lmcoursier.definitions.Configuration(Shaded.name))) ++
|
|
||||||
Seq(SbtCoursierShared.publicationsSetting(Seq(Shading -> DConfiguration("compile")))) ++
|
|
||||||
CoursierPlugin.treeSettings ++
|
|
||||||
Seq(
|
|
||||||
configuration := baseSbtConfiguration, // wuw
|
|
||||||
ivyConfigurations := ivyConfigurations.in(baseSbtConfiguration).value
|
|
||||||
.filter(_.name != Shaded.name)
|
|
||||||
.map(c => c.withExtendsConfigs(c.extendsConfigs.filter(_.name != Shaded.name))),
|
|
||||||
libraryDependencies := libraryDependencies.in(baseSbtConfiguration).value.filter { dep =>
|
|
||||||
val isShaded = dep.configurations.exists { mappings =>
|
|
||||||
ivyXmlMappings(mappings).exists(_._1 == Configuration(Shaded.name))
|
|
||||||
}
|
|
||||||
|
|
||||||
!isShaded
|
|
||||||
},
|
|
||||||
// required for cross-projects in particular
|
|
||||||
unmanagedSourceDirectories := (unmanagedSourceDirectories in Compile).value,
|
|
||||||
toShadeJars := {
|
|
||||||
coursier.Shading.toShadeJars(
|
|
||||||
ToCoursier.project(coursierProject.in(baseSbtConfiguration).value),
|
|
||||||
coursierResolutions
|
|
||||||
.in(baseSbtConfiguration)
|
|
||||||
.value
|
|
||||||
.collectFirst {
|
|
||||||
case (configs, res) if configs(baseDependencyConfiguration) =>
|
|
||||||
res
|
|
||||||
}
|
|
||||||
.getOrElse {
|
|
||||||
sys.error(s"Resolution for configuration $baseDependencyConfiguration not found")
|
|
||||||
},
|
|
||||||
coursierConfigurations.in(baseSbtConfiguration).value,
|
|
||||||
Keys.coursierArtifacts.in(baseSbtConfiguration).value,
|
|
||||||
classpathTypes.value.map(Type(_)),
|
|
||||||
baseDependencyConfiguration,
|
|
||||||
Configuration(Shaded.name),
|
|
||||||
streams.value.log
|
|
||||||
)
|
|
||||||
},
|
|
||||||
toShadeClasses := {
|
|
||||||
coursier.Shading.toShadeClasses(
|
|
||||||
shadeNamespaces.value,
|
|
||||||
toShadeJars.value,
|
|
||||||
streams.value.log
|
|
||||||
)
|
|
||||||
},
|
|
||||||
packageBin := {
|
|
||||||
coursier.Shading.createPackage(
|
|
||||||
packageBin.in(baseSbtConfiguration).value,
|
|
||||||
shadingNamespace.?.value.getOrElse {
|
|
||||||
throw new NoSuchElementException("shadingNamespace key not set")
|
|
||||||
},
|
|
||||||
shadeNamespaces.value,
|
|
||||||
toShadeClasses.value,
|
|
||||||
toShadeJars.value
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package org.pantsbuild.jarjar
|
|
||||||
|
|
||||||
// from https://github.com/sbt/sbt-assembly/blob/17786404117889e5a8225c97b9b7639160fb91e8/src/main/scala/org/pantsbuild/jarjar/JJProcessor.scala
|
|
||||||
|
|
||||||
import org.pantsbuild.jarjar.util.{EntryStruct, JarProcessor}
|
|
||||||
|
|
||||||
import scala.collection.JavaConverters._
|
|
||||||
|
|
||||||
class JJProcessor(val proc: JarProcessor) {
|
|
||||||
|
|
||||||
def process(entry: EntryStruct): Boolean = proc.process(entry)
|
|
||||||
|
|
||||||
def getExcludes(): Set[String] = {
|
|
||||||
val field = proc.getClass().getDeclaredField("kp")
|
|
||||||
field.setAccessible(true)
|
|
||||||
val keepProcessor = field.get(proc)
|
|
||||||
|
|
||||||
if (keepProcessor == null) Set()
|
|
||||||
else {
|
|
||||||
val method = proc.getClass().getDeclaredMethod("getExcludes")
|
|
||||||
method.setAccessible(true)
|
|
||||||
method.invoke(proc).asInstanceOf[java.util.Set[String]].asScala.toSet
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
object JJProcessor {
|
|
||||||
|
|
||||||
def apply(patterns: Seq[PatternElement], verbose: Boolean, skipManifest: Boolean): JJProcessor =
|
|
||||||
new JJProcessor(new MainProcessor(patterns.asJava, verbose, skipManifest))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
|
|
||||||
lazy val root = crossProject
|
|
||||||
.in(file("."))
|
|
||||||
.jvmConfigure(
|
|
||||||
_.enablePlugins(coursier.ShadingPlugin)
|
|
||||||
)
|
|
||||||
.jvmSettings(
|
|
||||||
shadingNamespace := "test.shaded",
|
|
||||||
libraryDependencies += "io.argonaut" %% "argonaut" % "6.2-RC2" % "shaded"
|
|
||||||
)
|
|
||||||
.settings(
|
|
||||||
scalaVersion := "2.11.12",
|
|
||||||
organization := "io.get-coursier.test",
|
|
||||||
name := "shading-cross-test",
|
|
||||||
version := "0.1.0-SNAPSHOT",
|
|
||||||
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
|
|
||||||
)
|
|
||||||
|
|
||||||
lazy val jvm = root.jvm
|
|
||||||
lazy val js = root.js
|
|
||||||
Binary file not shown.
|
|
@ -1,21 +0,0 @@
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
import argonaut._
|
|
||||||
|
|
||||||
import Foo._
|
|
||||||
|
|
||||||
object Main extends App {
|
|
||||||
|
|
||||||
val expectedClassName0 = expectedClassName(args.headOption == Some("--shaded"))
|
|
||||||
|
|
||||||
Console.err.println(s"Expected class name: $expectedClassName0")
|
|
||||||
Console.err.println(s"Class name: $className")
|
|
||||||
|
|
||||||
if (className != expectedClassName0)
|
|
||||||
sys.error(s"Expected class name $expectedClassName0, got $className")
|
|
||||||
|
|
||||||
val msg = Json.obj().nospaces
|
|
||||||
|
|
||||||
Files.write(new File("output").toPath, msg.getBytes("UTF-8"))
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
val pluginVersion = sys.props.getOrElse(
|
|
||||||
"plugin.version",
|
|
||||||
throw new RuntimeException(
|
|
||||||
"""|The system property 'plugin.version' is not defined.
|
|
||||||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
addSbtPlugin("io.get-coursier" % "sbt-shading" % pluginVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.25")
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
import argonaut._
|
|
||||||
|
|
||||||
object Foo {
|
|
||||||
|
|
||||||
def expectedClassName(shaded: Boolean) =
|
|
||||||
if (shaded)
|
|
||||||
"test.shaded.argonaut.Json"
|
|
||||||
else
|
|
||||||
// Don't use the literal "argonaut.Json", that seems to get
|
|
||||||
// changed to "test.shaded.argonaut.Json" by shading
|
|
||||||
"argonaut" + '.' + "Json"
|
|
||||||
|
|
||||||
val className = classOf[Json].getName
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
$ delete output
|
|
||||||
> rootJVM/run
|
|
||||||
$ exists output
|
|
||||||
$ delete output
|
|
||||||
> rootJVM/publishLocal
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-cross-test_2.11:0.1.0-SNAPSHOT
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-cross-test_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
> rootJVM/shading:publishLocal
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-cross-test_2.11:0.1.0-SNAPSHOT
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-cross-test_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
|
|
||||||
enablePlugins(coursier.ShadingPlugin)
|
|
||||||
shadingNamespace := "test.shaded"
|
|
||||||
shadeNamespaces += "argonaut"
|
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
|
||||||
"com.github.alexarchambault" %% "argonaut-shapeless_6.2" % "1.2.0-M5" % "shaded",
|
|
||||||
// directly depending on that one for it not to be shaded
|
|
||||||
"org.scala-lang" % "scala-reflect" % scalaVersion.value
|
|
||||||
)
|
|
||||||
|
|
||||||
excludeDependencies += sbt.ExclusionRule("com.chuusai", "shapeless_2.11")
|
|
||||||
|
|
||||||
scalaVersion := "2.11.8"
|
|
||||||
organization := "io.get-coursier.test"
|
|
||||||
name := "shading-exclude-dependencies"
|
|
||||||
version := "0.1.0-SNAPSHOT"
|
|
||||||
Binary file not shown.
|
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
val pluginVersion = sys.props.getOrElse(
|
|
||||||
"plugin.version",
|
|
||||||
throw new RuntimeException(
|
|
||||||
"""|The system property 'plugin.version' is not defined.
|
|
||||||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
addSbtPlugin("io.get-coursier" % "sbt-shading" % pluginVersion)
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
import argonaut._
|
|
||||||
|
|
||||||
object Main extends App {
|
|
||||||
|
|
||||||
def excludeCheck(): Unit = {
|
|
||||||
val className = "shapeless.HList"
|
|
||||||
val loader = Thread.currentThread.getContextClassLoader
|
|
||||||
|
|
||||||
val found =
|
|
||||||
try {
|
|
||||||
loader.loadClass(className)
|
|
||||||
true
|
|
||||||
} catch {
|
|
||||||
case _: java.lang.ClassNotFoundException => false
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(!found, s"Expected class $className not to be found")
|
|
||||||
}
|
|
||||||
|
|
||||||
excludeCheck()
|
|
||||||
|
|
||||||
val expectedClassName =
|
|
||||||
if (args.contains("--shaded"))
|
|
||||||
"test.shaded.argonaut.Json"
|
|
||||||
else
|
|
||||||
// Don't use the literal "argonaut.Json", that seems to get
|
|
||||||
// changed to "test.shaded.argonaut.Json" by shading
|
|
||||||
"argonaut" + '.' + "Json"
|
|
||||||
|
|
||||||
val className = classOf[Json].getName
|
|
||||||
|
|
||||||
Console.err.println(s"Expected class name: $expectedClassName")
|
|
||||||
Console.err.println(s"Class name: $className")
|
|
||||||
|
|
||||||
if (className != expectedClassName)
|
|
||||||
sys.error(s"Expected class name $expectedClassName, got $className")
|
|
||||||
|
|
||||||
val msg = Json.obj().nospaces
|
|
||||||
|
|
||||||
Files.write(new File("output").toPath, msg.getBytes("UTF-8"))
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
$ delete output
|
|
||||||
> run
|
|
||||||
$ exists output
|
|
||||||
> publishLocal
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-exclude-dependencies_2.11:0.1.0-SNAPSHOT
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-exclude-dependencies_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
> shading:publishLocal
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-exclude-dependencies_2.11:0.1.0-SNAPSHOT
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-exclude-dependencies_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
|
|
||||||
enablePlugins(coursier.ShadingPlugin)
|
|
||||||
shadingNamespace := "test.shaded"
|
|
||||||
|
|
||||||
shadeNamespaces += "argonaut"
|
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
|
||||||
"io.argonaut" %% "argonaut" % "6.2-RC2" % "shaded",
|
|
||||||
// directly depending on that one for it not to be shaded
|
|
||||||
"org.scala-lang" % "scala-reflect" % scalaVersion.value
|
|
||||||
)
|
|
||||||
|
|
||||||
scalaVersion := "2.11.8"
|
|
||||||
organization := "io.get-coursier.test"
|
|
||||||
name := "shading-base-test"
|
|
||||||
version := "0.1.0-SNAPSHOT"
|
|
||||||
|
|
||||||
lazy val checkToShadeClasses = TaskKey[Unit]("check-to-shade-classes")
|
|
||||||
|
|
||||||
checkToShadeClasses := {
|
|
||||||
val toShadeClasses0 = toShadeClasses.in(Shading).value
|
|
||||||
val log = streams.value.log
|
|
||||||
|
|
||||||
if (toShadeClasses0.nonEmpty) {
|
|
||||||
log.error(s"Found ${toShadeClasses0.length} classes to be explicitly shaded")
|
|
||||||
for (name <- toShadeClasses0)
|
|
||||||
log.error(" " + name)
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(toShadeClasses0.isEmpty)
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
val pluginVersion = sys.props.getOrElse(
|
|
||||||
"plugin.version",
|
|
||||||
throw new RuntimeException(
|
|
||||||
"""|The system property 'plugin.version' is not defined.
|
|
||||||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
addSbtPlugin("io.get-coursier" % "sbt-shading" % pluginVersion)
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
import argonaut._
|
|
||||||
|
|
||||||
object Main extends App {
|
|
||||||
|
|
||||||
val expectedClassName =
|
|
||||||
if (args.headOption == Some("--shaded"))
|
|
||||||
"test.shaded.argonaut.Json"
|
|
||||||
else
|
|
||||||
// Don't use the literal "argonaut.Json", that seems to get
|
|
||||||
// changed to "test.shaded.argonaut.Json" by shading
|
|
||||||
"argonaut" + '.' + "Json"
|
|
||||||
|
|
||||||
val className = classOf[Json].getName
|
|
||||||
|
|
||||||
Console.err.println(s"Expected class name: $expectedClassName")
|
|
||||||
Console.err.println(s"Class name: $className")
|
|
||||||
|
|
||||||
if (className != expectedClassName)
|
|
||||||
sys.error(s"Expected class name $expectedClassName, got $className")
|
|
||||||
|
|
||||||
val msg = Json.obj().nospaces
|
|
||||||
|
|
||||||
Files.write(new File("output").toPath, msg.getBytes("UTF-8"))
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
$ delete output
|
|
||||||
> checkToShadeClasses
|
|
||||||
> run
|
|
||||||
$ exists output
|
|
||||||
> publishLocal
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-base-test_2.11:0.1.0-SNAPSHOT
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-base-test_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
> shading:publishLocal
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-base-test_2.11:0.1.0-SNAPSHOT
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-base-test_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
|
|
||||||
enablePlugins(coursier.ShadingPlugin)
|
|
||||||
shadingNamespace := "test.shaded"
|
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
|
||||||
"io.argonaut" %% "argonaut" % "6.2-RC2" % "shaded",
|
|
||||||
"org.scala-lang" % "scala-reflect" % scalaVersion.value // not shading that one
|
|
||||||
)
|
|
||||||
|
|
||||||
scalaVersion := "2.11.8"
|
|
||||||
organization := "io.get-coursier.test"
|
|
||||||
name := "shading-base-test"
|
|
||||||
version := "0.1.0-SNAPSHOT"
|
|
||||||
Binary file not shown.
|
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
val pluginVersion = sys.props.getOrElse(
|
|
||||||
"plugin.version",
|
|
||||||
throw new RuntimeException(
|
|
||||||
"""|The system property 'plugin.version' is not defined.
|
|
||||||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
addSbtPlugin("io.get-coursier" % "sbt-shading" % pluginVersion)
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
import argonaut._
|
|
||||||
|
|
||||||
object Main extends App {
|
|
||||||
|
|
||||||
val expectedClassName =
|
|
||||||
if (args.headOption == Some("--shaded"))
|
|
||||||
"test.shaded.argonaut.Json"
|
|
||||||
else
|
|
||||||
// Don't use the literal "argonaut.Json", that seems to get
|
|
||||||
// changed to "test.shaded.argonaut.Json" by shading
|
|
||||||
"argonaut" + '.' + "Json"
|
|
||||||
|
|
||||||
val className = classOf[Json].getName
|
|
||||||
|
|
||||||
Console.err.println(s"Expected class name: $expectedClassName")
|
|
||||||
Console.err.println(s"Class name: $className")
|
|
||||||
|
|
||||||
if (className != expectedClassName)
|
|
||||||
sys.error(s"Expected class name $expectedClassName, got $className")
|
|
||||||
|
|
||||||
val msg = Json.obj().nospaces
|
|
||||||
|
|
||||||
Files.write(new File("output").toPath, msg.getBytes("UTF-8"))
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
$ delete output
|
|
||||||
> run
|
|
||||||
$ exists output
|
|
||||||
> publishLocal
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-base-test_2.11:0.1.0-SNAPSHOT
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-base-test_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
> shading:publishLocal
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-base-test_2.11:0.1.0-SNAPSHOT
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-base-test_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
|
|
||||||
enablePlugins(coursier.ShadingPlugin)
|
|
||||||
shadingNamespace := "test.shaded"
|
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
|
||||||
"com.github.alexarchambault" %% "argonaut-shapeless_6.2" % "1.2.0-M4" % "shaded",
|
|
||||||
"com.chuusai" %% "shapeless" % "2.3.2",
|
|
||||||
"org.scala-lang" % "scala-reflect" % scalaVersion.value
|
|
||||||
)
|
|
||||||
|
|
||||||
scalaVersion := "2.11.8"
|
|
||||||
organization := "io.get-coursier.test"
|
|
||||||
name := "shading-transitive-test"
|
|
||||||
version := "0.1.0-SNAPSHOT"
|
|
||||||
Binary file not shown.
|
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
val pluginVersion = sys.props.getOrElse(
|
|
||||||
"plugin.version",
|
|
||||||
throw new RuntimeException(
|
|
||||||
"""|The system property 'plugin.version' is not defined.
|
|
||||||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
addSbtPlugin("io.get-coursier" % "sbt-shading" % pluginVersion)
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
import argonaut._
|
|
||||||
|
|
||||||
object Main extends App {
|
|
||||||
|
|
||||||
val expectedClassName =
|
|
||||||
if (args.headOption == Some("--shaded"))
|
|
||||||
"test.shaded.argonaut.Json"
|
|
||||||
else
|
|
||||||
// Don't use the literal "argonaut.Json", that seems to get
|
|
||||||
// changed to "test.shaded.argonaut.Json" by shading
|
|
||||||
"argonaut" + '.' + "Json"
|
|
||||||
|
|
||||||
val className = classOf[Json].getName
|
|
||||||
|
|
||||||
Console.err.println(s"Expected class name: $expectedClassName")
|
|
||||||
Console.err.println(s"Class name: $className")
|
|
||||||
|
|
||||||
if (className != expectedClassName)
|
|
||||||
sys.error(s"Expected class name $expectedClassName, got $className")
|
|
||||||
|
|
||||||
val msg = Json.obj().nospaces
|
|
||||||
|
|
||||||
Files.write(new File("output").toPath, msg.getBytes("UTF-8"))
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
$ delete output
|
|
||||||
> run
|
|
||||||
$ exists output
|
|
||||||
> publishLocal
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-transitive-test_2.11:0.1.0-SNAPSHOT
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-transitive-test_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
> shading:publishLocal
|
|
||||||
-$ exec java -jar coursier launch io.get-coursier.test:shading-transitive-test_2.11:0.1.0-SNAPSHOT
|
|
||||||
$ exec java -jar coursier launch io.get-coursier.test:shading-transitive-test_2.11:0.1.0-SNAPSHOT -- --shaded
|
|
||||||
|
|
@ -6,7 +6,6 @@ import sbt.Keys._
|
||||||
import sbt.ScriptedPlugin.autoImport.{scriptedBufferLog, scriptedLaunchOpts}
|
import sbt.ScriptedPlugin.autoImport.{scriptedBufferLog, scriptedLaunchOpts}
|
||||||
|
|
||||||
import com.jsuereth.sbtpgp._
|
import com.jsuereth.sbtpgp._
|
||||||
import coursier.ShadingPlugin.autoImport.{Shading, shadingNamespace}
|
|
||||||
|
|
||||||
object Settings {
|
object Settings {
|
||||||
|
|
||||||
|
|
@ -65,19 +64,6 @@ object Settings {
|
||||||
sbtVersion.in(pluginCrossBuild) := targetSbtVersion
|
sbtVersion.in(pluginCrossBuild) := targetSbtVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val shading =
|
|
||||||
inConfig(Shading)(PgpSettings.projectSettings) ++
|
|
||||||
// Why does this have to be repeated here?
|
|
||||||
// Can't figure out why configuration gets lost without this in particular...
|
|
||||||
coursier.ShadingPlugin.projectSettings ++
|
|
||||||
Seq(
|
|
||||||
shadingNamespace := "coursier.shaded",
|
|
||||||
publish := publish.in(Shading).value,
|
|
||||||
publishLocal := publishLocal.in(Shading).value,
|
|
||||||
PgpKeys.publishSigned := PgpKeys.publishSigned.in(Shading).value,
|
|
||||||
PgpKeys.publishLocalSigned := PgpKeys.publishLocalSigned.in(Shading).value
|
|
||||||
)
|
|
||||||
|
|
||||||
lazy val generatePropertyFile =
|
lazy val generatePropertyFile =
|
||||||
resourceGenerators.in(Compile) += Def.task {
|
resourceGenerators.in(Compile) += Def.task {
|
||||||
import sys.process._
|
import sys.process._
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@ addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")
|
||||||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.7.0")
|
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.7.0")
|
||||||
|
|
||||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "2.0.0-RC5-3")
|
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "2.0.0-RC5-3")
|
||||||
addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.0.0-RC5-3")
|
addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.0.0")
|
||||||
|
|
||||||
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
|
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue