在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):SpareBank1/monorepo-sample开源软件地址(OpenSource Url):https://github.com/SpareBank1/monorepo-sample开源编程语言(OpenSource Language):Java 51.7%开源软件介绍(OpenSource Introduction):Monorepo sampleThis repo showcases how one could structure and build monorepos with either Apache Maven or Bazel. The repoA couple of toy applications under
Continous integrationThe Maven and Bazel: a comparison of basic actionsMaven is really not a monorepo-native build tool (e.g. lacks trustworthy incremental builds, can only build java code natively, is recursive and struggles with partial repo checkouts) but can be made good use of with some tricks and usage of a couple of lesser known command line switches.
Notes
Sparse checkoutsA monorepo will naturally grow quite large quite fast and for many reasons engineers will for the most time prefer to only have a subset of the tree checked out at once. Git sparse checkouts provides a mechanism for archieving this. Executing: git config core.sparseCheckout true
echo '/*' > .git/info/sparse-checkout
echo '!/apps/*' >> .git/info/sparse-checkout
echo '/apps/app1/*' >> .git/info/sparse-checkout enables sparse checkouts and configures git to checkout the the whole tree except all apps other than app1. To make it happen, either run a checkout command or to update the work tree in-place:
Notes for MavenSparse checkoutsWhile Bazel is fine with sparse checkouts, Maven struggles as a sparse checkout typically implies that there will be pom.xml-references to submodules that no longer are present on disc. A hack to work-around this is to use Maven profiles that only activates when the corresponding pom.xml-file is available on disc: <profile>
<id>app2</id>
<activation>
<file>
<exists>app2/pom.xml</exists>
</file>
</activation>
<modules>
<module>app2</module>
</modules>
</profile> Build parallelizationMaven requires explicit setup to build modules in parallell. This can be provided as a switch on the
command-line ( VersioningMaven requires you to provide an version for every module in its Project Object Model. This is confusing and superflous in monorepos as the they are typically exclusively versioned by the version control system. This repo takes advantage of Maven's newish support for so-called CI Friendly Versions. This makes it possible to ensure that the version of all Maven modules are set to current git HEAD at build-time: $ mvn clean install -Drevision=$(git rev-parse HEAD) To ensure that no CI-friendly version placeholders ( Partial buildsMaven's lack of incremental build support can lead to long build times in a large monorepo. The partial-build-plugin can be used to only build modules that has a diff against the trunk branch. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论