2

So I have been assigned a task to convert our applications from Ant to Maven as a part of Devops migrations. I have handled the dependencies except for few which are not present on the nexus repository. I have kept those dependencies in a location under the project's web folder (which gets converted into .war file) under the path (Sorry I cant share the official name and code of the project due to legal issues so sharing a similar project structure and code)

applicationName -> WebContent -> WEB-INF -> lib

Here is the project's folder structure :

ApplicationName(.jar)

ApplicationName-ear(.ear) 

ApplicationName-build

ApplicationName-web(.war)

Sample Structure :

/Users/ankit/Desktop/Screenshot 2018-10-02 at 1.54.58 PM.png

Now under the pom.xml of ApplicationName-web project I have entered the following snippet to read the jars from the lib folder :

                <plugin>
                  <groupId>com.googlecode.addjars-maven-plugin</groupId>
                  <artifactId>addjars-maven-plugin</artifactId>
                  <version>1.0.5</version>
                  <executions>
                    <execution>
                        <goals>
                            <goal>add-jars</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${basedir}/WebContent/WEB-INF/lib</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                  </executions>
                </plugin>

but it is still not reading the jars from that location and giving an error like "package {name of the package} does not exist" when i user maven-install under run-as. I am also referring this jar in the ApplicationName(.jar) project as well and I was hoping that it would automatically read the jar once it is added via the above plugin.

I hope my question made sense, I tried to explain it the best I can and again sorry for not providing the actual code snippet and pom.

TL;DR : How to add .jar files present in lib folder of your project as dependencies via maven.

Ankit Jain
  • 121
  • 6
  • Possible duplicate of [Can I add jars to maven 2 build classpath without installing them?](https://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them) – Till Brychcy Oct 02 '18 at 08:59
  • If you are building an EAR you have to make dependencies of the EAR to war module and using the maven-ear-plugin (packaging: ear) which combines them into the final EAR automatically without using strange plugin addjars-maven-plugin which is the wrong way...Take a look here as an example: https://github.com/khmarbaise/javaee – khmarbaise Oct 03 '18 at 08:32

1 Answers1

1

Short answer: You don't. You upload them to your company Nexus and then use them like any other Maven dependency.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142