2
votes

We have a maven project in which we use some artifacts that are not present in any remote repositories. They are included in our project in some directory, say /lib, as compiled .jar files. Some of these are "plain" dependencies which we can utilize from /lib using scope system + systemPath, however there is one artifact that should be used with the maven-dependency-plugin unpack goal. The relevant part of the pom.xml looks like this

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-dependency-plugin</artifactId>
   <executions>
       <execution>
           <id>unpack-resources</id>
           <phase>generate-resources</phase>
           <goals>
               <goal>unpack</goal>
           </goals>
           <configuration>
               <artifactItems>
                   <artifactItem>
                       <groupId>xxx.yyy.zzz</groupId>
                       <artifactId>ourartifact</artifactId>
                       <outputDirectory>${target.directory}/somedir</outputDirectory>
                       <includes>
                           files1/**,files2/**,files3/**
                       </includes>
                   </artifactItem>
               </artifactItems>
           </configuration>
       </execution>
   </executions>
</plugin>

However this still tries to reach out to the remote repository and fetch the artifact from there, which of course does not succeed. Can we somehow achieve that this artifact is also attempted to be fetched from /lib?

1
Have you considered standing up a local Nexus server and putting your local artifacts in it?azurefrog
Yes, we are currently going round the issue by simply installing all the artifacts into local maven repos, but on the long range the expectation is to resolve via the above described way, because project restrictions will not allow to install the artifacts into remote repositoryhammerfest

1 Answers

0
votes

Instead of fetching from /lib, and if setting up your own Nexus/Artifactory/etc... is a bit much right now, you could add the jar to your local repository. Each individual would have to do this on their own computer, but once there, it would be available to all the maven built projects on that machine, so you wouldn't have to have a /lib copy for each project. If you are compiling that jar yourself and it is a maven project, you can do "mvn install" and that will install to your local repo. Note that mvn package won't install to your local repo.

If this is a 3rd party jar, you can use mvn install:install-file to do this. To do this, follow the instructions at https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html .

Hope this helps!

Update: by local repository, I might mean differently than you referred to in your comment -- I mean the local repository on each user's computer, versus a repository server that is local to your intranet. Sorry if that caused any confusion :)