Production build missing JS libraries from a local jar

I am working on my first my first vaadin-on-kotlin app and I’m having problems doing a production build with the very nice MediaQuery addon by @Jean-Christophe.1

In dev mode everything works, but for some reason it’s not included to final bundle.

Is there something special about using a local dependency compared to deps from repos? Addons from repos like leaflet are picked up.

Snip from my build.gradle.kts:

plugins {
    kotlin("jvm") version "1.9.23"
    kotlin("plugin.serialization") version "1.9.23"
    id("com.vaadin") version "24.2.12" // tried also 24.3.7
}
dependencies {   
    // other deps removed
    // leaflet addon works
    implementation("com.xdev-software:vaadin-maps-leaflet-flow:4.0.1")
    // mediaquery addon ignored on productionBuild
    implementation(files("libs/mediaquery-5.0.3.jar"))
}
vaadin {
    productionMode = true
}

What I was able to see from running tasks with --info:

  1. On :compile mediaquery is on classpath
  2. In :vaadinPrepareFrontend the js files from mediaquery.jar are placed to frontend/generated/jar-resources
  3. But when :vaadinBuildFrontend runs the classpath to NodeTasks.Builder does not contain mediaquery-5.0.3.jar → js files don’t get scanned and included to generated-flow-imports.

I will try tomorrow. Do you have a sample repo to reproduce it?

I have never used that files syntax. Directory is bit weird for this JC’s add-on: it doesn’t show the custom repository it exists in. The leaflet add-on by XDEV is in central so that works out of the box :+1:

I tested with my yesterdays Kotlin webinar example an there it worked like this:

Are you sure you enabled the production mode for the build? Some add-ons work without the front-end build and that might be the case for the leaflet add-on as well :man_shrugging:. In my test project all worked fine with these commands from CLI:

./gradlew -Pvaadin.productionMode=true build
java -jar build/libs/kotlinwebinar-0.0.1-SNAPSHOT.jar

The files() clause includes a dependency not from a repository, but rather from a filesystem; in this case from a folder libs/ committed to the git repository. :vaadinBuildFrontend not including this kind of dependency into classpath sounds like a bug in the Vaadin Gradle plugin. Could you please open a ticket at Issues · vaadin/flow · GitHub and attach a very simple Gradle project which reproduces the issue?

Probably related to this similar issue for Maven support maven system dependency · Issue #2230 · vaadin/hilla · GitHub

1 Like

Here’s a repo: GitHub - elaintarha/vaadin-naughty-dep

Ticket is here Gradle vaadinBuildFrontend does not include filesystem dependency to classpath · Issue #19024 · vaadin/flow · GitHub