Gradle projects depending on artifacts created by sibling projects

前端 未结 2 2042
梦毁少年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 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.

提交回复
热议问题