我在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()
}使用此...and 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;
}然后对...and进行单元测试,以获得相同的结果:
package io.shido.event;
import org.junit.jupiter.api.Test;
final class PrototypeTest {
@Test
void instantiate() {
final Prototype event = Prototype.???
}
}我希望我可以在那里为这个类使用一个生成器,但是没有生成任何内容。
我是不是漏了什么东西?所有东西都会编译,但我看不到为Lombok生成任何东西。不知道还能尝试什么。
发布于 2018-08-21 17:32:44
如果您使用的是IDEA和最近版本的Gradle (我认为是>= 4.7),您可以使用以下设置,它在我的不同项目中运行得很好:
这应该很好,您将能够在主代码和单元测试中使用Lombok特性。
https://stackoverflow.com/questions/51951178
复制相似问题