Maven was recently used in the development of projects, and there was a connection between multiple MAVEN projects, so they were created separately and then managed with Maven aggregation.
Project uses Git to manage code, Because the. setting files are not uploaded in the. gitignore file when uploading the code, the MAVEN project that was downloaded in git is not a elipse project file, so if the code is pulled down in GitHub, it is not very convenient to import, so use Maven's plugin to into eclipse projects.
The structure of the project is as follows:
Where encryption is one of several MAVEN projects that rely on POM files in utils4java-parent
Utils4java-parent:
Encryption Project (also the new MAVEN project structure):
In this case, other than the Pom file is not ticked, because the git upload to GitHub in the. gitignore file is ignored, and SRC is not uploaded because the folder I did not add source, is empty. Here you can see the Eclipse project file flags for. Setting not been uploaded.
The import in Eclipse is this:
I. How to manage multiple projects with Maven
Utils4java-parent pom files are as follows, all of the MAVEN project's POM files depend on this parent file:
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <groupId>com.kxw</groupId> <artifactId> Utils4java-parent</artifactid> <packaging>pom</packaging> <version>0.0.1-snapshot</ Version> <name>utils4java-parent</name><url>http://maven.apache.org</url><modules > <module> ... /encryption</module> </modules> <repositories> <repository> <id>central</ id> <name>central repository</name> <url>https://nexus.sourcesense.com/nexus/content/reposi tories/public/</url> <layout>default</layout> <snapshots> <enabled>false< ;/enabled> </snapshots> </repository> </repositories> <properties> <project.build.sourceencoding>utf-8</project.build.sourceencoding > <junit.version>4.10</junit.version> </properties> <dependencyManagement> <dep endencies> <dependency> <groupId>junit</groupId> <artifactid>junit</artif actid> <version>${junit.version}</version> <scope>test</scope> </dependen cy> </dependencies> </dependencyManagement> <build> <plugins> <plu Gin> <groupId>org.apache.maven.plugins</groupId> <artifactid>maven-comp Iler-plugin</artifactid> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> & Lt;showwarnings>true</shOwwarnings> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.1.2</version> <executions> <execution> <goals> <goal>jar</goal> <goal>test-jar</goal> < ;/goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactid>ma Ven-eclipse-plugin</artifactid> <version>2.8</version> <CONFIGURATION&G T <wtpversion>2.0</wtpversion> </configuration> </plugin> <plu Gin> <groupId>org.apache.maven.plugins</groupId> <artifactid>maven-war- Plugin</artifactid> <version>2.3</version> <configuration> <archive> <manifestEntries> <vendor>${projec T.organization.name}</vendor> <artifact-id>${project.artifactid}</artifact-id> ; <Implementation-Version>${project.version}</Implementation-Version> <build>${ Project.build}</build> </manifestEntries> </archive> </configuration> </plugin> </plugins> </build> </proJect>
The pom files in the encryption project are as follows:
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" ><modelversion >4.0.0</modelVersion><parent><groupId>com.kxw</groupId><artifactId> Utils4java-parent</artifactid><version>0.0.1-snapshot</version><relativepath>, .... /utils4java-parent/pom.xml</relativepath></parent><artifactid>encryption</artifactid> <packaging>jar</packaging><name>encryption</name><url>http://maven.apache.org </url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties><dependencies><dependency><groupid>junit</groupid><artifactid >junit</artifactid><scope>test</scope></dependency></dependencies></ Project>
This makes it possible to create multiple MAVEN files on this basis and rely on the parent pom file.
Two. Managing project code with GIT
. 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
Want to know how to upload code with GIT can be seen here: http://blog.csdn.net/kingson_wu/article/details/38436923
Three. Use the Maven plugin to turn the project into an Eclipse project
These plugins are already configured in the parent Pom file and can only be run Maveneclipsebuild.bat
CD Utils4java-parentcall mvn eclipse:clean eclipse:eclipse Pause
Demo Source in: Https://github.com/KingsonWu/Kingson4Blog/tree/master/MutipleEclipseMavenProjectDemo
How to develop a MAVEN project with multiple aggregation relationships in Eclipse and manage it with git