Build-helper-maven-plugin of Maven Plug-ins

Source: Internet
Author: User
Tags execution resource custom name

When you add an existing project to MAVEN management, there is always a lot of inexplicable problems, one of which is that MAVEN's default project structure is inconsistent with its own project structure, resulting in the inability to compile the source code, let alone deploy and run the project.

Java program Development, the general use of Eclipse, myeclipse and other tools, its source directory is SRC, which is different from the MAVEN default Src/main/java. Therefore, without additional configuration, the use of the MAVEN command cannot complete the compilation of the code.

In this case, Codehaus provides a build-helper-maven-plugin plug-in to support the customized project directory structure (as opposed to the MAVEN default directory structure).

The plugin's official website: http://mojo.codehaus.org/build-helper-maven-plugin/

Up to the present (2013-12-25), the latest version is 1.8

<plugin>  
    <groupId>org.codehaus.mojo</groupId>  
    <artifactId> build-helper-maven-plugin</artifactid>  
    <version>1.8</version>  
</plugin>

The plug-in provides a number of goals, including setting up the main source directory, test source directory, master resource file directory, test resource file directory, and so on.

The following is a brief account of the main resource file directory, the main source directory configuration, the other settings are similar, no longer one by one to tell.

Directly on the code, the description is all in the comment.

<!--set up multiple source folders--> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactid>bui Ld-helper-maven-plugin</artifactid> <version>1.8</version> <executions> < !--Add the Master resource file directory--> <execution> <!--custom name, not repeatable--> <id>add-resource&lt ;/id> <!--Specifies the binding to the lifecycle--> <phase>initialize</phase> <!--Specifies the specified Target, you can add multiple--> <goals> <goal>add-resource</goal> </goals&  
            Gt
                    <configuration> <resources> <!--resource Files directory to add multiple-->  
                        <resource> <directory>${basedir}/src/main/one</directory>  
                        <!--whether to enable variable filtering--> <filtering>true</filtering> <!--Excluded files, can add multiple--> <excludes> <exclude>**/*.java</exc lude> </excludes> </resource> <res Ource> <directory>${basedir}/src/main/two</directory> & Lt;filtering>true</filtering> <excludes> <exclud  
                E>**/*.java</exclude> </excludes> </resource> </resources> </configuration> </execution> <!--Tim Add main source directory--> <execution> <id>add-source</id> <phase>initializ e</phase> <goals> <goal>add-source</goal> </goals > <cOnfiguration> <sources> &LT;SOURCE&GT;${BASEDIR}/SRC/MAIN/THREE&LT;/SOURC  
            E> <source>${basedir}/src/main/four</source> </sources> </configuration> </execution> <!--add Test source directory--> <executio  
            N> <id>add-test-source</id> <phase>initialize</phase> <goals> <goal>add-test-source</goal> </goals> <c Onfiguration> <sources> <source>${basedir}/src/main/five</source  
            > <source>${basedir}/src/main/six</source> </sources> </configuration> </execution> </executions> </plugin>

After you add the above configuration, you can compile the source code by executing the MAVEN command compile.

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.