Gradle projects depending on artifacts created by sibling projects

前端 未结 2 2043
梦毁少年i
梦毁少年i 2020-12-30 05:09

I have this Gradle setup with four projects, a parent with three children, where a Java Servlet JSON \'backend\' is built into a war-file, and then a static HTML5 \'frontend

相关标签:
2条回答
  • 2020-12-30 05:57

    Using this post and ideas from elsewhere I made a github project - https://github.com/istomisgood/WarNode

    0 讨论(0)
  • 2020-12-30 06:13

    The local Maven repository (and Gradle's install task) should only be used when exchanging artifacts with Maven builds. It's not meant to be used for exchanging artifacts between projects of a Gradle build, and installing into the local Maven repository won't happen automatically.

    Instead, merger needs to declare project dependencies on the other two projects. For example:

    configurations {
         merge
    }
    
    dependencies {
        merge project(":frontend"), project(":backend")
    }
    
    task merge(type: Zip) {
        from { configurations.merge.collect { zipTree(it) } }
    }
    

    This assumes that frontend and backend correctly declare their artifacts. (This may happen automatically, for example if the war plugin is used.)

    You'll find much more on this in the Gradle User Guide, in particular the multi-project builds chapter.

    0 讨论(0)
提交回复
热议问题