본문 바로가기

Study/Java

세 가지 모듈(Module) - Java 9 Module, IntelliJ IDEA Module, Module of Build System

반응형

Java 9의 모듈과 IntelliJ IDEA에서 모듈, Maven, Gradle과 같은 빌드 도구에서 모듈은 서로 다른 개념이다.

 

자바 모듈

- 자바 9에서는 클래스들을 분류하는 방법으로 패키지 외에 Jigsaw 프로젝트로 불리는 자바 모듈 시스템(JPMS, Java Platform Module System)이 추가되었다.

 

Jigsaw 프로젝트는 JEP 200: The Modular JDK에서 처음 논의가 시작 되었는데 모듈 시스템은 클래스와 JVM을 물리적으로 묶기 위한 형식을 정의한다. 모든 JVM마다 제공되던 표준 클래스들은 이제 자바 모듈로 묶어서 제공된다.

 

JEP 200: The Modular JDK

JEP 200: The Modular JDK Summary Use the Java Platform Module System, specified by JSR 376 and implemented by JEP 261, to modularize the JDK. Goals Divide the JDK into a set of modules that can be combined at compile time, build time, and run time into a v

openjdk.java.net

자바 모듈의 장점은 콘솔 앱이나 데스크탑 앱은 각각의 앱에서 실제 사용되는 클래스들과 묶인 JVM만을 갖도록 만들 수 있다. 전체 표준 자바 클래스들의 모듈들은 생략할 수 있는데 이는 결국 만들어지는 앱의 크기(용량)를 줄여서 프로그램 실행 부담을 줄여준다.

 

자바 9 모듈 시스템은 모듈 서술자(module descriptor) 명세를 통해 추가적인 기능을 제공한다.

- 다른 모듈들에서 현재 패키지를 이용할 수 있게 명시적으로 만든다.

- exports : 서비스들(모듈)을 제공할 수 있다.

- requires : 서비스들(모듈)을 사용할 수 있다.

- opens : 다른 모듈들에서 참조되는 모듈들을 사용할 수 있게 한다.

 


 

IntelliJ 프로젝트 모듈

IntelliJ 같은 통합개발환경(IDE, Intergrated Development Environment)은 모듈들을 포함하는 IDE만의 시스템을 정의했다. IntelliJ IDEA에서 모듈은 단지 서브 프로젝트다. 모듈은 이클립스에서의 프로젝트와 의미가 같고, 워크스페이스는 여러개의 프로젝트들을 가질수 있다.

 

IntelliJ IDEA는 이미 프로젝트를 위한 모듈 개념을 가지고 있다. 모든 IntelliJ IDEA 모듈은 각 모듈의 클래스패스에 빌드한다. IntelliJ IDEA는 자바 플랫폼의 클래스패스 대신 모듈패스를 사용할 수 있도록 지원함으로써 IntelliJ IDEA의 모듈 개념을 확장시켰다.

IntelliJ IDEA에서 Java 9 모듈 프로젝트 만들어보기 : https://blog.jetbrains.com/idea/2017/09/java-9-and-intellij-idea/

 

Java 9 and IntelliJ IDEA – IntelliJ IDEA Blog | JetBrains

Java 9 is released today, so let's do a quick recap of the existing Java 9 support in IntelliJ IDEA, and have a peek at some of the upcoming features in IntelliJ IDEA 2017.3 for Java 9.  Java 9 has be

blog.jetbrains.com

 

---

 

빌드 시스템의 모듈

메이븐(Maven)과 그레이들(Gradle)과 같은 빌드 시스템도 여러개의 서브 프로젝트들로 구성된 프로젝트인 모듈 개념을 사용하고 있다.

 

요즘 자바 개발자들은 프로젝트에서 대부분 빌드 시스템을 사용한다. 빌드 시스템을 사용하는 프로젝트는 다양한 하위 프로젝트들을 독립적으로 컴파일한 뒤 하나의 프로젝트로 만들 수 있다. 

 

---

 

참고 링크 : 

 

[What are 'modules' in intellij IDEA,actually? Is it different from a Java module?](https://stackoverflow.com/questions/57116629/what-are-modules-in-intellij-idea-actually-is-it-different-from-a-java-module)

 

[Is IntelliJ IDEA project Module different concept from Java 9 Module?](https://stackoverflow.com/questions/55834885/is-intellij-idea-project-module-different-concept-from-java-9-module)

 

[Understanding Java 9 Modules](https://www.oracle.com/corporate/features/understanding-java-9-modules.html)

 

[Support for Java 9 Modules in IntelliJ IDEA 2017.1](https://blog.jetbrains.com/idea/2017/03/support-for-java-9-modules-in-intellij-idea-2017-1/)

 

[Modules](https://www.jetbrains.com/help/idea/creating-and-managing-modules.html#multimodule-projects)

 

[Configure projects](https://www.jetbrains.com/help/idea/working-with-projects.html#settings-types)

 

[A Guide to Java 9 Modularity](www.baeldung.com/java-9-modularity)

반응형