khalilou88 / jnxplus

Nx plugins that adds Java/Kotlin monorepo support to Nx workspace using Gradle and Maven
MIT License
55 stars 13 forks source link

jnxplus and nx remote caches #1137

Open shanon84 opened 2 days ago

shanon84 commented 2 days ago

Hey there, I have another performance suggestion. For context: We have a NX Monorepo with about 150 nx maven projects. A build nearly always results in a complete fullbuild (even with affected), because every change results in all dependencies to be build and all projects using your changed projects (and all there dependencies too). It cascades up to all the apps resulting in a fullbuild. To takle the build time we switched from local caching to remote caching. But because we only cache the target folder of the maven project, we still need to run an install:install in a seperate step to install all jars in the target folders to be able to build the dependend projects. This still is a huge hit too performance, because we run 300 buildsteps now. Maybe the local m2 repository could be used to circumvent the additional install step, if for each project a simlink is created inside the m2 repository targeting the corresponding jar file in target folder (also for pom file). This way we would only need to run a mvn package in each project and get a completely remotely cacheable result.

Best regards

khalilou88 commented 2 days ago

Hi @shanon84 What are you asking for is already implemented, you need two steps to make it working:

  1. Add localRepoRelativePath to the plugin option (nx.json), so you can generate .m2 inside the workspace.

  2. Add {options.outputDirLocalRepo} to the outputs of the project you want to save its cache, by default it's libs and parent projects.

Check this Repo for examples: https://github.com/khalilou88/jnxplus-examples