I work for a java shop and we use JFROG artifactory.
I am trying to use Scala and SBT, but I see everyone doing Scala projects prefers to use maven with scala plugin.
I want to know what settings, configuration, I need to do in a SBT project so that it disables IVY altogether and my builds interact with the JFROG server just like maven would.
I figured out the answer. it is documented here
http://www.scala-sbt.org/0.13/docs/Using-Sonatype.html
Related
When creting a project in IntelliJ, I am given options for sbt, Lightbend Project Starter, IDEA, Play 2.x, Dotty(experimental). What do these options mean, and how could I learn more about them?
IDEA project, is just IDE configuration that let's you work with Scala... but it doesn't come with build system that you can easily configure, commit to git repo, etc - you basically would have to configure everything in IntelliJ yourself which is a pain.
Other options are sbt templates where sbt is a build tool for Scala:
sbt - creates empty build configuration and imports it to IDE
Lightbend Project Starter - a collection of templates with configurations seeded. In general sbt new template-name can generate a project using template name (github repository name of a template) and Lightbend prepared and maintains some of them
Play - sbt configurations for Play Framework
Dotty - sbt configuration for Dotty (experimiental Scala 3)
With them you have a build config that you can configure and import and check into git, that is used by IntelliJ to generate IDE configuration.
IDEA is something related to IntelliJ IDE.
SBT is a build tool(substitute for maven) for scala projects.
When you enable SBT option, it will add sbt related configuration, sbt shell, sbt options. You can choose sbt if your project is built upon sbt (means your project will have a build.sbt file).
The other options also can be opted only if your project folder demands it.
Dotty is the name of the future version of the language (Scala 3). See https://dotty.epfl.ch/.
In Eclipse in Preferences -> Scala -> Compiler -> Build manager, I can select a "buildmanager." What is the difference between "refined" and "sbt"?
Also, is this some method to integrate an sbt build file into the Eclipse IDE?
ScalaIDE has two build managers, basically they are interfaces between the eclipse model and the scala compiler, they have to do things like work out which resources need re-compiling and how that affects dependent code. Refined is a refined version of the original interface and sbt is, well, sbt.
SBT is the default now, and I expect refined will go away at some point.
Unfortunately the build manager is very much under the hood. There is no real eclipse project->sbt integration yet. There is an eclipse plugin for sbt which allows you to generate eclipse project files but no tight integration from an eclipse project to sbt akin to IvyDE or m2e.
You can use sbt deliver-local to create an ivy file of dependencies, and use IvyDE to keep your classpath containers up to date - that's about as good as it gets at the moment.
I wouldn't be surprised to see this situation improve though - check out the roadmap.
I am wondering what is the most efficient way to use Sbt and Eclipse together? There seems to be a Sbt Eclipse plugin but what is the generally recommended workflow post generating the eclipse config? It seems kind of wrong to then add dependencies via the Eclipse Maven plugin in Eclipse? Is that what people usually do though?
Kind of new to the ecosystem so maybe I'm missing something here.
I add maven dependencies in via the sbt config files. Then regenerate the eclipse project after each modification, keeping the sbt config as the definitive project specification. I suspect it's the only sane way to run the setup.
I use the IvyDE plugin for eclipse with sbt deliver-local.
The advantage here is it can give you separate classpath containers for different configurations easily and you don't need to blat your eclipse project settings regularly.
It'd be really nice if scala-ide supported tighter integration with sbt.
I am experimenting with a small Scalatra web application, which I have imported as a project into Eclipse.
I have used Eclipse to manage a few Lift applications before. With a Lift project, SBT copies all the dependency JAR's to a /lib_managed directory. I can therefore add those JAR's to Eclipse's build path, and it co-exists with SBT just fine without complaining about missing classes.
With Scalatra, however, the dependency JAR's don't seem to get copied anywhere helpful during the development cycle. If you build a WAR file, then the dependencies get bundled up into that... but there doesn't seem to be anything like Lift's /lib-managed directory.
Assuming that anyone else uses Eclipse in developing Scalatra projects, how might I easily set up Eclipse's build path? I suppose that I could manually create entries that point my local Ivy repository one-by-one, although that seems a bit ugly. Perhaps there's an easy way through SBT to setup something similar to Lift's /lib-managed subdirectory inside the project directory.
It looks like the best approach for this is using the SBT plugin for Eclipse.
This is not an "Eclipse plugin" for managing SBT. Rather, it's an "SBT plugin", for generating the .project and .classpath files used by Eclipse. The Maven world used to deal with Eclipse in a similar manner, before the m2eclipse Eclipse plugin reached maturity over the past couple years.
With this plugin installed (I installed it globally so I wouldn't have to change my project's files), you just type sbt eclipse after any changes to your dependencies. SBT will then update your Eclipse project files to match.
You could also use my Maven prototype, then simply import the maven project into Eclipse. Quite nice and you're not forced to use SBT.
https://github.com/fancellu/scalatra-maven-prototype
I'd be interested to find out about any automated processes that people have for ensuring that the project classpaths for the ant and eclipse configurations are in synch. In my case, I want the classpath defined in the ant build file to be the master configuration, since its used for our production builds. As part of the build i'd like to add an ant target that will verify that the eclipse classpath is up to date, or at least indicate differences between the two classpaths.
I'm aware of ant4eclipse but its focus is in the opposite direction, ensuring that the eclipse classpath is master and that the ant build reuses the eclipse path. I like the idea behind AntAndEclipse but am wondering are their ant other tools in this space that i'm not aware of.
You solution at a previous company was to have ant invoke Eclipse to do the compiles as described here:
http://www.eclipse.org/articles/Article-PDE-Automation/automation.html
I'm not aware of any ant tools which can do this but I've switched from ant to Maven a few years ago and never looked back. You can use the "Maven integration for Eclipse" to make Eclipse use the Maven classpath.
As of today, I'm not 100% happy with the Eclipse plugin, though. It's a bit slow and due to the different philosophy of Eclipse and Maven, some operations behave strange. For example, Eclipse doesn't differentiate between a "production" and "test" classpath, so you can get compile errors in Maven when everything looks great in Eclipse.
My solution was to use the plugin to keep the classpath in sync and compile from the commandline.
there is an ant task to do xml transformations, we used that task to create the classpath in our build file. It was a little trick to get the XSL right but once it worked it was great
Did you evaluate Apache IVY? Currently I am building a Continuous Integration environment at our place and we use IVY to handle our dependencies. There is a eclipse plugin that takes the dependency configuration of eclipse and uses it as eclipse classpath.
Currently this solution looks quite promising.
My team wrote an Eclipse plug-in to add a new type of library to the Java Build Path->Add Library option in the project settings. This custom library type allowed both Eclipse and ANT to reference the same canonical list of dependencies.
Nowadays, I'd probably look at IVY for doing the same thing if I was locked into using ANT, rather than writing my own.
You need Ant2Eclipse.