Practice 1 of maven development process management (development environment and code isolation generate-sources)

Source: Internet
Author: User

The basic concepts of maven are mentioned in the preparation of maven development process management in the previous blog. I understand the concept, but those things seem far away from me. Let's talk about development first,

As a result, IT male Luo shuquan obtained the source code on svn and began to import IT to the local development environment. Click import to display the familiar import interface.

 

Import failed. Why? I asked my colleagues to know that the company uses the idea development environment, while the company uses eclipse. What should we do? Giving up your favorite eclipse is really painful, and unfamiliar with it will lead to low development efficiency. Is there a perfect solution? Yes.

 

 

Think about how hibernate is compatible with different databases in the data access layer? Create a language in the middle, such as hql. When you know the specific type of the connected database in the configuration, call its adaptation function to convert the corresponding database SQL. The principles of Maven are similar. The pom description file is provided to describe the components of the project, such as src, target, and lib, if you know which development environment you want to adapt to in the command, you can convert it. This provides some flexibility for specific development. Maven provides the plug-in for converting to the mainstream environment eclipse maven-eclipse-plugin, the corresponding conversion command is eclipse: eclipse. IDEA also provides the maven-IDEA-plugin plug-in for idea conversion, and the command for converting to the corresponding development environment is idea: idea.

 

IT male loose enters the root directory of the project in the command line, runs maven eclipse: eclipse, and then imports IT. IT male Luo shu is very excited. At the same time, he is very excited. How does maven convert IT?

 

 

In fact, any development environment must identify the project features before development can proceed smoothly. For example, in the eclipse project, you can see several basic elements, such as the source code Directory, which has a package on the src/main/java folder, the source code directory is the place where the user writes the source code. The target directory is the place where the target file is generated, such as the class file. Referenced Libraries is the place where the jar packages dependent on the project are placed.

 

 

 

These project descriptions are described in. classpath and. project. For example, the. classpath file:

 

 

Obviously, the following conclusions can be drawn:

  1. Kind = "src", path = src/main/java, which describes the location of src;
  2. Kind = "output", path = target/classes, indicating the location of the target directory;
  3. Kind = "var", indicating the location of a lib.

The. project File describes the plug-ins required for this project and the builder used.

So how does maven work? In fact, he also analyzed the commonalities of all development environments and abstracted their concepts. In the following code:

Org. apache. maven. plugin. ide. AbstractIdeSupportMojo. java

   1:        boolean processProject = setup();

   2:        if ( !processProject )

   3:        {

   4:            return;

   5:        }

6: // parse all dependencies to form lib reference

   7:        IdeDependency[] deps = doDependencyResolution();

8: // bind the source code and javadoc.

   9:        resolveSourceAndJavadocArtifacts( deps );

10: // generate a configuration file for a specific development environment

  11:        writeConfiguration( deps );

  12:        reportMissingArtifacts();

 

This is an implementation of the template mode. In a specific development environment, you only need to inherit AbstractIdeSupportMojo to override the writeConfiguration (deps) to generate a specific configuration file.

Therefore, maven provides powerful plug-in support for the isolation of the development environment and source code, taking into account the interests of different programmers, thus improving the overall development efficiency.

 

Recommended books:

1. maven books: Maven practice -- Xu xiaobin

2.21 JOLT awards-development process methodology: continuous delivery: system methods for releasing reliable software

References:

Introduction to Apache Maven2

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.