在将我重定向到与此相关的众多其他帖子之一(例如 this 或 this )之前,请知道我已经尝试过。
我想做的很简单:我有一个名为 generated-sources 的文件夹,与 src 处于同一级别,我希望 maven 自动将其添加到源目录中。
这是片段,因为它也可以在我上面链接的问题中看到:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>generated-sources/enums/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
当我运行它时,它实际上显示了这些行
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @ gui ---
[INFO] Source directory: C:\development\gdg\gui\generated-sources\enums added.
事实是,即使我这样做,源目录也不会出现在项目资源管理器中,我也无法将它们用作依赖项。
注意:我目前正在使用 m2e 连接器插件,并且已经尝试使用 <pluginManagement>
标签。我也已经重新加载了项目,但没有效果。
我可能又变得非常愚蠢了,所以感谢您的帮助。 〜克劳利
最佳答案
除了重新加载项目之外,还可以尝试 Maven > Update Project ...
。
如果这没有帮助,您可以随时手动将源添加到项目中:在项目的“属性”下,在“Java 构建路径”的“源”选项卡中,使用“添加文件夹”按钮选择您的文件夹。
关于java - 将源文件夹添加到我的 Eclipse 项目中的generate-sources,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38431161/