How to bundle static resources from other subproject into java application

Solution from here:

In the “frontend” subproject create a jar from some static files, and make it an artifact belonging to a configuration:

tasks.register('packageDistribution', Jar) {
  // ... add files here
  // for webjar, use next line
  // into "META-INF/resources"
}

// define new configuration
configurations {
    webjar
}

// tell gradle the task adds to the new configuration
artifacts {
    webjar packageDistribution
}

In the java subproject, do:

runtimeOnly(project(path = ":frontend", configuration = "webjar"))

Anyone, please correct me if that’s wrong.