我在 Gradle 中有一个多项目。build.gradle
脚本如下所示:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.github.jengelman.gradle.plugins:shadow:2.0.4"
classpath "io.franzbecker:gradle-lombok:1.14"
}
}
allprojects {
//apply plugin: "base"
}
subprojects {
apply plugin: "com.github.johnrengelman.plugin-shadow"
apply plugin: "idea"
apply plugin: "java"
apply plugin: "io.franzbecker.gradle-lombok"
group = "io.shido"
version = "0.1.0-SNAPSHOT"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
jcenter()
mavenCentral()
}
dependencies {
// [start] Research
//compileOnly "org.projectlombok:lombok:1.18.2"
// [end] Research
testCompile "nl.jqno.equalsverifier:equalsverifier:2.4.5"
testCompile "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
//=================================================================================================
// P L U G I N S
//=================================================================================================
lombok {
version = "1.18.2"
}
//=================================================================================================
// T A S K S
//=================================================================================================
// shadowJar { ... }
test {
useJUnitPlatform()
}
}
然后我有一个messages
项目build.script
:
plugins {
id "java-library"
}
repositories {
jcenter()
mavenCentral()
}
...和一个core
项目build.script
:
plugins {
id "io.spring.dependency-management" version "1.0.6.RELEASE"
}
dependencies {
compile project(":messages")
}
所有这些都应该没问题。
如果我写一个简单的类messages
:
package io.shido.event;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@Builder
@ToString
@EqualsAndHashCode(of = "name")
class Prototype {
private String id;
private String name;
}
...然后进行相同的单元测试:
package io.shido.event;
import org.junit.jupiter.api.Test;
final class PrototypeTest {
@Test
void instantiate() {
final Prototype event = Prototype.???
}
}
我希望我可以在那里为该类使用构建器,但没有生成任何内容。
我在设置中遗漏了什么吗?一切都可以编译,但我看不到为 Lombok 生成的任何内容。不知道还有什么可以尝试的。