如何让Gradle将Lombok添加到其项目和外部依赖库? [英] How to make Gradle add Lombok to its Project and external dependencies libraries?
问题描述
wrapper
和 init
命令来生成生成,设置和包装文件。该项目有一个空的源文件夹,因为我正试图解决一个更复杂的项目类似的问题,并采取分而治之的方法 - 只需添加Lombok依赖项。
这是我的 build.gradle
按照lombok网站的指示:
apply plugin:'java'
dependencies {
compileOnlyorg.projectlombok:lombok:1.16 .12
和 gradle-wrapper.properties
如果需要:
distributionBase = GRADLE_USER_HOME
distributionPath =包装/ dists
zipStoreBase = GRADLE_USER_HOME
zipStorePath = wrapper / dists
distributionUrl = https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip / *< ---试过其他版本太* /
然后我运行jar文件将其安装在我的eclipse上。如果我通过Java Build Path手动添加jar,它可以工作,但我希望Gradle为我处理这个问题。当我刷新项目时什么也没有发生 - 项目和外部依赖项下没有lombok jar,依赖lombok的代码会出错。
还有另一个项目它确实有它,我不知道我做了什么不同,但我知道这是可能的。
我设法解决这是经过试验和错误。 build.gradle
文件必须添加 jcenter
存储库:
存储库{
jcenter()
}
为什么会出现这种情况,为什么在我不知道的地方没有提到这一点。但现在这是有效的。
I created a Java project in Eclipse Neon. I used Buildship 1.0.21 to import the project as a Gradle project and ran the wrapper
and init
commands to generate the build, settings and wrapper files.
The project has an empty source folder because I am trying to solve a similar problem on a more complicated project and taking the divide and conquer approach - just add Lombok dependency.
Here is my build.gradle
as instructed on the lombok website:
apply plugin: 'java'
dependencies {
compileOnly "org.projectlombok:lombok:1.16.12"
}
and gradle-wrapper.properties
if needed:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip /* <--- tried other versions too */
and I ran the jar file to install it on my eclipse. If I add the jar manually via "Java Build Path" it works but I want Gradle to handle this for me. When I refresh the project nothing happens - there is no lombok jar under "Projects and External Dependencies" and code relying on lombok will give errors.
There is another project I have which does have it there and I don't know what I did differently but I know it's possible.
I managed to solve this after trial and error. The build.gradle
file must add the jcenter
repository:
repositories {
jcenter()
}
Why this is the case and why this is not mentioned anywhere I don't know. But for now this is what works.
这篇关于如何让Gradle将Lombok添加到其项目和外部依赖库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!