Creating a Java Maven Dependency Project
This tutorial shows you how to create a generic Java Maven dependency project for consumption by a MyEclipse Web project, or any other Maven project. The steps cover basics of creating andconsuming Maven dependencies. You will learn how to:
- Create a Maven utility project
- Add a dependency to a project
- Add the utility project as a dependency
This feature is available in MyEclipse.
1. Create a Maven Utility Project
The Maven utility project will be consumed by an existing Maven project.
- Create a project with Maven support that will consume the project created in this tutorial.
- Select File>New>Project, type Maven in the search field, select Maven Project, and click Next.
Creating a new Maven project - Select the Create a simple project checkbox, and click Next.
- Enter group and artifact IDs and a project name, and click Finish.
Project configuration
2. Add a Java Maven Dependency to the Utility Project
- Right-click the utility project, and select Maven>Add Dependency.
- Type a dependency name in the Enter groupID… field (e.g., commons-logging) to search for a dependency.
Selecting a dependency - Select the dependency, and click OK.
- Expand the utility project, right-click the pom.xml file, and select Run As>Maven Install to install the file into the local repository.
- View the Console. When it displays “Build Success,” the utility project is available for reference by other projects.
Successful build
3. Add the Utility Project as a Dependency
- Right-click the consuming project, and select Maven>Add Dependency.
- In the Enter groupId… field, type com.mycompany or the group ID you entered when you created the utility project.
Adding the utility project as a Java Maven dependency to the consuming project - Select the utility project, and click OK. The dependency is added to the consuming project’s pom.xml file.
- Right-click pom.xml file of the consuming project, and select Run As>Maven Build.
Maven build configuration - Select goals, and edit other build configurations as necessary, and click Run. Watch the console messages for a successful build message.
Note: If you click the Select button to specify goals and the goals list is empty, you need to enable the full repository index. To do so, open the Maven Repositories view, and expand Global Repositories. Right-click Central, and select Enable Full Index. It will take several minutes for the indexes to update.
Enabling a full repository index