how to specify maven compiler plugin order

前端 未结 4 844
故里飘歌
故里飘歌 2021-02-10 17:29

I\'m working on a mixed java and kotlin project by using maven.

The problem I\'m facing right now is, maven-compiler-plugin runs before compiling kotl

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-10 17:52

    Although it's more verbose, you can compile both Java and Kotlin sources in the compile phase with the following configuration:

    
        kotlin-maven-plugin
        org.jetbrains.kotlin
        ${kotlin.version}
        
            
                kotlin-compile
                compile
                
                    compile
                
            
            
                kotlin-test-compile
                test-compile
                
                    test-compile
                
            
        
    
    
        org.apache.maven.plugins
        maven-compiler-plugin
        3.5
        
            
                default-compile
                none
            
            
                default-testCompile
                none
            
            
                java-compile
                compile
                
                    compile
                
            
            
                java-test-compile
                test-compile
                
                    testCompile
                
            
        
    
    

    Normally, plugins are executed in the order they are declared in the POM, but the executions of default-compile and default-testCompile are special because they're built-in, so they always go first. The above configuration gets around that by disabling the default compile executions, and declaring maven-compiler-plugin with new compilation executions after the kotlin-maven-plugin. In this way, you can get all compilation to properly occur during the compile phase of the build lifecycle.

提交回复
热议问题