Maven - Suppress [WARNING] JAR will be empty - no content was marked for inclusion in pom.xml

前端 未结 6 1255
再見小時候
再見小時候 2021-02-12 21:16

My maven project intentionally only needs src/test/java and src/test/resources. After removing src/main/* folders, the expected w

6条回答
  •  别那么骄傲
    2021-02-12 21:55

    This is (according to me) the cleanest solution
    for projects that don't contain production code but do contain tests:

        
            
                
                    org.apache.maven.plugins
                    maven-jar-plugin
                    
                        true
                    
                
                
                    org.apache.maven.plugins
                    maven-install-plugin
                    
                        true
                    
                
                
                    org.apache.maven.plugins
                    maven-deploy-plugin
                    
                        true
                    
                
            
        
    

    It indicates what you want:

    • to skip trying to package "no production code" into a jar
    • don't try to install/deploy the non-existing jar

    leaving test execution untouched.


    Like @John Camerin mentioned it is NOT advised to use pom
    unless the ONLY thing your pom should do is gather dependencies.
    Otherwise, if you have tests, they would be skipped without warning, which is not what you want.

提交回复
热议问题