Install IntelliJ IDEA Community Edition and the Scala plugin (File -> Settings -> Plugins -> Available).
Generate your maven project using the simple Scala archetype:
mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create -DarchetypeGroupId=org.scala-tools.archetypes -DarchetypeArtifactId=scala-archetype-simple -DarchetypeVersion=1.2 -DremoteRepositories=http://scala-tools.org/repo-releases -DgroupId=group -DartifactId=artifact
Add the Scala compiler lib to your project dependencies in the pom.xml file:
<dependencies> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-compiler</artifactId> <version>${scala.version}</version> <scope>compile</scope> </dependency> </dependencies>
Update the Scala version configuration to a recent release:
<properties> <scala.version>2.7.7</scala.version> </properties>Open the a new project. Select the pom.xml in the file dialog.
An notification will pop up. Click "Create Scala Facet".
Done.
You can now compile and execute as usual and run the maven build
mvn install
with the Maven Tool Window. (The M2_HOME environment variable or Maven home settings (File -> Settings -> Maven -> Maven home directory) have to be present.)
Just a heads up, you'll need to add the following to your pom in order for the ${scala.version} property to resolve:
ReplyDelete<properties>
<scala.version>2.7.5</scala.version>
</properties>
Thanks Hohonuuli! The 2.7.0 in the template is ancient. I added it to the description.
ReplyDeleteThank you this was very useful.
ReplyDeleteAdding the dependency to scala-compiler is required by IDEA (bug ?) not by your project (except if you use class from the compiler of course).
ReplyDeleteSo I suggest you change the scope from compile to provided or add <optional>true</optional>. So user of your jar will not have required dependency to scala-compiler.
Thank you so much! I was looking for the solution... great, now I've also figured out what mvn archetypes are for.
ReplyDeleteThank you!!!