Couple of packaging questions


#1

Hello. I'm try packaging kotlin for Fedora distribution. I'm familiar with java and groovy, slightly known scala but newbie in kotlin. My main intension package kotlin in rpm as standalone compiler.

Now (after http://youtrack.jetbrains.com/issue/KT-5055) I be able compile it from source but frustrating how big project is and what to do next.
Some major questions for me:

  1. After built it with ant -f build.xml I have many artifacts but it is not so clear for me what to do now. Discovered binary does not run:
  2. [pasha@hubbitus kotlin-build-0.7.808]$ ./compiler/cli/bin/kotlinc-jvmError: Could not find or load main class org.jetbrains.jet.preloading.Preloader
    1. In particular, as I be able download binarie artifacts from your teamcity server, I have not found any instructions how I can reproduce it self. Is there some documentation?
    2. Most found documentation and examples show how create project in Idea, add plugin and so on. Could you please point me on some instructions how to compile sample demo code in command line? Is it possible run it without implicit compilation as "scripts"?
    3. Groovy include two awesome tools to work interactively with scripts which are groovysh (console) and groovy-console (swing application). Do you provide some similar tools for user?
  3. Second vague question about dependencies. According to update_dependencies.xml it downloads artifacts of Idea CE. It is very big overhead. Idea IDE was retired long time before in Fedora 13 (https://fedoraproject.org/wiki/Features/IntelliJ_IDEA) if I understand correctly exactly because problems with dependencies. So, I do not think I'm ready packaging this great IDE now (Personaly I have Ultimate edition and not so interesting packaging it. Meantime it discussible. Anyway it separate big work). But I assume it stay there mostly to produce plugin for it? Can I build compiler without Idea plugin and therefor without such big dependency? If such artifacts still needed from Idea, it may be stated as more granular dependencies.

#2

Hi, Pavel.

  1. You can find the compiler built with ant in dist/kotlinc directory. Specifically, there are dist/kotlinc/bin/kotlinc-jvm (or -js) shell and Windows batch scripts.
    1. There's none at the moment, but similarly you will find the CLI compiler in kotlinc/ directory in the downloaded archive.
    2. The most straightforward way is:

      /path/to/kotlinc-jvm -src source.kt -jar output.jar -includeRuntime

      You can also pass -output instead of -jar, and use different other options (see kotlinc-jvm -help). You can omit -includeRuntime which will not include standard Kotlin library in your application (decreasing its size substantially) but then you will need to provide the path to kotlin-runtime.jar (found in kotlinc/lib/) when launching your jar.

    3. The closest thing we have is REPL which fires up when you launch kotlinc-jvm with no arguments, but it's not under active development right now and problems may arise there.
  2. Besides providing the sandbox to run our plugin in, we also need intellij-core.jar (which is a part of IntelliJ) in the compiler. Recall that Kotlin fully inter-operates with Java. That means when we're building a mixed Kotlin+Java project, Kotlin should compile first and Java second (the other way around would make referencing Kotlin from Java impossible). But to be able to process references to Java from Kotlin, our compiler should parse source Java files (and load compiled Java classes, to compile against binary libraries). Of course, we wouldn't write yet another Java parser, so we're using IntelliJ's one. We also use its parser framework for our own parser, its dependency on ASM to write bytecode and a handful of other things. Actually I believe all dependencies are packaged to kotlin-compiler.jar upon build, so I'm not sure what's your problem in downloading IntelliJ IDEA CE once.

Please note that the command line compiler is not our top priority at the moment and we have several issues with it. For example, you probably will need to mark kotlinc-jvm as executable before trying to run it (chmod +x).


#3

Thank you very much for the answers. First part I'll try tomorrow and ask if questions will arrive.

udalov wrote: Hi, Pavel.

  1. Besides providing the sandbox to run our plugin in, we also need intellij-core.jar (which is a part of IntelliJ) in the compiler. Recall that Kotlin fully inter-operates with Java. That means when we're building a mixed Kotlin+Java project, Kotlin should compile first and Java second (the other way around would make referencing Kotlin from Java impossible). But to be able to process references to Java from Kotlin, our compiler should parse source Java files (and load compiled Java classes, to compile against binary libraries). Of course, we wouldn't write yet another Java parser, so we're using IntelliJ's one. We also use its parser framework for our own parser, its dependency on ASM to write bytecode and a handful of other things.

Off course code reuse is very important. But it is also free components. Is it possible say publish your Java parser, ASM and other things as smaller maven modules and use it in both projects?

udalov wrote:

  1. Actually I believe all dependencies are packaged to kotlin-compiler.jar upon build, so I'm not sure what's your problem in downloading IntelliJ IDEA CE once.

Main problem what Fedora strongly prohibid bundling libraries: http://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries

udalov wrote:

Please note that the command line compiler is not our top priority at the moment and we have several issues with it. For example, you probably will need to mark kotlinc-jvm as executable before trying to run it (chmod +x).

Off course it is smallest issue. Obey HFS, setup rights and env adjustment and other around stuff is a main goal to package things into binary packages to make life end users easy.


#4

Sorry. Could I hope to get answers? Or you are not willing make any effort to modularize your software and provide assistance for inclusion in any Linux distributions (I known at least Debian, Ubuntu, Suse and Arch have similar requirements)?


#5

Sorry for the delay.

I’m still not sure what’s your problem: take a look at update_dependencies.xml, lines 261…287. We’re downloading each of the IntelliJ libraries we’re using separately. Some of them are used only in the compiler, some of them only in plugin, some in both. We keep these dependencies in one place because we’re developing the compiler and the plugin simultaneously, but in practice it’s not that hard to leave only compiler’s dependencies (which will not include the giant IDEA archive) to package the compiler only.

As I mentioned earlier, the CLI compiler is not our priority at the moment and we’re not currently working on packaging our compiler for package managers. At least until we got our dependencies straightened out (some of them may not be needed in the compiler in the future).