Building data2viz

Building data2viz is not very easy. We started the project even before Kotlin Multiplatform and what we are trying to do is complicated.

I don’t know any other MPP UI project trying to target JS + Android + JFX. As a result, we face some severe issues:

  • being able to have efficient development experience,
  • doing rendering tests on very different environments,
  • package and deploy.

The current version uses the old Kotlin MPP plugin. The new one, and its intellij idea integration, still have some bugs that make it unusable for the project. We decomposed Data2viz library into a lot of Gradle projects: one per module and per platform. The main advantage is the caching mechanism of Gradle that will recompile only modified projects, keeping the build time acceptable.

The best workflow, when working on a module, is to edit the code and then relaunch the build only on that project. The Gradle Wrapper can help here, by launching builds only in the context of the current directory.

Tests are also quite long and shouldn’t be launched during fast feedback loops:
gw build -x test.

To accelerate builds, you can modify in gradle.properties the type of project that will be activated.

# project activation
include_android=false
include_js=true
include_jfx=false
include_jfx_renderings=false

@yevhenii Could you have a look at this bug in the context of an Android build? Quite strange.

@gaetan I already updated gradle version in my free time on my side and had similar error. I prepared quick workaround and now it works good. I will explore more and propose solution soon

2 Likes

Pull request - https://github.com/data2viz/data2viz/pull/122
I have similar errors with 4.6
I solved issue by upgrading to 4.10.3 (latest 4.x version for now).
I also included android modules in build to show compatibility. Android & JFX modules had conflicts previously (JFX build error) with old gradle version. With 4.10.3 you shouldn’t disable Android modules to run JFX.
Currently

  • It not possible to run JFX via click on main method in IDE + run (as Kotlin application)

Error: Could not find or load main class io.data2viz.examples.geo.EarthApplication

  • but it runs via build :run task on JFX module
  • It possible to run Android as app via IDEA and via gradle action
  • It possible to build js modules via Gradle and gradle from IDE
  • It is possible to build whole project via shift + f9 from IDE. Previously error was thrown

I think we should put somewhere in docs information about build:

  • the best option is to build via gradle tasks (from terminal or IDEA gradle view)
  • to run Android application you should run :installDebug task like ./gradlew :app:installDebug
  • to tun JFX application you should run :run task like ./gradlew :ex-geo:ex-geo-jfx:run
  • to build JS files you should run :build like ./gradlew :ex-geo:ex-geo-js:build and open index.html in module directory

@yevhenii You should activate travis on your fork of data2viz to correct builds before merging in main repo: https://travis-ci.org/data2viz/data2viz/builds/532744102

  • I added Travis to my repository.
  • I explored build errors and it looks like travis script don’t change
    include_android property.
    In travis.yml we have line for Java build
    ./gradlew check -Pinclude_android=false -Pinclude_js=true -Pinclude_jfx=false but it looks like Travis use simple./gradlew assembleand fails due to non-existing Android build environment. However Android Travis setup works and properly usexvfb-run ./gradlew check -Pinclude_android=true -Pinclude_js=false -Pinclude_jfx=false from config
    I added a temporary solution: made include_android=false in gradle.properties (https://travis-ci.com/xal/data2viz/builds/112118730) by default so it well configured for Java and Android Travis build, but we should fix travis configuration for JVM for build without error not depending on include_android in gradle.properties
1 Like

@gaetan I fixed Travis config and now it does not depend on include_android value in gradle.properties
https://travis-ci.com/xal/data2viz/jobs/201628125

During work on geo. I found that d2v android samples reached 64k limit and fail during build. So I enabled multidex in geo branch.

2 Likes