I'm trying to use sbt-scalabuff to generate scala case class from proto file. I have added the plugin reference into plugins.sbt file of the Play project, added runtime dependencies too.
If I do not add any settings to Build.scala referring to sbt-scalabuff then I assume that will go with default settings, expecting to find the files in src/main/protobuf.
Do you know any Build.scala sample of proper settings of sbt-scalabuff?
Thanks,
Gabi
I haven't actually tested sbt-scalabuff much myself, but you can try raising an issue on the sbt-scalabuff github page.
Related
The Play website says it should be in "conf", but the Lagom default HelloeWorld example places it under the "resources" directory within /applicationProject/src/main". "conf/" does not even show up anywhere in the directory structure in Lagom. Can someone clarify?
According to default Play project layout
application.conf located at conf/application.conf. So if you will inject play.api.Configuration this will represent parsed and loaded config from that file.
On another hand I suppose, Lagom is library, which relies on default Maven project layout, which differs from default Play layout, in which src/main/resources is standard folder for resources like configuration, which is why in Lagom project example you see application.conf in another folder then in Play.
What you can do as an option: take play.api.Configuration.underlying and pass manually to Lagom code.
Or keep using standard Maven project layout for Play via special plugin introduced after version 2.6.8: https://www.playframework.com/documentation/2.6.x/Highlights26#PlayService-sbt-plugin-(experimental)
Hope this helps!
I have searched for this error, but the answers were for Java,
but my case is Scala. I am trying to run this project in IntelliJ IDE
sentimenAnalysis, but it throws an error. This is also the structure of the project. Class Not found
Update 1 According to answers, Adding $ at the end of the name of search class
Update 2 after adding sbt task:
Update 3
My problem was resolved by importing the project, instead of getting it directly from GitHub, probably the manual configuration that Mike Allen said could resolve the problem, but I couldn't successfully apply that.
My problem was resolved when I marked "src" folder as sources root.
Right-click on (folder) src -> Mark Directory as -> Sources Root
Probably you imported project somehow wrong. I see scala folder is not highlighted as sources.
Usually, you don't even need to setup Run configuration manually for Scala SBT project. Do you have Scala and SBT Plugins in your IDE?
You should open SBT projects through "Import project" and choose "build.sbt" file. I would also recommend enabling auto-import to install all of the dependicies.
That's how it look for me:
If you still wanna make it manually your configuration should work. That's my Run configuration that works:
You will get this error if you tried to open the project and imported it incorrectly. I would open the project like this in Intellij:
File>New> Project from Existing Source>(select) Import project from external model>
(select)sbt
click Next>Finish
To fix this issue in my project I invalidated caches and restarted:
In my case the object in the object MyObject extends App was nested, if you have it unested meaning in your scala file it's not under any other object it made it work.
Netsted caused this error in intellij:
object External {
object MyMain extends App // Could not find or load main class in scala in intellij IDE
}
While the below unested worked:
object External { }
object MyMain extends App // Worked!
Hi I solved this problem by defining the class in src package under main and by setting up the configuration as default.
Create a new project and make sure SBT is proper loaded along with Scala Library. This happens with many times, bad internet connection or failure of Scala library/SBT loading might be some of the reasons.
Best of Luck for Next Project, Happy Developers & Coders.
Had a similar problem with latest Intellij IDEA build (2022.1.1) and scala 3.1.2 - both sbt and Intellij scala projects. For me the solution was to use non-ascii path.
#SeriousDron answer helped me with my problem. You need to make sure you have Scala language installed in IntelliJ. You can do this by going to Settings > Plugins > search for "Scala". Now, it will automatically pick up your .sbt file and project.
I met the same issue, please check the whole execute command and check the configuration, make sure the compiled files path is correctly configured.
refer to my screenshot:
I just downloaded the plug in for Scala in IntelliJ and have created a project but now have various errors I read that the problem can be that I am missing a library. But when I try and go to project structure -> dependencies to add a library I have no clue where in the files to look for a library.
The errors are really simple but I can't seem to figure it out.
Any suggestions would be helpful :)
Here's everything you need to properly set up Scala plugin in Intellij. Furthermore your code has several errors:
Are you sure you created a Scala project (when you did File->New->Project)? This looks to me like a Java project? That class file looks to me like a Java class not a Scala class (that's why you're getting compilation errors on def but not public class).
1) value is not defined anywhere, of course it will throw a compilation error
2) classes in Scala are by default public, you do not (cannot) mark them as such
You can save yourself a lot of trouble by creating a simple SBT project that specifies all of your dependencies, etc. and then just pointing the IDE at that. Then when you change build.sbt, IntelliJ IDEA will notice that and update itself automatically. Plus, your build.sbt gets checked into your code base so that anyone you are collaborating with sees your changes to the dependencies. And the project can be built in batch mode using sbt compile and friends.
The following page talks about IntelliJ IDEA's "SBT Import" feature:
https://confluence.jetbrains.com/display/IntelliJIDEA/Getting+Started+with+SBT
Scala source files end in .scala, not .java. Try renaming Counter.java to Counter.scala. This should improve things a lot.
Background:
I am in the process of integrating TypeScript into a Play Framework (2.2.6) and I am trying to use mumoshu's plugin to do so. Problem is, the plugin has problems when running "play dist" on a windows machine.
I've forked the code from GitHub in order to make some modifications to the source so I can continue using the plugin.
Question:
I have a play framework plugin in the traditional source structure:
project/build.properties
project/Build.scala
project/plugins.sbt
src/main/scala/TypeScriptPlugin
src/main/scala/TypeScriptKeys.scala
...<other code>
I'd like to include this plugin into another project but I don't really know where to start and how to hookup the settings.
From previous suggestions, I've been able to add the module to my project as follows:
// In project/Build.scala...
object ApplicationBuild extends Build{
lazy val typeScriptModule = ProjectRef(file("../../../play2-typescript"), "play2-typescript")
lazy val main = play.Project(<appName>, <appVersion>, <appDependencies>).settings(typescriptSettings: _*).dependsOn(typeScriptModule).aggregate(typeScriptModule)
}
Where typescriptSettings is defined in the other project... I think, I'm still not 100% sure what typescriptSettings IS other than adding this settings call enabled the plugin to work. This worked fine originally when I had included the plugin in the plugins.sbt file and imported the package com.github.mumoshu.play2.typescript.TypeScriptPlugin._ but now that I'm including the source and explicitly including the module, I can't just import the package... Or at least not the way I used to.
I am still new to scala/sbt and I am having difficulty finding helpful resources online. Any help would be appreciated.
Assuming in the same parent directory you have two directories:
play2-typescript: which is a clone of mumoshu's play2-typescript
play2-typescript-testapp: which is the play app in which you're testing your changes
You need to create, inside play2-typescript-testapp's project directory a file like so:
play2-typescript.sbt
val metaBuild = (project in file(".")
dependsOn ProjectRef(file("../../play2-typescript"), "play2-typescript")
)
Note:
The relative path is to the play2-typescript plugin project, and is relative to the project directory inside play2-typescript-testapp.
Change that to what is correct in your setup, and consider that you can also define it as an absolute path.
There a lots of activator template examples of this. I have a project where we followed the https://typesafe.com/activator/template/play-multidomain-auth path. Specifically, to address your question; the plugins in the root project play-multidomain-auth/project/ are accessible in the modules (play-multidomain-auth/modules/admin/, .../common, and .../web).
This example is the cleanest example I've seen in using multi-project design however that opinion is very subjective.
I hope this helps.
Using IntelliJIdea 12, i downloaded the Scala plugin and created a HelloWorld application.
The following import seems odd. Why does IDEA not recognize this to be a Scala Application? Is my setup incomplete?
I checked to see where does my compiler points to and got this. Don't really see a way to navigate IDEA to my scala installation.
Please advise.
When creating a new Scala project from the wizard IDEA can download and configure everything for you:
Settings can be changed later in the Scala Facet:
and in Compiler:
Libraries configuration:
Code and imports completion is available from the Scala library:
You need to add Scala as a framework for your project.
To do this, right click on the top level directory in your project, choose "Add Framework Support..." and select Scala. Then Scala will be added as a "Facet" of your project.
Here is a good page with more info:
IDEA Scala Project Configuration Explained
I got around this by downloading the Scala library from scala-lang.org, unzipping it and then pointing the project to it. It worked fine after that. But of course, I'm an eclipse guy so perhaps someone else might be able to give you a better automated (?) solution. Here's what my project looks like in Module Settings -> Libraries: