I'm using ammonite (http://ammonite.io/) to write Scala scripts. It allows you to fetch remote dependencies via this kind of text:
import $ivy.`org.scalaz::scalaz-core:7.2.7`, scalaz._, Scalaz._
How do you use a local maven repo (sitting in e.g. ~/.m2), though?
It changed in v 1.7.1
Now the correct way to do this is like this :
import coursierapi.MavenRepository
interp.repositories.update(
interp.repositories() ::: List(MavenRepository.of("https://some_repo"))
)
If you wish to link up a local repository, you can replace https://some_repo with file://path_to_local_rep
Thanks to #danslapman on github - here's the reference discussion https://github.com/lihaoyi/Ammonite/issues/1003
With many thanks to #sake92 on https://gitter.im/lihaoyi/Ammonite
#!/usr/bin/env amm
interp.repositories() ++= Seq(coursier.Cache.Dangerous.maven2Local)
#
import $ivy.`com.foo:artifact:1.3.0`
The # forces the script to be compiled in two parts. Without it the extra repo will simply be ignored.
There was an issue some time ago
with a following PR that concluded that there quite often local Maven repository contains broken things, so it is not there by default.
However, later ability to add your own resolvers was added, probably sth like:
import coursier.MavenRepository
interp.repositories() ++= Seq(MavenRepository(
"~/.m2/local"
))
should work.
Related
I have a lot of successful rest accesses in grails 2.x.x
I simply coded
import grails.plugins.rest.client.*
import grails.util.Holders
import org.codehaus.groovy.grails.web.json.JSONObject
import org.codehaus.groovy.grails.web.json.JSONArray
and Classes JSONObject, JSONArray, RestBuilder, RestResponse where available for further use.
What are the corresponding imports in 4.0.1 and what jars resp. what lines in build.gradle are necessary?
What are the corresponding imports in 4.0.1 and what jars resp. what
lines in build.gradle are necessary?
Grails 4 offers better options than to interact with the classes you asked about but to answer the question as asked...
org.grails.web.json.JSONObject is in grails-web-common-4.0.1.jar. Use import org.grails.web.json.JSONObject.
org.grails.web.json.JSONArray is in grails-web-common-4.0.1.jar. Use import org.grails.web.json.JSONArray.
grails.plugins.rest.client.RestBuilder is in grails-datastore-rest-client-6.1.12.RELEASE.jar. Use import grails.plugins.rest.client.RestBuilder.
grails.plugins.rest.client.RestResponse is in grails-datastore-rest-client-6.1.12.RELEASE.jar. Use import grails.plugins.rest.client.RestResponse.
Depending on what other dependencies you may have in your project those may or may not be pulled in transitively so you may not need to add them to your build.gradle directly. The most likely scenario is you won't need to add anything to pull in grails-web-common-4.0.1.jar but you probably will need to pull in grails-datastore-rest-client-6.1.12.RELEASE.jar which can be done by adding the following to your build.gradle:
compile "org.grails:grails-datastore-rest-client:6.1.12.RELEASE"
If you want to pull in grails-web-common explicitly you could use the following:
compile "org.grails:grails-web-common:4.0.1"
If you are using the BOM correctly, you could simplify that with the following:
compile "org.grails:grails-web-common"
I hope that helps.
I have a build.sbt file but I am not able to figure out the role of this import import docker.{addDockerPackage}
Is this an open source import? I am not able to find info about it. Further down in the script it calls a method addDockerPackage()
I wonder if the method is in that package? Or all this is some proprietary stuff? If it is a standard import, where do I read about it?
You can use sbt-native it has a Docker plugin:
http://www.scala-sbt.org/sbt-native-packager/formats/docker.html
Here are 4 different good example that you can run to see how it works:
https://github.com/marcuslonnberg/sbt-docker
As far as:
import docker.{addDockerPackage}
I don't think that is a package. It looks more like a helper to define something like this:
packageName in Docker := packageName.value
Currently, I used a plugin like this:
addSbtPlugin("com.tuplejump" % "sbt-yeoman" % "0.7.1")
But then, I fork this plugin on github (let's say https://github.com/myname/play-yeoman.git) and make some changes, what would be an easier way to use my forked version of plugin? Do I really have to register this fork on a maven/ivy repository?
Thanks!
Using SBT 0.13.8, I was able to replace the following line in my ./project/plugins.sbt:
addSbtPlugin("net.ground5hark.sbt" %% "sbt-concat" % "0.1.8")
with the following two lines
lazy val root = (project in file(".")).dependsOn(concatPlugin)
lazy val concatPlugin = uri("https://github.com/ground5hark/sbt-concat.git#342acc34195438799b8a278fda94b126238aae17")
No other steps were necessary. Also, note that the git URI has a commit hash on the end. This is very useful for ensuring a known-to-work, specific version of the source is used in the project, rather than whatever the latest unknown state of the source is.
Follow this steps:
Add -SNAPSHOT suffix to the version of the plugin, i.e. version := "1.0.0-SNAPSHOT"
Run sbt publishLocal from the command line.
Reference the snapshot version from your plugins.sbt.
I am writing an SBT Command and I can obtain the full list of resolved files for any project with
import UpdateReport._
(update in Test).value.allFiles
However, this does not include the -source and -javadoc files.
How do I programmatically re-run update so that it resolves and provides me the sources and docs in an UpdateReport? (i.e. re-run as if withSources and withJavadoc were applied to every ModuleID)
ok, this was trivial:
import UpdateReport._
(updateClassifiers in Test).value.allFiles
I want to add some fast local maven repository url to sbt, say:
http://maven.example.com/public
I want to add it to "global", so that I don't need to add them to each of sbt project. And also want to be tried first when sbt downloading some jars.
But I can't find useful information to do this, how to do it?
(My sbt version is 0.13.1)
With the help of a friend, finally I found the solution:
create a new file ~/.sbt/repositories
add content like this:
[repositories]
local
my-maven-repo: http://example.org/repo
my-ivy-repo: http://example.org/ivy-repo/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]
See official doc: http://www.scala-sbt.org/0.13.2/docs/Detailed-Topics/Library-Management.html#override-all-resolvers-for-all-builds
Modify your global configuration file, which is normally located in ~/.sbt/0.13/global.sbt, if it's not there you can create it.
In the file add following line:
externalResolvers := { ("Fast Repo" at "http://maven.example.com/public") +: externalResolvers.value }
You can confirm it's working by executing show externalResolvers in any project to see the list of resolvers. Your newly added resolver should be first.