aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes My Project Cannot Import Other Maven Projects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "My Project Cannot Import Other Maven Projects" Watch "My Project Cannot Import Other Maven Projects" New topic
Author

My Project Cannot Import Other Maven Projects

Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
Hi, I work in a team. We have a division of labor arrangement. Under our project, each developer is assigned a sub-task. Each sub-task receives some input parameters from its upstream sub-task and generates some outputs for the downstream sub-task.

All developers first work indepently. Each of us has our own folder in the Repository. Each of us makes an assumption on the values of the input parameters received. (We later on integrate all sub-tasks.)

I generate my Java classes under a folder called "Orchestrator", and I access some classes under the folder called "common". Things go smoothly.

Thereafter, I start accessing other folders. I first retrieve other folders from the Repository and then in the Eclipse Package Explorer View --> import --> Import Existing Maven Projects ... No problem. I have all other folders in the Package Explorer View.

However, when I start adding the import statements in my Java classes to access classes in other folder; for example,

I have the compilation error:
The import company_name.overall_project_name.project_name.folder_name cannot be resolved


First, I have no problem to access the "common" folder. The code I have below does not have compilation error and I am able to use the class that is imported:

Second, I have checked the consistency of path and folder name.

Can anybody give me a clue? Thank you.



Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

Since you are creating a Maven project, you need to add a dependency to your pom.xml for the artifact that includes the "company_name.overall_project_name.project_name.folder_name.subfolder_name.class_name" class.

In other words, each project must create an artifact which goes into a central Maven repository (you do have one of those, right?), and each project must list in its pom.xml the artfiacts of the projects on which it depends.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My Project Cannot Import Other Maven Projects