Intellij Command Used for "Refrsh SBT Project" - intellij-idea

I'm wondering what is the actual sbt command that Intellij is executing when I use "Refresh sbt project" from the sbt window. I would like to understand how the same command can be issued from the sbt shell.

The IntelliJ Scala plugin ships with the sbt-structure sbt plugin, which gets automatically loaded with sbt shell sessions that you start from the IDE. When you enable sbt shell for imports, a refresh simply writes commands similar to these to the sbt shell:
> set org.jetbrains.sbt.StrcutureKeys.sbtStructureOptions in Global := "prettyPrint download"
> */*:dumpStructureTo structure.xml
To actually import the project structure, IntelliJ also runs an additional step which does not happen in sbt.

Related

Use custom script in Intelij IDEA to run sbt shell

Is it possible to run sbt shell in Intelij IDEA using custom script instead of built in sbt or sbt from sbt-launch.jar? Why I need this, for example there is some project which uses custom script to set config file location, VM parameters, and other options for sbt and this script is shared in version control system. And it would be very convenient to just specify for IntelliJ IDEA location of such script.
This is currently not possible. However, to pass project-specific sbt command line parameters to sbt you may place a .sbtopts in your project directory, and likewise a .jvmopts for VM parameters.

IDEA 2016.1, Gradle's processResources expanding not working automatically

I have an IDEA 2016.1 Enterprise and a Gradle 2.12 multi-module project. In one of the modules, in src/main/resources, I have a file which I would like Gradle to 'expand', here is my configuration:
processResources {
filesMatching('my.properties') {
expand(project.properties)
}
}
(I would like to expand just this single file, and just copy the rest.)
It all works fine when built on the command line, but not by default in IDEA - when I clean and build the project, the file lands in build/resources/main but the placeholders are not replaced. I have to manually invoke the Gradle processResources task using the Gradle pane in IDEA and double clicking on the task.
Is this something I should report to Jetbrains (i.e. a bug) or has anybody have it working and I should change something in my configuration?
When you build from command line, you are using gradle. However, when you build the project from intellij, by default intellij doesn't use gradle to build, but use its internal build system which doesn't understand your gradle's processResources.
One way to solve it is to check "Delegate IDE build/run actions to gradle" as shown below:
If you don't want to use gradle build in intellij, there's another workaround - add processResources as a gradle task to run after build in your "Run/Debug Configurations":
Try adding the dependency in your build.gradle file, eg.
assemble.dependsOn processResources
This should work if you have java plugin applied.

How to customize sbt build command in intellij for spark

I need to add some profiles to the sbt command line: e.g.
sbt -Pyarn -Phadoop-2.4 -Dhadoop.version=2.5.2 assembly
So in Intellij 14 where is the sbt command line configured?

What is the command line option to pass into the activator framework to generate an intellij project?

I'd like to generate the intellij project files from a typesafe activator project via a script - is there a command line interface or command i can use for this purpose?
(i wasn't able to find directions for one online, or in the usual help locations)
Please note that since IntelliJ IDEA version 13 it is no longer necessary to generate files for IntelliJ IDEA. sbt support is now build in, you can open/import the project by opening your build.sbt with IntelliJ IDEA: http://blog.jetbrains.com/scala/2013/11/18/built-in-sbt-support-in-intellij-idea-13/
Remember that Activator is just an sbt wrapper with optional UI mode. So what you want is sbt-idea:
https://github.com/mpeltonen/sbt-idea
The Activator UI will auto-add this plugin and then (on the Code tab) it has an "open in" menu item to generate the intellij project.
If you want to script it, there are two steps:
add the plugin (either drop an idea.sbt in project/ directory or put it globally in ~/.sbt/0.13/plugins)
run activator gen-idea

SBT just loops in IntelliJ IDEA on SBT:Compile

Using Intellij IDEA 12.1.6 and SBT 0.13.0
I generated the hello-play with Activator and generated IDEA project. If I compile using the SBT console it both compiles and runs fine. If I create a run configuration with a Before launch: Run SBT Action 'compile' and launch, I just get the spinning Executing SBT Action and it never stops. I finally close IDEA.
Am I missing something basic here?
Here you can have the explanatioin of why this won't be fixed:
https://github.com/orfjackal/idea-sbt-plugin/issues/66
Instead you may just kill SBT (a small skull icon on the left pane), this will remove all those "Executing SBT Action" processes.