Maven compile a source jar dependency

前端 未结 2 1070
粉色の甜心
粉色の甜心 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:15

    Downloading the source packages using Maven is easy:

    
        log4j
        log4j
        1.2.16
        sources
    
    

    How to configure Maven to expand this dependency and then compile it's contents is beyond me....

    Have you considered an ANT solution? The ivy plug-in provides it with Maven-like abilities and the groovy plug-in can be used to script your special build logic:

    build.xml

    Ivy uses "configurations" (similar to Maven scopes) to group dependencies.

    In this example the "sources" configuration holds the downloaded source packages. These are placed into a referenced fileset, which can be processed sequentially by the groovy task.

    Each downloaded source jar is unzipped into the "build/src" directory:

    
    
        
        
    
        
            
            
            
        
    
        
            
    
            
            project.references.sourcezips.each {
                ant.unzip(src: it, dest: properties["src.dir"])
            }
            
        
    
        
            
        
    
    
    

    ivy.xml

    Each source package dependency uses the "sources" configuration. This maps directly to the "sources" scope of the Maven module.

    
        
        
            
            
        
        
            
            
    
            
            
            
        
    
    

提交回复
热议问题