maven eclipse常用插件配置

添加source folder

用于非标准maven 目录结构场景下,比如要将"/src/java/dev"这种目录设置为源文件目录.插件配置如下:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.4</version>
    <executions>
       <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>${basedir}/src/java/dev</source>
                </sources>
            </configuration>
      </execution>
   </executions>
</plugin>

设置eclise项目默认编码

常用于win环境下,windows中文环境下默认编码格式为GBK,导致eclipse项目空间也默认采用GBK编码。如果需要修改此默认编码,可以通过下述配置修改。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.5.1</version>
    <configuration>
        <additionalConfig>
            <file>
                <name>.settings/org.eclipse.core.resources.prefs</name>
                <content>
                <![CDATA[eclipse.preferences.version=1${line.separator}encoding/<project>=UTF-8${line.separator}]]>
                </content>
            </file>
        </additionalConfig>
    </configuration>
</plugin>