How to include a maven module outside of the project context?

后端 未结 2 892
谎友^
谎友^ 2021-01-19 03:25

I\'d like to have a module in some kind of global project directory, so that I can include that module in all other projects that use that common code.

But how can I

2条回答
  •  广开言路
    2021-01-19 04:02

    Using relative path to include some submodules is not a good practice...you will have a lot of problems.

    Can not you just put the common project as a dependency of the parent module...

    In this way you will have that "common project" in all the submodule that declare the parent project as a parent...

    Why do you want to compile your "common" project every time you compile the parent pom?

    Edited:

    YOUR SVN:

    svn/MyGlobalProject/project-commons/pom.xml           //should be shared among different projects
    svn/MyProject/web-parent/trunk/pom.xml                //the parent pom used to build the    application
    svn/MyProject/web-parent/trunk/project-domain/pom.xml //submodule 1
    svn/MyProject/web-parent/trunk/project-web/pom.xml    //submodule 2
    

    PARENT POM.XML:

    
        de.project
        project-parent
        pom
    
        
           
          de.project
          project-commons
          ${common.project.version}
           
        
    
    
        project-domain
        project-web
    
    

    Just like this... in that way project-domain and project-web will inherit that dependency, and you will able to use it everywhere you want in submodules...

    Than the use of dependency management could be a good improvements

提交回复
热议问题