Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load.ivy where a classifier is required #387

Closed
laurencer opened this issue May 9, 2016 · 4 comments
Closed

Cannot load.ivy where a classifier is required #387

laurencer opened this issue May 9, 2016 · 4 comments
Labels

Comments

@laurencer
Copy link

@laurencer laurencer commented May 9, 2016

In sbt you can normally specify the classifier - e.g.

libraryDependencies ++= "net.sf.json-lib" % "json-lib" % "2.4" % "jdk15"

This doesn't work with load.ivy and its not clear how to load a JAR which requires a classifier.

@lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented May 20, 2017

This is fixed as of 662859f, which allows you to use coursier to add a classifier:

Welcome to the Ammonite Repl version-SNAPSHOT
(Scala 2.12.2 Java 1.8.0_112)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ interp.load.ivy(
    // Directly using coursier API. Can pass in exclusions,
    // attributes, configurations, classifiers, etc.
    coursier.Dependency(
      coursier.Module("net.sf.json-lib", "json-lib"),
      "2.4",
      attributes = coursier.Attributes(classifier = "jdk15")
    ),
    "xom" % "xom" % "1.1"
  )
https://repo1.maven.org/maven2/xom/xom/1.1/xom-1.1.pom
  100.0% [##########] 1.7 KiB (1.6 KiB / s)
https://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4.pom
  100.0% [##########] 12.8 KiB (11.2 KiB / s)
https://repo1.maven.org/maven2/xom/xom/1.1/xom-1.1.jar
  100.0% [##########] 421.5 KiB (336.9 KiB / s)
https://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4-jdk15.jar
  100.0% [##########] 155.4 KiB (120.5 KiB / s)

@ val serializer = new net.sf.json.xml.XMLSerializer
serializer: net.sf.json.xml.XMLSerializer = net.sf.json.xml.XMLSerializer@6d1c0769
@
@lihaoyi lihaoyi closed this May 20, 2017
@lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented May 21, 2017

@borice
Copy link

@borice borice commented Nov 25, 2020

@lihaoyi How is this supposed to work with the new version:
Welcome to the Ammonite Repl 2.2.0 (Scala 2.13.3 Java 1.8.0_252)

I see there's now a coursierapi, where Dependency and Module live, but not Attributes.

@borice
Copy link

@borice borice commented Nov 25, 2020

I found something that works.

interp.load.ivy(
      "edu.stanford.nlp"              %  "stanford-corenlp"     % "4.2.0",
      Dependency.of("edu.stanford.nlp", "stanford-corenlp", "4.2.0").withClassifier("models"),
      Dependency.of("edu.stanford.nlp", "stanford-corenlp", "4.2.0").withClassifier("models-english")
  ) 

would be nice if the syntax would more closely match what's used in SBT for simple copy-paste testing, like:

SBT:
      "edu.stanford.nlp"              %  "stanford-corenlp"     % "4.2.0",
      "edu.stanford.nlp"              %  "stanford-corenlp"     % "4.2.0" classifier "models" classifier "models-english"

to translate to:

interp.load.ivy(
      "edu.stanford.nlp"              %  "stanford-corenlp"     % "4.2.0",
      "edu.stanford.nlp"              %  "stanford-corenlp"     % "4.2.0" classifier "models" classifier "models-english"
)

or, even if it needs to be duplicated, something like:

interp.load.ivy(
      "edu.stanford.nlp"              %  "stanford-corenlp"     % "4.2.0",
      "edu.stanford.nlp"              %  "stanford-corenlp"     % "4.2.0" classifier "models",
      "edu.stanford.nlp"              %  "stanford-corenlp"     % "4.2.0" classifier "models-english"
)

would be nice, if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants