5

I have two Maven projects. One should be a dependency to another. Both have pom.xml files. When I search repository, it sees the local project and automatically added.

The pom.xml entry when I add it:

<dependencies> <dependency> // for another dependency, an external jar <groupId>..</groupId> <artifactId>..</artifactId> <version>...</version> </dependency> <dependency> // the one for other project which I want to add as dependency <groupId>..</groupId> <artifactId>..</artifactId> <version>..</version> </dependency> </dependencies> 

But the references to that project can not see the classes. Is there some specific way to do that, instead of adding from repository?

2
  • How does your pom.xml look like? Commented Mar 5, 2015 at 8:27
  • I added, please check. Commented Mar 5, 2015 at 8:36

2 Answers 2

3

You set the type of dependency using the <type> tag inside <dependency> tag.

<dependency> <groupId>..</groupId> <artifactId>..</artifactId> <version>...</version> <type>jar OR war OR ejb-client OR test-jar</type> </dependency> 

The default value for type is jar

Sign up to request clarification or add additional context in comments.

Comments

0

I supoose you want this because you are observing that the changes made in dependent are not getting reflected in parent project.

Ideally you should follow this

  1. Make changes in dependent
  2. mvn clean install dependent so that updated jar is added in local repo
  3. mvn clean eclipse:eclipse parent jar so that updated dependent jar is added to build path of parent project

If you want to avoid this do the following (although not highly recommended)

Parent Project -> Properties -> Java Build Path -> Libraries -> Add JAR -> Select ur dependent project in same workspace-> build

1 Comment

I need to use this dependency as a project, not a jar. For some reason I don't know, some scheme files in this project is not visible when it's jar, but they are visible when project is an Eclipse project with sources.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.