如何让 Eclipse 使用 Gradle 生成 MapStruct 映射器
How to get Eclipse to generate MapStruct Mappers using Gradle
是否有任何特殊配置可以让eclipse生成Mapstruct映射器?目前还没有生成。
它们确实在 gradle 构建中生成,但我无法让它们生成,因此我可以在开发中使用它们。
我把这个添加到我的 build.gradle:
plugins {
id "net.ltgt.apt" version "0.10"
}
dependencies {
compile "org.mapstruct:mapstruct-jdk8:$mapstructVersion"
apt "org.mapstruct:mapstruct-processor:$mapstructVersion"
}
我还为 MapStruct 添加了 eclipse 插件(虽然我相信这实际上不是 必需的???)
然后我转到项目 > 属性 > Java 编译器 > 注释处理:
但是 .apt_generated 是空的,我错过了什么?
我正在使用:
Eclipse:版本:Oxygen Release (4.7.0) Build id:20170620-1800
MapStruct 版本 1.2.0.CR1(也尝试 1.1.0.FINAL)
所以经过一番搜索,我确定解决方案是您必须手动 运行 gradle 中的 eclipse
任务。如果成功,您应该会看到类似以下内容:
解决方案来自阅读 https://github.com/tbroyer/gradle-apt-plugin 文档,其中指出:
When using Buildship, you'll have to manually run the eclipseJdtApt and eclipseFactorypath tasks to generate the Eclipse configuration files, then either run the eclipseJdt task or manually enable annotation processing: in the project properties → Java Compiler → Annotation Processing, check Enable Annotation Processing. Note that while all those tasks are depended on by the eclipse task, that one is incompatible with Buildship, so you have to explicitly run the two or three aforementioned tasks and not run the eclipse task.
它指出 eclipse
任务与 buildship 不兼容,但这似乎已修复(我 运行 eclipse
任务没有问题):
但是我确实遇到了 cleanEclipse
任务的问题,它似乎与 Buildship 不兼容。
毕竟 *MapperImpl.java
类 在 <project_root>/.apt_generated
中生成
是否有任何特殊配置可以让eclipse生成Mapstruct映射器?目前还没有生成。
它们确实在 gradle 构建中生成,但我无法让它们生成,因此我可以在开发中使用它们。
我把这个添加到我的 build.gradle:
plugins {
id "net.ltgt.apt" version "0.10"
}
dependencies {
compile "org.mapstruct:mapstruct-jdk8:$mapstructVersion"
apt "org.mapstruct:mapstruct-processor:$mapstructVersion"
}
我还为 MapStruct 添加了 eclipse 插件(虽然我相信这实际上不是 必需的???)
然后我转到项目 > 属性 > Java 编译器 > 注释处理:
但是 .apt_generated 是空的,我错过了什么?
我正在使用:
Eclipse:版本:Oxygen Release (4.7.0) Build id:20170620-1800
MapStruct 版本 1.2.0.CR1(也尝试 1.1.0.FINAL)
所以经过一番搜索,我确定解决方案是您必须手动 运行 gradle 中的 eclipse
任务。如果成功,您应该会看到类似以下内容:
解决方案来自阅读 https://github.com/tbroyer/gradle-apt-plugin 文档,其中指出:
When using Buildship, you'll have to manually run the eclipseJdtApt and eclipseFactorypath tasks to generate the Eclipse configuration files, then either run the eclipseJdt task or manually enable annotation processing: in the project properties → Java Compiler → Annotation Processing, check Enable Annotation Processing. Note that while all those tasks are depended on by the eclipse task, that one is incompatible with Buildship, so you have to explicitly run the two or three aforementioned tasks and not run the eclipse task.
它指出 eclipse
任务与 buildship 不兼容,但这似乎已修复(我 运行 eclipse
任务没有问题):
但是我确实遇到了 cleanEclipse
任务的问题,它似乎与 Buildship 不兼容。
毕竟 *MapperImpl.java
类 在 <project_root>/.apt_generated