如何覆盖maven-compiler-plugin的配置。 (构建目录,我想通过使用配置文件进行更改)

时间:2011-03-06 14:27:01

标签: java maven-2 maven maven-plugin

我想通过使用maven的配置文件忽略特定目录中的一些构建错误。我试着像下面这样做,但它没有用。任何帮助将不胜感激?

============================================
[executed command]

mvn -P test clean compile

============================================
[part of pom.xml]

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <showWarnings>true</showWarnings>
            </configuration>
        </plugin>
    </plugins>
</build>
<profiles>
    <profile>
        <id>test</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                    <executions>
                        <execution>
                            <id>default-compile</id>
                            <configuration>
                                <excludes>
                                    <exclude>**/nocompile/*</exclude>
                                </excludes>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

============================================
[a class happened a build error]

package com.sample.web.nocompile;

public class NoCompileSample {

    // An error do happen here 
    private String

}

1 个答案:

答案 0 :(得分:4)

您的个人资料看起来不错。但是,maven编译器似乎存在已知问题。有关问题的说明和解决方法,请参阅this answer类似的问题。