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

发布于 2024-10-20 06:59:35 字数 1999 浏览 0 评论 0原文

我想通过使用 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

}

I want to ignore some build errors at a specific directory by using maven's profile. I tried to do like below but it did not work. Any help will be appreciated?

============================================
[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

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柒夜笙歌凉 2024-10-27 06:59:35

你的个人资料看起来不错。不过,maven 编译器似乎存在一个已知问题。请参阅此答案一个类似的问题来描述问题和解决方法。

Your profile looks alright. There seems to be a known issue with the maven compiler though. See this answer to a similar question for a description of the problem and a workaround.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文