GithubHelp home page GithubHelp logo

missing META-INF artifacts about sbt-assembly HOT 14 CLOSED

sbt avatar sbt commented on July 23, 2024
missing META-INF artifacts

from sbt-assembly.

Comments (14)

eed3si9n avatar eed3si9n commented on July 23, 2024

Everything directly under META-INF are excluded by design. Try this:

excludedFiles in Assembly := { (base: Seq[File]) => Nil }

conflictingFiles  in Assembly := { (base: Seq[File]) => Nil }

from sbt-assembly.

rollinsruss avatar rollinsruss commented on July 23, 2024

Added that per your suggestion, now receiving:

java.lang.RuntimeException: Could not create directory /var/folders/g5/g5ooF8+7EvCDdAf+Xv+ZfU+++TI/-Tmp-/sbt_dd73df93/META-INF/license: file exists and is not a directory.

from sbt-assembly.

eed3si9n avatar eed3si9n commented on July 23, 2024

So you have to exclude license files.

excludedFiles in Assembly := { (base: Seq[File]) => (base / "META-INF" / "license").get }

conflictingFiles  in Assembly := { (base: Seq[File]) => (base / "META-INF" / "license").get }

You get the idea..

from sbt-assembly.

rollinsruss avatar rollinsruss commented on July 23, 2024

Thanks, appreciate the tip, I wondered how nasty it might be to reconcile potential collisions from the dependencies.

from sbt-assembly.

rollinsruss avatar rollinsruss commented on July 23, 2024

So looks like the case is for a license directory, even with the exclusion/conflicting setting I'm still getting this error. After multiple sbt reloads and restarts. Being new, not sure if it has anything to do with the line below, where the isFile is being evaluated and my case (not sure which jar) has a directory?

private def assemblyExcludedFiles(base: Seq[File]): Seq[File] =
    (base / "META-INF" * "*").get collect { case f if f.isFile => f }

from sbt-assembly.

eed3si9n avatar eed3si9n commented on July 23, 2024

I'll look into this later. Could you give me the name of the jars?

from sbt-assembly.

rollinsruss avatar rollinsruss commented on July 23, 2024

The jar that's providing the directory is netty-3.2.3.Final.jar, probably several in my dependency tree that have single license files that could be overwriting each other prior to even processing the directory case. I forked so I could get this working locally (since I found another case with missing META-INF files is hosing the runtime of my assembled deployment jar) and it dawned on me that this situation presents an unpleasant chicken-and-egg issue due to name/type collisions. So I started added some logic to simply move all license related dirs and files into a separate directory to avoid collisions and overwrites altogether. That being said, I keep coming back to thinking about the Maven assembly plugin that applies an alternative approach to unzipping everything and simply shoves the jars into an embedded lib directory and updates the manifest so the classpath is complete--which avoids this problem altogether and maintains pristine isolation. Perhaps that approach could be a future alternative task on this plugin (wish I had time to help, as it has me quite intrigued).

from sbt-assembly.

eed3si9n avatar eed3si9n commented on July 23, 2024

Not sure why license dir would cause problem if it's deleted right away.

That being said, I keep coming back to thinking about the Maven assembly plugin that applies an alternative approach to unzipping everything and simply shoves the jars into an embedded lib directory and updates the manifest so the classpath is complete--which avoids this problem altogether and maintains pristine isolation.

That's an interesting approach. Class file level exclusion filter won't work any more, but they're mostly to get around META-INF problems it seems. If the resulting jar can be made runnable, that could be the way to go.

from sbt-assembly.

rollinsruss avatar rollinsruss commented on July 23, 2024

So the real problem was the actual deletion, but the temp dir approach might be useful for ensuring all licenses are accounted for. In the end, here's what worked for me using version 0.5:

excludedFiles in Assembly := { (base: Seq[File]) => (base.head / "META-INF" / "license" * "*" ).get }

conflictingFiles  in Assembly := { (base: Seq[File]) =>
    val licConflicts  = base.head / "META-INF" / "license"
    val manifestConflicts = base.head / "META-INF" / "MANIFEST.MF"
    (licConflicts).get ++ (manifestConflicts).get }

Note that I had to call "head" to get the actual temp dir entry otherwise my entries were ignored.

For what it's worth, any project using Java Mail with the present version will have to at least have something defined for both conflictingFiles and excludingFiles or the assembled package will be missing a slew of critical files since the default case removes everything from META-INF (in which case, again favors the Maven-style approach http://goo.gl/wq4w5).

from sbt-assembly.

eed3si9n avatar eed3si9n commented on July 23, 2024

I am adopting your idea on excluding only license and MANIFEST.MF by default.

  private def assemblyExcludedFiles(bases: Seq[File]): Seq[File] =
    bases flatMap { base =>
      (base / "META-INF" * "*").get collect {
        case f if f.getName.toLowerCase == "license" => f
        case f if f.getName.toLowerCase == "manifest.mf" => f
      }
    }

I created #12 for maven-assembly-plugin mode, so let's keep talking there.

from sbt-assembly.

rollinsruss avatar rollinsruss commented on July 23, 2024

Along the lines of the "lib" recommendation in an earlier comment: http://stackoverflow.com/questions/7351280/collecting-dependencies-under-sbt-0-10-putting-all-dependency-jars-to-target-sca/7361492#7361492

from sbt-assembly.

eed3si9n avatar eed3si9n commented on July 23, 2024

I so tried to implement this, but it was more complicated than I thought. Class-Path entry in the manifest doesn't actually resolve the jar in jar, and instead you're supposed to provide a class loader. Good news is someone has already done the hard work: One-JAR™. Aslo retronym has already ported it to sbt-onejar.

from sbt-assembly.

rollinsruss avatar rollinsruss commented on July 23, 2024

Thanks, I'll check it out!

from sbt-assembly.

rain1024 avatar rain1024 commented on July 23, 2024

I got issue like this (http://stackoverflow.com/questions/25925233/deduplication-error-in-build-sbt-when-building-a-fat-jar-using-sbt-assembly).

But I don't know where I put

excludedFiles in assembly <<=
(excludedFiles in assembly) {
  (old) => (bases) =>
    old(bases) ++ (bases flatMap (base =>
      (base / "META-INF/ECLIPSEF.RSA").get))
}

I put this code to build.sbt in the root project but got error

/code//build.sbt:26: error: not found: value excludedFiles
excludedFiles in assembly <<= (excludedFiles in assembly) {
^
[error] Type error in expression

from sbt-assembly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.