How to develop multiple maven projects with aggregation relationships in eclipse and manage them with git

Source: Internet
Author: User
Tags how to use git using git

How to develop multiple maven projects with aggregation relationships in eclipse and manage them with git

Maven has recently been used in development projects. Multiple maven projects are related to each other, so they are created separately and managed using maven aggregation.

The project uses git to manage code because it is set during code uploading. the gitignore file is not uploaded. setting and other files, so the maven project downloaded in git is not an elipse project file, so it is not convenient to import the code after pulling the code in github, so here we use the maven plug-in to convert each project into an Eclipse project.

 

The project structure is as follows:

Here, encryption is one of multiple maven projects that depend on the pom file in the Utils4Java-parent

Utils4Java-parent:

Encryption project (the same is true for other maven project structures created ):

Except for the pom file, other projects are not checked because they are uploaded to github using git. the gitignore file is ignored, while the src file is not uploaded because I did not add source code to the folder and it is empty. The. setting file marked by the eclipse project file is not uploaded.

 

The import in eclipse is as follows:

 

 

I. How to Use maven to manage multiple projects

The pom file for the Utils4Java-parent is as follows, and all pom files for maven projects depend on this parent file:

 

   
  
   4.0.0
    
  
   com.kxw
    Utils4Java-parent    
  
   pom
    
  
   0.0.1-SNAPSHOT
    
  
   Utils4Java-parent
  
  
   http://maven.apache.org
  
      
   
    ../encryption
     
          
      
         
    
     central
          
    
     Central Repository
          
    
     https://nexus.sourcesense.com/nexus/content/repositories/public/
          
    
     default
          
            
     
      false
           
        
     
    
      
   
    UTF-8
       
   
    4.10
        
      
      
         
            
     
      junit
             junit        
     
      ${junit.version}
             
     
      test
           
        
     
       
          
               
                    
     
      org.apache.maven.plugins
                     maven-compiler-plugin                
     
      2.3.2
                     
                         
      1.7                    
      
       1.7
                          
      
       true
                          
      
       UTF-8
                      
     
     
                 
    
    
    
                
                    
     
      org.apache.maven.plugins
                     maven-source-plugin                
     
      2.1.2
                     
                         
       
        
        
         jar
         
        
         test-jar
         
        
                      
                 
                
                    
     
      org.apache.maven.plugins
                     maven-eclipse-plugin                
     
      2.8
                     
                         
      
       2.0
                      
                 
                
                    
     
      org.apache.maven.plugins
                     maven-war-plugin                
     
      2.3
                     
                                                 
       
       
        ${project.organization.name}
        ${project.artifactId} 
       
        ${project.version}
        
       
        ${project.build}
        
                                          
                 
                      
   
   
   
   
       
  
  
  
  
  
    
 

The pom file in the encryption project is as follows:

 

 

 

 
  
   4.0.0
  
  
   
    com.kxw
   Utils4Java-parent
   
    0.0.1-SNAPSHOT
   
   
    ../Utils4Java-parent/pom.xml
   
  encryption
  
   jar
  
  
   encryption
  
  
   http://maven.apache.org
  
  
   
    UTF-8
   
  
  
   
    
     junit
    junit
    
     test
    
   
  
 


 

In this way, you can create multiple maven files and rely on the parent POM file.

 

2. Use git to manage project code

 

. Gitignore file:

 

.*.swp.DS_Store*target**.jar*.war*.ear*.classclasses/.svn.classes.project.classpath.settings/.metadatabintmp/**tmp/**/**.tmp*.bak*.swp*~.nib.classpath.settings/**tartget/**git.properties


 

To learn how to use git to upload code, see here: http://blog.csdn.net/kingson_wu/article/details/38436923

 

3. Use maven plug-in to change the project to an eclipse project

These plug-ins have been configured in the parent POM file, and only run MavenEclipseBuild. bat.

 

cd Utils4Java-parentcall mvn eclipse:clean eclipse:eclipse pause
 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.