Creating new SBT project for Scala using Eclipse - eclipse

I have Eclipse (Kepler) and the Scala plugin (http://scala-ide.org/) installed.
With Eclipse, I can create a new Scala project, but its not an sbt project, so cannot add dependencies.
What is the best way to create a new skeleton sbt project, either within Eclipse, or one which can be imported into Eclipse?
Thanks

Create the sbt project yourself, then use the sbt-eclipse plugin to generate your eclipse project. This should make a .project and .classpath file in your sbt project directory. In Eclipse, use the "import existing projects" dialog.

Related

How to import a maven project in eclipse?

I have a (command-line) maven based project which just works great (mvn clean, mvn verify, install all perfect)! I want now import this into eclipse not as maven project but regular eclipse project.
I did it but I have a dependency issue which I solved by just copying all the jars created into the .m2 folder to another folder into my eclipse workspace. Then I've added all these jars to my project.
everything ok!
Question is: I have the feeling that this is not the best way to manage the dependency in eclipse ... what do you suggest? best practices
If you have a simple java project which is made up of only one module, using Eclipse is very simple. To generate the Eclipse project files from your POM you execute the following command:
mvn eclipse:eclipse
If you have created or checked out the project with Eclipse, you only have to refresh the project in your workspace. Otherwise you have to import the project into your Eclipse workspace (From the menu bar, select File > Import > Existing Projects into Workspace). In the latter case the project (directory) should not be located in your workspace, because Eclipse might come into trouble, especially if you want to use Eclipse as the scm client.

How eclipse maven and ant work together?

I made simple maven project and I opened it with Eclipse. I have installed maven plugin for Eclipse. I'm interested in following:
How Eclipse compiles code when I hit save on my source code (does it use configuration from ant or maven or something else)?
When I run tests from JUnit plugin for Eclipse those Eclipse calls mvn test (I suppose not, but what is then happening exactly)?
Is it possible that maven does the build successfully but Eclipse is
showing errors in code?
The Maven Integration for Eclipse makes it easier to edit POM files, allows you to execute maven builds from within Eclipse and to help with dependency management. It doesn't actually compile your code (unless of course you execute a maven build from within Eclipse). The main help is with the dependency management and writing the .classpath file of your project within Eclipse.
To try and answer your questions:
Eclipse uses its standard mechanism to compile code. With a standard eclipse for java developers your project will have a Java Project nature and Eclipse will then use the Java Development Tools - JDT to compile the code. (Internally this uses an incremental builder to build the code http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2FresAdv_builders.htm). What source files it will compile and where it will place the resultant .class files is configured in your project's Java Build Path (which I am guessing the maven plugin may well configure for you)
JUnit support is part of the Java Development Tools as well.
It is possible that maven will successfully build a project outside of Eclipse, but that the same project will show errors within Eclipse. This is usually down to classpath errors (dependencies defined in the project's POM not being added to the classpath in Eclipse). If you are using the maven plugin with eclipse this probably shouldn't happen. If you are not using the maven plugin within eclipse you can execute maven eclipse:eclipse to have maven update the Eclipse .classpath file of the project which should then fix any of these problems.

Create an eclipse plugin with dependency on a maven project

I have a maven project that contains a certain api I need to use in an eclipse plugin. This eclipse plugin is not currently a maven project but a normal eclipse plugin project with a manifest. I converted this plugin project to a maven project (using m2e menu command to change project to maven) I added the dependency to the maven project from this project. My maven build for this project is running fine from command line. Now when I launch the eclipse application I am getting a ClassNotFoundException for the api I am referring to from the plugin project. Please help.
This can be done by adding tyco configuration to the maven project. That enables you to have a maven project with a Manifest thus enabling other plugins to depend on it. More info: http://www.eclipse.org/tycho/

Adding and removing dependencies with SBT and Scala IDE

I've been experimenting with SBT and the Scala IDE (Eclipse) and I'm wondering - what's the standard workflow for adding and removing dependencies from your build.sbt file where the project's referenced libraries will be updated in Eclipse?
Are there any current plugins that are required to use sbt with eclipse when adding / removing dependencies?
The sbteclipse plugin will do it. The key is that whenever you change your dependencies you need to re-run the command to create the Eclipse files. I use:
eclipse same-targets
Then you need to right-click on the project in Eclipse and choose Refresh.
I also needed this. I can confirm that re-running the eclipse task from the sbteclipse plugin (version 1.3-RC3 for SBT 0.10.1) will indeed regenerate the Eclipse project files (these are .project and .classpath). If you're seeing something else, it sounds like a bug that should be reported.

Importing a Scala project from github into Eclipse

I've installed EGit plugin in my Eclipse Helios with latest Scala IDE plugin beta. I've imported it as a "general project" using clone and I can't find any Configure -> Add Scala nature option ... what am I doing wrong? (can't compile/run/add libraries etc)
I'm not familiar with the EGit Plug-in, but do you also have the option to import it as a Java project? The "Add Scala Nature" option is only available for Java projects.
If you can't create it as a Java project, you can also just modify the generated .project file and add the Java nature to it manually:
<nature>org.eclipse.jdt.core.javanature</nature>
(taken from http://enarion.net/programming/eclipse-change-general-to-java-project/)
One recommended approach would be first to make your GitHub project compiled/run with sbt (which ensures both IDE-independence and third-party library dependency management).
The sbt-eclifsify can easily generates .classpath and .project files for the Eclipse IDE from the sbt project.
The class ProjectFile.scala details how the .project file is build.