-1

When I run Maven install I see my .jar files are getting copied into the repository location:

[INFO] --- maven-install-plugin:2.4:install (default-install) @ data-model ---
[INFO] Installing E:\java\web\data-model\target\rest-server.jar to C:\Users\Stefan\.m2\repository\com\mahlzeit\server\data-model\0.0.1-SNAPSHOT\data-model-0.0.1-SNAPSHOT.jar
[INFO] Installing E:\java\web\data-model\pom.xml to C:\Users\Stefan\.m2\repository\com\mahlzeit\server\data-model\0.0.1-SNAPSHOT\data-model-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

I'm referencing those in my pom.xml:

<dependencies>
    <dependency>
        <groupId>com.mahlzeit.server</groupId>
        <artifactId>mahlzeit-data-model</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>com.mahlzeit.server</groupId>
        <artifactId>mahlzeit-shared</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>

I'm having of course a few more dependencies from remote locations. Those dependencies are getting downloaded and placed into <project>/war/WEB-INF/lib as they should - but not my local files data-model-0.0.1-SNAPSHOT.jar and shared-0.0.1-SNAPSHOT.jar.

Why doesn't Maven copy those files like it does with the other files into <project>/war/WEB-INF/lib?

This is the /lib directory where you can see that Hibernate dependencies are getting downloaded and copied into this directory:

enter image description here

Edit: Thinking about it I might be running into the same issue again while trying to avoid it.

Community
  • 1
  • 1
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
  • is your requirement to include those dependencies inside your jar? – Ramzy Jun 05 '15 at 16:38
  • So you want to include the classes from those jar files into the web-inf/classes folder of your war. Am I right. – Ramzy Jun 05 '15 at 16:41
  • ok good. Happy Coding. comment once the issue resolved. – Ramzy Jun 05 '15 at 16:53
  • @Ramzy You mean when I fixed my question? :) – Stefan Falk Jun 05 '15 at 17:37
  • At this point, I'd need to see your WAR POM and see the maven log when run with -X. – tdrury Jun 05 '15 at 17:39
  • 1
    Is maven finding the jars at this folder **com.mahlzeit.server.mahlzeit-data-model** and **com.mahlzeit.server.mahlzeit-shared**. Because that is how I think, maven finds them. In your logs, they are installed at **.m2\repository\com\mahlzeit\server\data-model\** which is different. I am not completly sure, if thats how the jars are placed by mavaen and are being looked upon. But definitely, thats the folder structure I found – Ramzy Jun 05 '15 at 17:43
  • Ramzy, good catch. The maven repo stores artifacts in a subdir using each dotted element of the groupId and then the whole artifactId another subdir, followed by each version. The installed dir is "data-model" but the artifactId is mahlzeit-data-model. – tdrury Jun 05 '15 at 17:54

1 Answers1

1

Maven checks, by default, for newer versions of dependencies on remote repos once per day. So the next day, if you haven't rebuilt those artifacts and someone else made changes and deployed them to the remote repo, then when you build your war, it will pull those newer snapshots from the remote.

To avoid this either run in offline mode, or make sure you locally build those artifacts within one day of building the war.

tdrury
  • 2,307
  • 1
  • 22
  • 25
  • I have just installed those files on the repository but they're not getting copied anyway - not even in offline mode for some reason. – Stefan Falk Jun 05 '15 at 17:33