We're in the early stages of adopting Bazel and Scala support in the IDE is a must for us.
It's not a blocker now since we have bigger blockers but it's something we will have to have.
I'm very much willing to take on the development if that will be the missing piece.
Yeah, it would be fantastic to get support for the skylark rules of https://github.com/bazelbuild/rules_scala
I understand that you guys have more pressing issues, but maybe some pointers to how to get started (@brendandouglas, @damienmg) and contribute would help others pick up the cause?
Support for general rule types (including custom rules defined in Skylark extensions) is something we're actively working on. At the moment we're working through some initial bazel-side changes. We'll keep you updated.
Are there any recent updates on this issue? Thanks!
I'm working on this.
Thanks for the update!
Finished adding the sync plugin and updating the bazel aspect. Editing/completion/refactor should work now.
Currently finishing up adding run configurations (run/debug) for main classes.
Run configurations for test frameworks to be followed.
Awesome, thanks. I tried the build from source and noticed that IJ still asks me to setup Scala SDK for my module and then realizes there are already scala JARs. The other thing is that it cannot find sources for Scala SDK. Re run configuration: it is at least possible to fork and modify some existing run config for java_binary/java_test and use it for scala_binary/scala_test. It works then but Scala cannot be debugged.
I suppose you know all that. Is it on your to do list? Are there any things that are relatively simple to help and submit PR?
I tried the build from source and noticed that IJ still asks me to setup Scala SDK for my module and then realizes there are already scala JARs.
That shouldn't happen. You might not have the latest sources yet.
The other thing is that it cannot find sources for Scala SDK.
Yes, because of this. It'll need to be fixed by JetBrains.
It works then but Scala cannot be debugged.
I can update scala_rules and intellij plugin. Should I update Bazel itself too (I am at 0.5.0)?
I voted of JetBrains issues if there is a chance it will help.
Nice to know that debugging will work. Thanks for all that work!
Yes bazel will also need to be updated for the aspect changes.
On May 30, 2017 14:31, "Radim Kubacki" notifications@github.com wrote:
I can update scala_rules and intellij plugin. Should I update Bazel itself
too (I am at 0.5.0)?
I voted of JetBrains issues if there is a chance it will help.
Nice to know that debugging will work. Thanks for all that work!—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/bazelbuild/intellij/issues/13#issuecomment-304967663,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJlvsZNyOcXTUeLI4nO-R-kvnOMr8QhMks5r_GCZgaJpZM4JKoZq
.
Main class run/debug configurations are done. Should be in the next release.
JUnit support (without specs2) should be soonish (probably next release or release after that).
Scalatest and specs2 support will take more time, since they don't currently exist in the regular IntelliJ Scala plugin either.
JUnit support is blocked by this, but otherwise finished.
@chaoren ,
It seems that external jar imports for scala are not recognized yet by intellij Analysis
Here is an example for guava (the BUILD file contains a dependency for @com_google_guava_guava//jar ):

and for specs2:

The WORKSPACE looks like this:
rules_scala_version="b776a218dc526f54043576762c2bc1790bf9755d"
http_archive(
name = "io_bazel_rules_scala",
url = "https://github.com/bazelbuild/rules_scala/archive/%s.zip"%rules_scala_version,
type = "zip",
strip_prefix= "rules_scala-%s" % rules_scala_version
)
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
load("@io_bazel_rules_scala//specs2:specs2_junit.bzl","specs2_junit_repositories")
specs2_junit_repositories()
maven_jar(
name = "com_google_guava_guava",
artifact = "com.google.guava:guava:19.0",
)
Bazel commands do work, (build and test pass successfully).
But the Analysis fails...
btw, the same Guava import Analysis does works for me in java_library import, so its isolated to scala...
Chaoren,
There's a specs2 runner no? (
https://www.jetbrains.com/help/idea/2017.1/run-debug-configuration-specs2.html)
what's missing?
On Wed, 31 May 2017 at 20:25 Chaoren Lin notifications@github.com wrote:
Main class run/debug configurations are done. Should be in the next
release.
JUnit support (without specs2) should be soonish (probably next release or
release after that).
Scalatest and specs2 support will take more time, since they don't
currently exist in the regular IntelliJ Scala plugin either.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/bazelbuild/intellij/issues/13#issuecomment-305258326,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABUIF-hdsgehO4VB6Vr_GvVtvlqN5WoLks5r_aKjgaJpZM4JKoZq
.
@natansil Those should be working. What version of bazel, bazel plugin, rules_scala are you using?
@ittaiz We already have arbitrary bazel target runners too. We just don't have auto-generated run/debug icons next to each test class/method. It's a bit weird for scalatest and specs2 because each of the test cases look very different from, say, a JUnit test method.
I see you have the latest rules_scala, but what about bazel and bazel plugin?
Also make sure you have:
additional_languages:
scala
in your .bazelproject file.
@chaoren,
Here are the details you requested:
bazel version - 0.4.5-homebrew (also reproduced on 'latest HEAD' for @ittaiz , @or-shachar)
bazel plugin - 2017.05.08.1
in my .bazelproject file:
directories:
.
targets:
//...
additional_languages:
scala
Also, the scala files are not synced (and a java project the 'unsynced' is not shown)

bazel version - 0.4.5-homebrew
This is way too old. Use 0.5.0.
also reproduced on 'latest HEAD' for @ittaiz , @or-shachar
What versions of everything else did they use?
bazel plugin - 2017.05.08.1
This should get you resolving and completions, but no gutter run configuration for main classes.
also reproduced on 'latest HEAD' for @ittaiz , @or-shachar
What versions of everything else did they use?
Also, you need to make sure to choose the correct bazel binary in
File > Settings > Other Settings > Bazel Settings > Bazel binary location
It should look like this:

You may get this thing when you first import the project:

but hitting the bazel sync button:

should make it disappear. (I'm looking at preventing it from appearing in the first place.)
Hi @chaoren ,
956810b6ee24289e457a4b8d0a84ff56eb32c264)
Example project can be found here: https://github.com/or-shachar/bazel-sample-repo
I also get this error in intellij whenever I import new bazel project.
Assertion failed
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:168)
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:177)
at com.google.idea.blaze.base.command.info.BlazeInfo.<init>(BlazeInfo.java:89)
at com.google.idea.blaze.base.command.info.BlazeInfoRunnerImpl.lambda$runBlazeInfo$2(BlazeInfoRunnerImpl.java:79)
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:108)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:41)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:77)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
@chaoren ,
First of all, thank you for your assistance!
I've downloaded and installed bazel version 0.5.1
Seems to have solved the production code external dependencies resolving.
But in the test code import from specs2 is yet to be resolved:

