Maven compile a source jar dependency

前端 未结 2 1071
粉色の甜心
粉色の甜心 2021-02-01 23:18

Let\'s say I have a project that uses a dependency that can be found in the Maven repository. However, lets also say that the jar file that will be downloaded is NOT in a format

2条回答
  •  梦如初夏
    2021-02-02 00:06

    You could do the following:

    1. Use maven dependency plugin's unpack goal and place the contents of the dependency into a folder
    2. Use build-helper-maven-plugin's add-source goal to add this folder as a source folder

    Here is some code snippet...

    
      org.apache.maven.plugins
      maven-dependency-plugin
      2.2
      
        
          unpack
          process-sources
          
            unpack
          
          
            
              
                my.group
                my.artifact
                my.artifact.version
                sources
                false
                ${project.build.directory}/my.artifact
              
            
          
        
      
    
    
      org.codehaus.mojo
      build-helper-maven-plugin
      1.5
      
        
          add-source
          generate-sources
          
            add-source
          
          
            
              ${project.build.directory}/my.artifact.source
            
          
        
      
    
    

提交回复
热议问题