sbt / sbt-assembly

Deploy über-JARs. Restart processes. (port of codahale/assembly-sbt)
MIT License
1.95k stars 224 forks source link

Verify that no duplicate classes are provided without building jar #395

Closed jcallin closed 4 years ago

jcallin commented 4 years ago

Hi, I'm looking into a way to verify that there are no classpath issues in a multi-project sbt build. Each project will eventually run the assembly task and build its own jar. Earlier in our build process, while verifying that a branch can be merged, it would be nice to run a task that does something similar to the applyStrategies function in Assembly.scala. Is there a way to verify that no classpath issues exist without building the actual jar?

eed3si9n commented 4 years ago

Not really. You can either copy-paste some portion of Assembly.apply yourself, or maybe send a pull request to split apply into two parts: input building and output building.

jcallin commented 4 years ago

For anyone wondering, I ended up implementing a custom task that calls Assembly.applyStrategies directly. It is usually called inside Assembly.apply (used by the assembly task) which then builds the jar. This excludes the jar building portion.

  def verifyAssembly(key: TaskKey[File]) = Def.task {
    val s = (streams in key).value

    val assemblyOptions = (assemblyOption in key).value
    Assembly.applyStrategies(
      (assembledMappings in key).value,
      assemblyOptions.mergeStrategy,
      assemblyOptions.assemblyDirectory,
      s.log
    )
  }