Publish Site using SBT - scala

I have an SBT project using SBT 0.13.2. I am using the awesome sbt-site plugin to generate a pamflet site.
What is the best way using SBT to get the generated sbt-site onto a remote server for others to access?
We have this already setup and working wonderfully using Maven and WEBDAV.
I am hoping that there is a simple answer, barring creating my own sbt tasks.

I had to create my own SBT WEBDAV plugin to do the publishing. If people are interested in what I did, feel free to contact me (note: unclear on how to post contact info on here).
It wasn't hard, but rather a pain. I would love to open source it, but that would take time I don't have presently :(

Related

What is the Main class in a Lagom/Play application?

I'm trying to figure out how to package and deploy my lagom app in production. The docs are surprisingly coy about how to actually do this, and when I try to use sbt-native-packager to run universal:packageBin I get the warning that You have no main class in your project. No start script will be generated.
Has anyone worked through this and knows a good tutorial or something to reference?
https://github.com/lagom/lagom/blob/a35fab1ad8a0c4a3d28d6c86ae31a2408da2e340/dev/sbt-plugin/src/main/scala/com/lightbend/lagom/sbt/LagomSettings.scala#L28
Adding that to your project will fix it. That said, generally you shouldn't see this warning, because the Lagom plugin should configure it for you. There's two reasons that I can think of off the top of my head why you might be seeing this warning.
The first would be that you don't have the Lagom plugin enabled on your project. If that's the case, and you're not doing something advanced where you really know what you're doing (and if you really knew what you were doing I would be surprised if you had to ask this question), then you probably have a misconfiguration and need to enable the Lagom plugin.
The second might be that you're running universal:packageBin on multiple projects, some of which do have the Lagom plugin enabled, and some of which don't. In such a case, you probably only want to build the production artifact for your Lagom project, not for all the other projects (eg the API project, or the root project). So, just run it for your service (eg, run my-service-impl/universal:packageBin).

How to make sbt download its own sources/javadoc?

I know that I can download the sources/java-doc for my dependencies using the update-classifiers task.
But it would also be interesting to be able to download the sbt sources/java-doc, as Intellij is not showing me any kind of documentation for sbt-related stuff. I've already checked on their website and they seem to only provide the binaries. I would like to avoid having to download their github project, if possible.
Thanks

What's the point of downloading the source jars in a grails project?

I've noticed that in eclipse if you Right click on a project -> Grails Tools -> You have the option to 'Download Source Jars'.
What is the point of this and what are some common reasons as to why you would want to do this?
Grails 2.2.3
Edit:
I'm not even sure what grails does instead of that.
Many (most) libraries (JARs, "artifacts" in the Maven terminology) publish a sources archive alongside their binary artifacts in the repositories. This can be useful for Eclipse to show you the Javadoc and source code when you're using the library in your projects. As #JonSkeet commented above, it's very useful to have source code available directly in the IDE when using a library.
By default, Grails does not download the sources for artifacts; this option triggers it to do so and attach the sources to the binary JARs.
Agreed with E-Riz.
Here are the reasons I use the sources:
i want to have a deeper understanding of how the library works when debugging my own depending code
i want to find a possible bug in the library, so I can fork it and apply my own patch. i will possibly share this with the maintainers as a pull request if I'm willing to spend that much time on it.
i want to find out what logging systems it uses that might be poorly documented, so I can see better what their code is doing during runtime, to troubleshooting complicated problems.

Setting up a Scala project in Eclipse, together with JUnit & Scalatest

I have recently completed the Scala course on Coursera, and since then I have been looking forward to getting my hands dirty with Scala again. I have written code for some years but I neither educated to be nor work as a programmer, so it took me a while to get a good opportunity but now that I have some time to invest and a good project to work on it's time...
Except I can't seem to get things set up properly, which I find really frustrating. I have OpenJDK 1.7.0_25 running on my Linux machine. I have downloaded and installed the Bundle Scala IDE build for Eclipse (just like we used in the course). And I got ScalaTest both as a jar file and the Eclipse plug-in.
I have a simple project (so far) and no matter what I do I can't seem to get my builds and tests in order. First off how exactly am I supposed to set up my project so that my classes and tests are actually run properly? All the assignments we got were projects that had the same structure, so do I have to have:
project
|--src
|--main
|--scala
|--test
|--scala
structure? If so why is it not the default way the project is setup when I create a new project? Do I create these folders manually, as packages or as source folders? The whole thing gets pretty murky..
I should mention that I tried to "Mavenize" the project using the contextual menu in Eclipse, added my ScalaTest dependency. The first thing that happens is that I get compile errors, at every point of dependency in my code. So clearly the library is not visible, in other words Maven does not seem to be doing much of management. I thought the whole point of Maven was to get and maintain dependencies as the project evolves. I concluded that I do not fully understand the way Maven works and thus I eventually gave up on Maven, once again, and went back to doing things manually.
Secondly, I can't seem to run my tests; the Run As... menu item does not include ScalaTest as it's mentioned in the documentation of ScalaTest Eclipse Plug-in. I have double checked that the plugin is installed. If I instead try to run using JUnitRunner then my tests are not recognized as valid tests. I have JUnit and ScalaTest on my build path, so it's got to be something else.
I suppose my overarching question is as follows:
given the Scala IDE build of Eclipse and ScalaTest, just exactly how am I supposed to set up my project (in Eclipse) so that I can just focus on writing my code and testing it, and hopefully not have any other headaches?
I work alone, and this project is not a product I need to deliver to some client. In other words I do not need to adhere to strict professionalism here. Honestly I just want to be able to code, get better acquainted with Scala and hopefully build a small data analysis tool that I will be using from time to time.
Thanks in advance!
Try using the sbt eclipse plugin:
https://github.com/typesafehub/sbteclipse
This is of course assumes that you use sbt as you build tool. If you don't at the moment you can find instructions on installation and usage here: http://www.scala-sbt.org/
Personally I've been using typesafe giter8 template (https://github.com/typesafehub/scala-sbt.g8) to setup my Scala projects, and then I use the sbt plugin mentioned above to generate eclipse project files.
Scala is somewhat Maven-based (sometimes implicitly), that's why you use that structure.
The easiest way I think is to create a simple Sbt/Maven POM and create the Eclipse project configurations (like with sbt eclipse). There you can set the dependencies (like the actual version of JUnit, Scalatest to use), so you can use the ScalaTest plugin easily.
In case of other issues, feel free to ask at the ScalaTest mailing list, Chee Seng and Bill Venners can help you a lot there.
The Scala IDE website has a full documentation on how to run unit testing frameworks with the IDE, have a look ! If you find missing elements, the bug tracker of the scala-IDE project is here.

How should one start on creating a sbt plugin?

I want to create a sbt plugin for Scala project.
Please any one suggest me how we start?
I referred Plugins documentation but unable to understand steps.
The first step in becoming a sbt plugin author is understanding sbt build definition. The best resource for it is Getting Started guide. For plugins, it's essential that you understand the concept of scoping. Some of my blog posts like an unofficial guide to sbt 0.10 v2.0 and traveling through the 4th dimension with sbt 0.13 discuss the topic.
Next, try reading the source code for existing plugins:
sbt/sbt-appengine
sbt-appengine adds defines appengineSettings, which the build user can include in his or her build definition to add appengineDeploy and other appengine related tasks.
sbt/sbt-man
sbt-man on the other hand overrides settings and adds man command.
These are roughly two patterns for plugins. Once you understand them fully, try making your own plugin.
Another source of inspiration is the source for sbt itself. Whenever I'm writing a plugin, I'd consult Defaults.scala to see how sbt implements a particular task that I'm interested in. Once you're comfortable, you should also read Plugins Best Practices too.