• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


27 Feb, 2025

Updated at 16 Mar, 2025

How can an independent Maven module share plugins?

If I have two independent modules, how can I share a plugin between these two independent modules? For example, there is an independent module named shared-plugin-config, and a mybatis-generator-maven-plugin is defined in its pluginManagement. How can another independent module, module-a, use the mybatis-generator-maven-plugin configured in the shared-plugin-config module?

The following is the solution I tried according to the reply from the AI, but it didn't work.

First, define the mybatis-generator-maven-plugin in the pom.xml of the shared-plugin-config:


    4.0.0
    com.example
    shared-plugin-config
    1.0.0
    pom

    
        
            
                
                    org.mybatis.generator
                    mybatis-generator-maven-plugin
                    1.3.6
                
            
        
    

Then, reference the mybatis-generator-maven-plugin in the shared-plugin-config in the pom.xml of module-a:


    4.0.0
    com.example
    module-a
    1.0.0

    
        
            
                com.example
                shared-plugin-config
                1.0.0
                pom
                import
            
        
    

    
        
            
                org.mybatis.generator
                mybatis-generator-maven-plugin
            
        
    

As a result, the version number of the mybatis-generator-maven-plugin in module-a is "unknown". How can we achieve the sharing of plugins between independent modules?

screenshot of plugin list

The whole project structure consists of three submodules:

  • shared-plugin-config
  • module-a
  • mybatis-generator-maven-plugin

First, add the mybatis-generator-maven-plugin to a public module named shared-plugin-config, and then reference the public module shared-plugin-config in another module named module-a. I want the module-a to be able to use the mybatis-generator-maven-plugin as well.