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 and consuming 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
Duration Time: 20 Minutes
Don't have MyEclipse? Download Now
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.
- Select the Create a simple project checkbox, and click Next.
- Enter group and artifact IDs and a project name, and click Finish.
- Right-click the utility project, and select Maven4MyEclipse>Add Dependency.
- Type commons-logging or other dependency in the Enter... field to search for 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.
When the console displays "Build Successful," the utility project is now available for reference by other projects.
- Right-click the consuming project, and select Maven4Myeclipse>Add Dependency.
- In the Enter... field, type com.mycompany or the group ID you entered when you created the utility 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.
- 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.