How should I set up a web project using Kotlin on the back-end and in the browser? - kotlin

If I wanted to build a website which used Kotlin both on the back-end, and in the browser - how would I set this up? Is there a Maven archetype or a Gradle template that captures best-practices for something like this?

The easiest way is to keep the modules separate, and I guess conceptually you'd probably want to do that also. While IntelliJ IDEA for instance doesn't natively support the ability to output to JS and JVM with Kotlin, in principle with Gradle/Maven you could. Here are instructions on targeting JVM and JavaScript for Gradle http://kotlinlang.org/docs/reference/using-gradle.html

Related

Pros and Cons with installing Kotlin standalone compiler instead of using IntelliJ Kotlin plugin?

i understand that i can use Kotlin Plugin comes with IntelliJ but i can also install Kotlin standalone compiler. Is there any pros/cons using standalone vs IntelliJ own integrated?
I'd say that:
Any real Kotlin project (including projects in IntelliJ) should use a build system such as Gradle or Maven.
Enabling Kotlin support in a Gradle/Maven project will automatically download the correct compiler (and switch it when you update the Kotlin version in the config file) and not care about whether you have a stand-alone version installed.
Any other Kotlin tool will likely be integrated with them as well.
So the standalone compiler is pretty much only useful when you want to try something quickly outside any project, but then https://play.kotlinlang.org/ or https://try.kotlinlang.org/ can work as well; and again let you switch between Kotlin versions simpler than a manually installed compiler.
Running Kotlin scripts may be the only case where I would use the stand-alone compiler.
Not much, but having own install have few advantages, but probably not needed by most people on their machines:
You don't need intellij, so you can use that compiler in other IDE or just for other applications
You can use different version of compiler than the one from plugin.
But in most cases integrated one is all you need.

intellij hybris class recompile not working

I installed hybris plugin.
Imported project with it.
Have done ant clean all.
Then, if I try to build->recompile class it's not working. Seems like idea doesn't see classes generated by ant.
If I do build->rebuild project and then build->recompile class it's working fine, but it's not convenient at all. I believe there is fix to this, but I couldn't find it.
This is usual error I've got(packages are different for different cases):
this is essentially the expected behaviour. You can't mix "ant" build
and "native IDEA" build. Those are two separate build systems.
This is an explanation of hybris plugin developer (hybris-integration.atlassian.net/browse/IIPS-120)
And he suggests a solution for that:
before you try to import the project you need to do ant clean all (you will not need to use ant afterwards)
import the project using hybris plugin.
Press Build->Recompile project
Then you can create or modify your test run configuration if needed.
Recompile your classes and so on directly in Idea.
Also, he mentioned deal with JRebel here (hybris-integration.atlassian.net/browse/IIPS-47)
we support both compilation modes. Ant targets and idea internal. They
shouldn't be mixed as idea has it's own compilation model/cache. If
you use idea compilation then you can use JRebel or hotswap.
You cant hotswap classes in hybris without the help of a hotswap agent.There is a tool available in the market called JRebel. It is a good commercial tool if one can afford. However, if you are an open-sourcist, there is a promising alternative to JRebel, which is DCEVM (Dynamic Code Evolution Virtual Machine) along with HotswapAgent.
I don't know if this help,
you can start another cmd console, and run
setantenv and ant build to hotswap class in runtime.

OSGI aware IDE at development time

I'm starting development using OSGi but when one of my concerns is about the lack of support at development time, meaning that commonly IDEs (started using Intellij IDEA) don't use OSGi for class discovery but classpath search IDE managed (I'm in search for one that uses OSGi instead).
The main concern here is to prevent classpath issues at execution time by suing the same OSGi mechanisms at development time.
Does any IDE work this way ?
update: added link to blog post with my experience with IDEA
OSGi is a runtime technology, therefore there is no such thing as an OSGi mechanism at build time. Also bear in mind that ultimately all Java code must be compiled by a Java compiler, usually javac. The javac compiler does not use package dependencies like Import-Package, it always uses JARs or directories on the classpath.
Having said that, Bndtools uses package filtering at build time, based on the exported and private packages of the dependencies. This is a special feature of Eclipse and it does not work when you compile outside of the IDE, e.g. with Ant or Maven. However it may still be useful because if you try to use a non-exported package from another bundle you will get a problem marker with a red X in the Eclipse IDE.

use zeromq inside an eclipse plugin

I am trying to use zeromq inside an eclipse plugin.
The OSGi framework denies the use of normal external jars; thus, the solution is to bundle them into plugins themselves. Following a simple process (described also in
http://www.vogella.de/articles/EclipseJarToPlugin/article.html), I managed to use some of the external jars I needed without any suffering.
However, when I tried to bundle the jzmq.jar, I am having issues. The 'zmq plugin' is created easily but, once it is used, it freezes by looping into org.eclipse.ui.internal.Workbench.runEventLoop.
Anyone of you ever used zeromq inside an eclipse plugin successfully?
Any hint on how to solve this issue?

How make Eclipse instrument classes at build time?

Sometimes I have to perform some custom bytecode transformation.
I have used mainly asm and javaassit.
Inside eclipse usually I run my code with the -javaagent jvm parameter. Outside eclipse I use maven, ant, or the command prompt to invoke the weavers before running the application code.
But the point is that: I would like to perform instrumentation at build time inside eclipse.
What is the best way to do it?
Is there an already made plugin that I can connect to by implementing some api?
May I script this with eclipse monkey?
May I use an ant builder and invoke my weaver with it?
Should I look at the AspectJ plugin (must be huge) and try to figure out how to make my own plugin?
Should I look at the some other plugin to get inspiration?
Thanks.
You can create an annotation processor. This way you will be able to use it with ant, maven and any IDE (not only Eclipse).
Here is an example:
http://java.dzone.com/news/using-java-6-processors