Maven: add a dependency to a jar by relative path

后端 未结 9 1307
半阙折子戏
半阙折子戏 2020-11-21 23:21

I have a proprietary jar that I want to add to my pom as a dependency.

But I don\'t want to add it to a repository. The reason is that I want my usual maven commands

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 00:21

    This is working for me: Let's say I have this dependency

    
        com.company.app
        my-library
        1.0
        system
        ${project.basedir}/lib/my-library.jar
    
    

    Then, add the class-path for your system dependency manually like this

    libs/my-library-1.0.jar
    

    Full config:

    
        org.apache.maven.plugins
        maven-jar-plugin
        2.4
        
            
                
                    ${jdk.version}
                    ${project.name}
                    ${project.version}
                    ${project.name} Library
                    ${project.version}
                    libs/my-library-1.0.jar
                
                
                    true
                    com.company.app.MainClass
                    libs/
                
            
        
    
    
        org.apache.maven.plugins
        maven-dependency-plugin
        2.5.1
        
            
                copy-dependencies
                package
                
                    copy-dependencies
                
                
                    ${project.build.directory}/libs/
                
            
        
    
    

提交回复
热议问题