在同一模块中使用时,IntelliJ 找不到生成的源

IntelliJ can't find generated sources when used in same module

我正在使用 Google's AutoFactory 的注释处理器。我用 @AutoFactory 注释了 SomeClass 并在同一个模块的其他地方引用了 new SomeClassFactory().create()

Maven 配置:

我在 Maven 中添加了必要的依赖:

    <dependency>
        <groupId>com.google.auto.factory</groupId>
        <artifactId>auto-factory</artifactId>
        <version>1.0-beta2</version>
        <optional>true</optional>
    </dependency>

当 运行 $ mvn clean compile 我看到创建了 target/generated-sources/annotions/somepackage/SomeClassFactory 并且模块编译没有错误。

IntelliJ 配置:

如果我的理解是正确的,这在我的 IDEA (v14.1.4) 版本中应该足够了。

我还执行了以下步骤:

问题:

执行所有这些步骤后,生成的 class 不会显示在项目资源管理器中。事实上,整个 target 目录都不见了。编译失败 cannot find symbol: SomeClassFactory 并且new SomeClassFactory().create()在编辑器中被标记为红色,而Maven生成编译没有任何问题。

我自己没有选择,非常欢迎任何帮助或建议!

更新: 当我注释导致编译错误的代码时,IntelliJ 在编译消息中打印此警告:Warning:Output path /Users/.../target/generated-sources/annotations intersects with a source root. Only files that were created by build will be cleaned.

我得到了 Jetbrains 支持的帮助,结果发现问题出在对排除文件的偏好设置上。这些配置有两个地方:

Please check that folders/files are not excluded in Preferences > Build, Execution, Deployment > Compiler > Excludes and the file/folder pattern in not listed in Preferences > Editor > File Types -> Ignored files and folders

在我的例子中,target 包含在 Editor > File Types.

中忽略的文件和文件夹列表中

然后还有一个编译问题,我通过扔掉IDEA工程文件重新创建工程解决了。