- Modular Programming in Java 9
- Koushik Kothagal
- 357字
- 2021-07-02 18:38:24
Module versioning
There's one aspect of module dependency that you might have noticed is missing from what we've covered so far--versioning. When you declare a module definition, can you specify a version number for the module? Also, when you specify that a certain module requires another module, can you also specify which version of module it needs? The answer to both the questions is no. For various reasons, module versioning is not a feature that's available in the Java Module system. It is not a problem the Java platform attempts to solve.
The biggest advantage and utility with module versioning comes with dependency management. Think of tools like Maven or Gradle. These tools allow you to configure specific versions of external dependencies which they can then automatically download for you from some remote repository, and then make them available in the classpath. The Java platform does not attempt to do this, or to solve any dependency management problems. It assumes that all the dependencies are already available, perhaps assembled by a tool like Maven or Gradle. In Chapter 1, Introducing Java 9 Modularity, I had mentioned how build tools like Maven or Gradle achieve predictability and consistency in assembling dependencies, but they cannot validate the accuracy or completeness of what's assembled. This is where the Java module system steps in. The platform assumes that all the necessary source files and classes are already there! Whatever your build tools are, and whatever the means you take to assemble your code and libraries, the Java platform works on what you have as a result and then makes sure the module contracts are being met.
This is a nuanced topic, and the reasoning can be debated extensively, but it's important to remember that module versioning is not available in Java 9. To manage multiple versions of modules, you are free to use whatever tools or processes you have already been using to pull in jars and libraries. In Chapter 12, Using Build Tools and Testing Java Modules, we examine how to integrate a Maven multi-module project with a Java 9 modular application to leverage the best of both worlds.
- TypeScript Essentials
- Instant Apache Stanbol
- Django Design Patterns and Best Practices
- FLL+WRO樂(lè)高機(jī)器人競(jìng)賽教程:機(jī)械、巡線與PID
- Python+Tableau數(shù)據(jù)可視化之美
- 軟件供應(yīng)鏈安全:源代碼缺陷實(shí)例剖析
- Android智能手機(jī)APP界面設(shè)計(jì)實(shí)戰(zhàn)教程
- 軟硬件綜合系統(tǒng)軟件需求建模及可靠性綜合試驗(yàn)、分析、評(píng)價(jià)技術(shù)
- Elasticsearch搜索引擎構(gòu)建入門與實(shí)戰(zhàn)
- Mastering JavaScript Promises
- Android熱門應(yīng)用開發(fā)詳解
- C++從零開始學(xué)(視頻教學(xué)版)(第2版)
- Android Application Programming with OpenCV 3
- LabVIEW案例實(shí)戰(zhàn)
- 網(wǎng)頁(yè)設(shè)計(jì)理論與實(shí)踐