0

I have 2 maven projects; the first one has this pom:

<groupId>deseuri</groupId>
<artifactId>sim-common</artifactId>
<version>1.0.1</version>
<name>sim-common</name>
<dependencies>
    /*
        dependencies
    */
</dependencies>

In the second project, I want to use the first one as a dependency, like this:

 <groupId>utils</groupId>
 <artifactId>utils</artifactId>
 <version>1.0.1</version>
 <packaging>jar</packaging>
 <dependencies>
    <dependency>
        <groupId>deseuri</groupId>
        <artifactId>sim-common</artifactId>
        <version>1.0.1</version>
    </dependency>
    // other depdencies
</dependencies>

The first project build successfully with "mvn clean install", and it creates a jar file in my local maven repository (in .m2), but when I run clean install on the second project it says:

 package ro.sim.commonApp.model does not exist

...which is in the first project.

P.S.: If I choose "Make project" from Intellij Idea (which creates the source files in the target folder) and then run clean install it works fine.

Thanks, Tekin.

Tekin Omer
  • 63
  • 1
  • 10
  • no, when I tried "make project" from idea. This was due to an error of mine: I declared the source in project settings to be in the src folder, but maven wanted it to be in src/main/java. – Tekin Omer Oct 08 '14 at 13:32

1 Answers1

0

The problem is that your util project has an jar packaging, then from the description above you are trying to make an uber jar What is an uber jar?. To manage it in a correct way you can use Shade plugn

Community
  • 1
  • 1
Skizzo
  • 2,883
  • 8
  • 52
  • 99
  • Thank you for your answer. I don't want to create an uber jar, I just want this jar to be created and the dependency to be available at runtime. I tried adding the "runtime" and "provided" scope to the common dependency, but it doesn't actually do what I want. Any ideas on this?:) – Tekin Omer Oct 08 '14 at 07:35
  • In that case you have to suggest what is your new classpath (the place where this libraries live), otherwise java is not able to get your dependencies – Skizzo Oct 08 '14 at 07:40
  • I'm sorry, I don't understand. I don't want the dependency to be included in my jar, I want it to get the dependency from the classpath, whichever that may be. Can this be done? – Tekin Omer Oct 08 '14 at 07:46
  • Ok, but you have to indicate where are these dependencies? – Skizzo Oct 08 '14 at 07:51