Gradle Packing Jar Vue in Spark

I am linking Vue to the Spark Java interface.
Both modules are built independently, which works great 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 binds backend/src/main/resources/publicto the Jar /public. Therefore, I copied from ui/distin backend/src/main/resources/publicas a dependency of the task jar.

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

  jar.dependsOn( copyUI)

Gradle copies the files, but then creates a jar.
In other words, I have to create a jar twice so that everything is correct.

How can I instruct Gradle to wait for the copy to complete before packing / publishing

My build.gradlejar 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) }
    }
}
+4
source share
1 answer

, , ( ) , gradle . -, .

jar ../ui/dist from. , public.

jar {
    // ...
    from( '../ui/dist')
}

, public ( ui), (, , - ).

, , jar dependsOn UI, dist ../ui/dist

+2

Source: https://habr.com/ru/post/1695791/


All Articles