How to include dependency with 'provided' scope with maven-assembly-plugin

前端 未结 5 569
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 18:27

I am fighting with maven to include a managed dependency with \'provided\' scope into tar file by using the maven-assembly-plugin.

I use super parent pom file as a base

5条回答
  •  名媛妹妹
    2021-02-01 18:33

    This can be done using the Assembly plugin.

    First create an assembly.xml with the following:

    
        bin
        
            jar
        
        false
        
            
                true
                runtime
            
            
                true
                provided
            
        
    
    

    Then just enable it in your pom.xml

    
        maven-assembly-plugin
        2.4
        
            src/main/assembly/assembly.xml
        
        
            
                make-assembly
                package
                
                    single
                
            
        
    
    

    This will create a yourproject-bin.jar that will include all the compile and provided resources exploded so they can be referenced in a classpath.

    java -cp yourproject-bin.jar com.yourcompany.Main
    

提交回复
热议问题