Share test resources between maven projects

前端 未结 4 1699
太阳男子
太阳男子 2020-11-29 04:07

There is a clear solution for sharing the common test code between maven projects using test-jar goal of maven-jar-plugin plugin (see here).

<
4条回答
  •  暖寄归人
    2020-11-29 04:25

    Just use jar:test-jar and declare the resulting JAR as a dependency (refer to this guide for more details). And while I don't understand the problem of having resources and classes in this jar, you can always exclude all .class files:

    
      
        
         
           org.apache.maven.plugins
           maven-jar-plugin
           2.2
           
             
               
                 test-jar
               
             
           
            
             
               **/*.class
             
            
         
        
      
    
    

    And to use it:

    
      ...
      
        
          com.myco.app
          foo
          1.0-SNAPSHOT
          test-jar
          test
        
      
      ...
    
    

提交回复
热议问题