简体   繁体   中英

Adding Local Jar To Parent Module In Maven

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

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM