![]() ![]() SharedLibrary project is the first module ConsoleApp project is the second module and DesktopApp is the third module. Each module is a separate project.The following picture explains a Maven’s project structure with multiple modules: Here, CompanyProject is the root Maven project (packaging type must be pom). Building as Maven project, it would consist of 3 modules: Shared library, Console app and Desktop app. There’s a very common development scenario in which we need to develop an application that consists of some modules, as depicted below: You see, this application has some common code that is shared between the console program and desktop program. ![]() Maven should have generated jar file for each project there.That’s how to create a multi-module Maven project in Eclipse IDE.In this tutorial, I’d like share with you, guys, about how to create a multi-module Maven project in Eclipse IDE. Build a Multi-Module Maven project in Eclipse IDETo build the whole multi-module Maven project in Eclipse, right click on the root project, and select Run As > Maven install… Maven will build this multi-module project including sub modules as follows: Now you can check the target directory in each project. SwingUtilities.invokeLater(new Runnable() void run() You see, this class also makes use of the CommonUtility class from the SharedLibrary project.ĥ. Static String appName = CommonUtility.getAppName() Īdd(new JLabel("Welcome to " + appName)) The root project’s pom.xml should be updated for containing 3 modules as follows: įor demo purpose, code a simple Swing program for the desktop program with the following code: package com.mycompany Create the third Maven moduleNext, let’s create the third Maven module for the DesktopApp project. }You see, this class makes use of the CommonUtility class from the SharedLibrary project.Ĥ. String appName = CommonUtility.getAppName() And in the ConsoleApp project, it should refer to the SharedLibrary project in the pom.xml file follows: Īnd write simple console program as below: package com.mycompany Create the second Maven moduleSimilarly, create the second Maven module for the ConsoleApp project. }The static method getAppName() will be used by both console app and desktop app.ģ. Then code a simple class in the SharedLibrary project as follows: package com.mycompany And in the SharedLibrary project, its parent information is specified as below: Here, the packaging type of the root project is pom. Else click Finish to create the first module with the same groupId as the root project.You can notice a new module is added to the root project’s pom.xml file as below: Then choose Maven Module in the New Project dialog: Then in the New Maven Module Dialog, check the option “Create a simple project”, and enter module name as SharedLibrary as follows: Click Next if you want to specify project information for this module. Right-click on the CompanyProject in the Package Explorer/Project Explorer view, then select New > Project… from the context menu. Create the first Maven moduleNext, let’s create the first Maven module for the shared library project. Eclipse will create a simple Maven POM project that acts as the root project for sub modules.Ģ. In the New Maven Project dialog, check the option Create a simple project (skip archetype selection): Then enter project name and specify information for the Maven project as below: Choose the packaging type is pom. ![]() Create the root Maven projectIn Eclipse, click File > New > Project… and choose Maven > Maven project from the New project wizard: The packaging type of modules can be jar or war.Now, let’s see how to create this multi-module Maven project in Eclipse IDE. In this tutorial, I’d like share with you, guys, about how to create a multi-module Maven project in Eclipse IDE. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |