How to copy dependencies jars (without test jars) to a directory using maven?

后端 未结 3 1683
陌清茗
陌清茗 2021-01-01 09:57

I see maven-dependency-plugin does this; however, it seems to copy everything (including test jars) to the destination directory. Anyone know how to configure t

3条回答
  •  一整个雨季
    2021-01-01 10:51

    Mike answered their own question in a comment above. I think Mike's use case is similar to mine where I want to copy all of the jars I depend upon as well as my own jar in order to create a directory hierarchy sufficient to execute the program without including those dependencies directly into my own jar.

    The answer to achieve this is:

    compile
    

    This directive goes into the section of the pom.xml for the maven-dependency plugin. For example:

    
        org.apache.maven.plugins
        maven-dependency-plugin
        2.4
        
            
                copy-dependencies
                prepare-package
                
                    copy-dependencies
                
                
                    ${project.build.directory}/lib
                    compile
                
            
        
    
    

    excludeScope won't work because excluding test aborts the build and excludes all possible scopes. Instead the included scope needs to be adjusted.

提交回复
热议问题