production code is succesfult synced, but test code is not.
The build file looks like this:
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library", "scala_specs2_junit_test")
scala_specs2_junit_test(
name = "scala_example_test",
size = "small",
srcs = ["src/test/scala/com/example/ExampleTest.scala"],
deps = [":scala_example"],
suffixes = ["Test"],
)
upgraded scala_rules import to new version
commit a94b6d0690f48cd41d3649d8aab9a7fd1491b76e
also, couldn't find other settings -> bazel settings:

can't find 'Bazel binary location' anywhere
@or-shachar You're hitting this bug: https://github.com/bazelbuild/bazel/issues/3055. I think if you add the appropriate name (same as the containing directory) to your WORKSPACE it should go away.
@natansil Are you using an up to date version of IntelliJ?
Example project can be found here: https://github.com/or-shachar/bazel-sample-repo
There's only a Java file. Did you link the correct project?
@chaoren. yes, the intellij version is 2017.1.3.
Two other issues I've noticed:

@natansil I've never seen that before, sorry. Might be mac specific. Can you reliably reproduce?
@chaoren , I'm afraid it's not that easy to reproduce. for instance, opening and then closing a project works fine. I'll continue to monitor this...
Testing support is done. Should be released soon.
Somethings are missing, but they need to either be fixed in rules_scala or the scala plugin:
rules_scala).I'm gonna close this now. Please other new issues if you run into problems after 2-3 weeks (when all the changes are released).
@chaoren first of all thank you for all your hard work on this issue. We
appreciate it greatly.
We've discussed this in the past but I still don't understand what's
missing on the scala plugin side for running individual specs2 test cases?
I can run individual specs2 tests when using maven setup so I'm trying to
understand what's missing.
On Mon, 12 Jun 2017 at 22:46 Chaoren Lin notifications@github.com wrote:
I'm gonna close this now. Please other new issues if you run into problems
after 2-3 weeks (when all the changes are released).—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bazelbuild/intellij/issues/13#issuecomment-307895951,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABUIFzka8omJrlxsIBoq9btwzHKfy0jLks5sDZKpgaJpZM4JKoZq
.
I can run individual specs2 tests when using maven setup
By individual test, you mean the test class correct? Not individual infix expressions?
The test class is considered a suite, and within each suite is a bunch of test cases, which are the individual infix expressions.
With my change (to be released in 2-3 weeks), you'll be able to run individual test classes (in junit, specs2, or scalatest), but you won't be able to run individual test cases for specs2 or scalatest like you can run individual junit test cases (methods).
Also, rerun failed tests would rerun the entire test suite, instead of the just the failed test cases in specs2 and scalatest.
I do mean individual "methods".
Given a mutable specification which has something like:
"Foo" should {
"Do bar" in {
success
}
}
When moving the cursor to the "Do bar" line and pressing cmd+shift+F10 on
it IntelliJ runs only that "method" (fragment in specs2 lingo).
On Tue, 13 Jun 2017 at 0:51 Chaoren Lin notifications@github.com wrote:
I can run individual specs2 tests when using maven setup
By individual test, you mean the test class correct? Not individual infix
expressions?
The test class is considered a suite, and within each suite is a bunch of
test cases, which are the individual infix expressions.
With my change (to be released in 2-3 weeks), you'll be able to run all
test classes, but you won't be able to run individual test cases in specs2
or scalatest like you can run individual junit test cases (methods).
Also, rerun failed tests would rerun the entire test suite, instead of the
just the failed test cases in specs2 and scalatest.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bazelbuild/intellij/issues/13#issuecomment-307923843,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABUIF8aFxhQIK8tOTp0B1ChOVYH7cvknks5sDaU-gaJpZM4JKoZq
.
@ittaiz would there be a run marker next to "Doo bar"?
I ask because based on this line:
//TODO do nothing for now; gutter icons for classes require proper url processing for each framework
I assumed they had no such support. If they had the support, but just not the run lines, then it might be easily implemented.
I don't think there's a run marker no. But it does work (for the past 3
years I think). I'm pretty sure I sent you a link to the place in their
code where they do this. Any chance you have that? If not I'll look for it
On Tue, 13 Jun 2017 at 16:36 Chaoren Lin notifications@github.com wrote:
@ittaiz https://github.com/ittaiz would there be a run marker next to
"Doo bar"?
I ask because based on this line:
//TODO do nothing for now; gutter icons for classes require proper url
processing for each framework
https://github.com/JetBrains/intellij-scala/blob/idea172.x/src/org/jetbrains/plugins/scala/testingSupport/test/ScalaTestRunLineMarkerProvider.scala
I assumed they had no such support. If they had the support, but just not
the run lines, then it might be easily implemented.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bazelbuild/intellij/issues/13#issuecomment-308118136,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABUIF8Q2f5zyFvSVZstMGezudj4aExVxks5sDpBcgaJpZM4JKoZq
.
https://github.com/JetBrains/intellij-scala/blob/26f8c5b659c906ac645463d67602dcb13f83a4a0/src/org/jetbrains/plugins/scala/testingSupport/test/specs2/Specs2ConfigurationProducer.scala#L66
https://github.com/JetBrains/intellij-scala/blob/26f8c5b659c906ac645463d67602dcb13f83a4a0/Runners/src/org/jetbrains/plugins/scala/testingSupport/specs2/JavaSpecs2Runner.java#L215
Cool thanks. The current runner for Specs2 doesn't support those filters yet. I'll add these for when they do.
We can probably have the run markers too.
When moving the cursor to the "Do bar" line and pressing cmd+shift+F10
Can you share a simple maven project (that I can open directly with IntelliJ) where I can play around with this? I want to make sure bazel has feature parity.
@chaoren https://github.com/orrsella/scala-maven-template
I can update specs2 but this feature has literally been working for years so I don't think it should matter. Does this suit?
Most helpful comment
I'm working on this.