#StackBounty: #gradle #vue.js #packaging #spark-framework Gradle Jar packaging Vue into Spark

Bounty: 50

I am bundling a Vue UI with a Spark Java backend.
Both modules are built independently, which works fine with the following structure:

  project
  +-- backend
  |   +-- src
  |   |   +-- main
  |   |       +-- resources
  |   |           +-- public <= Where the jar is picking the static files
  |   +-- build
  |       +-- libs <= Gradle Jar output
  +-- ui
      +-- dist <= Vue build output

On the backend, Gradle is bundling backend/src/main/resources/public into the Jar /public. Hence I copied from ui/dist into backend/src/main/resources/public as a jar task dependency.

  task copyUI(type: Copy) {
      from( '../ui/dist')
      into( 'src/main/resources/public')
  }

  jar.dependsOn( copyUI)

Gradle is copying the files but after creating the jar.
In other words, I have to create the jar twice to get it right.

How can I instruct Gradle to wait the copy completion before packaging /public

My build.gradle jar section looks like this

jar {
    manifest {
        attributes(
                'Main-Class': 'tld.domain.MainClass'
        )
    }
    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
        configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
    }
}


Get this bounty!!!

Leave a Reply