How to make ktor reload JS changes at runtime - kotlin

I'm using the KTOR multiplatform project template in IntelliJ (New Project -> Kotlin -> JS Client and JVM Server). Is there any way, when running the project in IntelliJ, to pick up runtime changes to the JS build? When I look at the classpath of the running JVM I don't see where the JS files are being picked up from at all.

Autoreloading is described here:
https://ktor.io/servers/autoreload.html
For Kotlin files compiling to Javascript, though, this does not work properly as one expects, which I presume it is why you posted this question on SO.
I posted a solution that worked for me here
https://discuss.kotlinlang.org/t/webpack-watch-in-ktor-js-project/18428/4

Related

Possible to create a kotlin js app gradle config without webpack/npm/yarn?

Is it possible to create a gradle config that uses the kotlin multiplatform plugin to create a project with a kotlin js client (and ktor/jvm back end) that does required the webpack/npm/yarn gymnastics which I have little use for? Even if I remove the webpack element from the config the build still seems to fail because of the yarn lock problem. (Can be worked around of course, but it just seems for simple apps all this complexity ideally could be avoided.)
Solutions that don't use gradle at all - like just calling the compiler(s) and other tools directly in a script - would also be welcome!

Can't load the main class/runnable jar JavafX 8 project [duplicate]

i created a Javafx project using JDK 8 and when i tried to export it to a runnable .jar file, i got surprised that it doesn't run using CMD, and gives the following error :
"Javafx compenents are missing"
while it works perfectly during the compiling time(using the IDE) when i accessed the .jar files, i found it has just .class files (that i made), and the needed library files that haven't been exported (i made sure to select the "extract need library files extract required libraries into generated jar" option in Eclipse), is there a reason behind of this? and a way to solve it? thanks in advance
Ps: i tried this using Eclipse and Intellij IDE
I just wanna mention once again that I'm using JDK 8 where it has JavaFX library inside of it.
Did you try this?
There are detailed instructions on how to configure your IDE to run JavaFX with newer OpenJDKs (which do not come with JFX components in it).
It also explains how to create a new JavaFX Maven project from archetype, with all the necessary plugins to easily build your application while including the minimal Java components for it (using jlink).
This will ensure that anybody using your application will have those components.

Configuring Intellij IDEA to work with Smartsheet-api sdk for java

I am setting up smartsheet SDK for Java, and running into problems trying to use it in IntelliJ IDEA. I am fairly unfamiliar with setting up decencies, modules, and such in IntelliJ, and am just looking for guidance on setting this up to work with Smartsheet SDK.
I'm currently using the Windows version with JDK13 (I also have JDk12). I've tried downloading the JAR file and pointing to that as a dependency, but it doesn't even understand the imports.
I would start with the Smartsheet Sample App for Java, which will already have the code in it for loading dependencies and libraries. https://github.com/smartsheet-samples/java-read-write-sheet

Using kotlinx.coroutines in IntelliJ IDEA project

I am trying to learn coroutines and so I fire up IntelliJ and create a scratch file. But when I type in my coroutines I get compiler complaints such as runBlocking is an unresolved reference. So this is not an android project or any such thing. Just a scratch file in a basic Kotlin project.
How do I bring in the coroutine stuff so I stop getting errors?
runBlocking and other high-level coroutine utilities are not in the Kotlin standard library, but instead are a part of the library kotlinx.coroutines.
To use this library in your project you must download its binaries and add a dependency on them to the project. Usually declaring a library dependency is a line or couple of lines in a build file, if you use build systems like Gradle or Maven. However in a plain IntelliJ project it's possible to get that library from Maven Central almost without hassle:
Open project structure
In the "Modules" page select a module which you use as a context of the scratch file (I suppose there will be just one module).
Switch to "Dependencies" tab and hit the plus button.
then in a context menu select "Library" -> "From Maven"
paste maven coordinates of the kotlinx.coroutines library artifact:
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3
where 1.3.3 is the version of that library. You can find the latest available version here: https://github.com/Kotlin/kotlinx.coroutines/blob/master/README.md
be sure to check "Transitive dependencies" and "Sources" boxes.
After hitting OK the library will be downloaded from Maven Central repository with all its dependencies and added to your module. Then it will be possible to use runBlocking in your project or scratch files.
You should add kotlin coroutines library to your project. The simplest way to do it is to get it from Maven repo. At this moment actual version of library is 1.3.2 The address of library in maven repo you could find here
At moment of writing the address of library is
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2
In plain IDEA IntelliJ project you should make following steps:
1) Go to project structure
2) Then go to Modules page and Dependencies Tab
3) Press "+" button. Select library from "Maven"
4) In search bar use address org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2 of library in maven repo and add it.
5) Press OK then Apply. And recompile your project. That is it. Now you could use coroutines in your project.

Is there an eclipse plugin for Play2?

I know there is one for play1, but I don't find any for play2.
I hope the plugin can compile the templates to scala code automatically. It's not convenient now.
I just came across Scala IDE Play2 plugin for Eclipse Indigo/Juno and Scala IDE. The current features are
Syntax Highlighting (routes and templates)
Code completion (templates)
Formatter (routes)
Hyperlinking (routes and templates)
Note that hyperlinking to Java files is not supported for now. Also there are some limitations for the code completion feature, just take some time to read the doc. I didn't try it myself as I'm not working with Play2 right now, but thought it might be helpful for someone.
Edit: This answer is outdated. A Play Eclipse plugin has been written, as #Baztoune says.
There is no Play 2 plugin for Eclipse at the time I’m writing these lines. However, there is an eclipsify sbt command, provided by the Play 2 sbt plugin, which is able to generate an Eclipse project from a Play 2 application.
You won’t get syntax highlighting, contextual completion or code navigation inside Play 2 templates, but you can have them to be automatically compiled when saved by using the ~run sbt command (instead of just run). Check the Eclipse “General −> Workspace −> Refresh using native hooks or polling” option is enabled so it will take compiled templates changes into account.
Yes, here's how to get started:
Find the correct update site for your version of Eclipse from http://scala-ide.org/download/current.html.
In Eclipse go to Help->Install New Software. Use the update site from above to locate Scala related plugins.
Install both the Scala IDE for Eclipse plugin and the Play2 support in Scala IDE plugin. Note that the Play2 support in Scala IDE plugin is listed under the Scala IDE plugins checkbox.
I was unable to get this working at all starting from bare Eclipse, as many sources have suggested doing. The problem seems to be incompatible dependencies that only show up after much wasted time. The Scala IDE route eliminated this problem.
Yes. That's Scala IDE.
Update Site for Eclipse Juno and Kepler: http://download.scala-ide.org/sdk/e38/scala210/stable/site
Install with the following features:
Scala IDE for Eclipse
Scala IDE Plugins (incubation)
I use Scala IDE from http://scala-ide.org/ , then eclipsify my play2 project and import.
It works like a charm: it compiles my scala/java code.
You can get more details at this URL http://scala-ide.org/docs/tutorials/play20scalaide20/index.html