为什么Maven生成源不会被编译? [英] Why are Maven generated-sources not getting compiled?

查看:164
本文介绍了为什么Maven生成源不会被编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个插件,可以在 target / generated-sources / wrappers 目录下生成源代码。它连接到generate-sources阶段,如下所示:

I have a plugin which generates sources under the target/generated-sources/wrappers directory. It's wired into the generate-sources phase like this:

<plugin>
    <groupId>mygroupid</groupId>
    <artifactId>myartifactid</artifactId>
    <executions>
        <execution>
        <phase>generate-sources</phase>
        <goals>
            <goal>xml2java</goal>
        </goals>
        </execution>
    </executions>
</plugin>

问题是,当我使用 mvn deploy .class 文件不会放在jar中。我看到所有 .java 文件,但没有 .class

The problem is, when I use mvn deploy the .class files won't be placed in the jar. I see all the .java files there, but no .class.

我阅读了有关此问题的所有问题,但无法弄清楚如何解决问题。我正在使用Maven 3.0.x.

I read all the issues around this problem, but couldn't figure out how to solve the problem. I'm using Maven 3.0.x.

推荐答案

build-helper插件确实解决了这个问题。感谢@Joe的评论。

The build-helper plugin indeed solved the problem. Thanks @Joe for the comment.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>${project.build.directory}/generated-sources/wrappers</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

这篇关于为什么Maven生成源不会被编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