In Maven, how output the classpath being used?

后端 未结 7 1323
庸人自扰
庸人自扰 2020-12-12 23:31

For my current purposes I have a Maven project which creates a war file, and I want to see what actual classpath it is using when creating the war.

7条回答
  •  心在旅途
    2020-12-13 00:37

    As ecerulm noted in his comment to Janik's answer, you may want to specify the scope to dependency:build-classpath, as classpath output will differ for different scopes (by default test is used for some reason). I've ended up with a command like this:

    mvn -DincludeScope=compile dependency:build-classpath
    

    Within the POM, it could be used like this:

    
      [...]
      
        
          
            org.apache.maven.plugins
            maven-dependency-plugin
            2.9
            
              
                build-classpath
                generate-sources
                
                  build-classpath
                
                
                  compile
                  
                  ${project.build.directory}/compile-classpath.txt
                
              
              
                build-test-classpath
                generate-test-sources
                
                  build-classpath
                
                
                  test
                  
                  ${project.build.directory}/test-classpath.txt
                
              
            
          
        
      
      [...]
    
    

    This will output 2 versions of classpath, one for main build and the other for tests.

提交回复
热议问题