0

My Parent Module is building fine but jars from /lib folder in Parent Project are not getting copied to .m2 directory. No jar file "sqljdbc" is generated from mentioned dependency; See below parent.pom.xml file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>common</groupId>
  <artifactId>common-parent</artifactId>

  <version>0.0.1-SNAPSHOT</version>
  <name>common-parent</name>
  <packaging>pom</packaging>
  <description>It's a Parent Project for Child Projects</description>

   <repositories>
        <repository>
            <id>in-project</id>
            <name>In Project Repo</name>
            <url>file://${project.basedir}/lib</url>
        </repository>
    </repositories>
    <build>
    <finalName>common-parent</finalName>
    </build> 
     <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>microsoft</groupId>
            <artifactId>sqljdbc</artifactId>
            <version>4</version>
        </dependency>
    </dependencies>
  </dependencyManagement>
      <modules>
         <module>../FirstChild</module>
      </modules> 

</project> 

Let me know if i am missing someting. Further i am following https://dzone.com/articles/maven-multi-module-project-with-versioning To generate modules

ALI
  • 93
  • 1
  • 1
  • 9
  • 1
    Have you tried installing the jar with maven ? `mvn install:install-file -Dfile={full path of the jar} -DgroupId={groupId} -DartifactId={artifactId} -Dversion={version} -Dpackaging=jar` – Sagar Ahuja Jan 08 '20 at 16:47
  • What you should expect to happen, is that the artifacts found in the provided folder is copied to .m2 when needed. The layout of the folder needs to be precisely as expected by maven. We cannot tell from the question as it stands now, if that is the case. – Thorbjørn Ravn Andersen Jan 08 '20 at 17:53
  • 1
    The most important thing is to start using a repository manager and put your dependencies which can't be built/downloaded form open repositories. That will make your process easier etc. – khmarbaise Jan 08 '20 at 20:10
  • @ThorbjørnRavnAndersen Yes you are absolutely right that's what i am expecting. jar should be copied to .m2 from my project's /lib folder. – ALI Jan 09 '20 at 08:10
  • @khmarbaise That is the maven mindset but this allows you to embed those in your sources making your build setup less complex. – Thorbjørn Ravn Andersen Jan 09 '20 at 09:38
  • 1
    @ALI The layout needs to be absolutely correct for this to work. I've done it. – Thorbjørn Ravn Andersen Jan 10 '20 at 08:12

2 Answers2

0

You add the file as a dependency and not a repo with a path on your disk, I dont know if that works, but this does.

<dependency>
  <groupId>microsoft</groupId>
  <artifactId>sqljdbc</artifactId>
  <version>4</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/lib/name.jar</systemPath>
</dependency>
Maxdola
  • 1,562
  • 2
  • 10
  • 29
  • 1
    System scope is deprecated for a long time. – khmarbaise Jan 08 '20 at 20:09
  • Great then you could write a better way, but thats the only way I know to use it and it works. – Maxdola Jan 08 '20 at 20:12
  • @Maxdola This way i would have to specify every single Jar file (if i would have other dependencies in future) from /lib folder of my project. There should be a better way other than explicit jar name. – ALI Jan 09 '20 at 08:19
  • 1
    In maven you have to define every dependency you are having so I don't see why this is a bad way because you have to define every jar. – Maxdola Jan 09 '20 at 09:39
0

You can add the jar to your project in the that suggest @Maxdola, but if you want to generate a jar file with dependencies, maven will not include it. This is what happens to me.