Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade, lombok, errorprone #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions basic-gradle-java/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
out/
build/
generated/
generated_tests/
.gradle/
.idea/
*.iml
52 changes: 42 additions & 10 deletions basic-gradle-java/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
plugins {
id('idea')
id('java')
id('io.ebean') version '13.11.0'
id("io.freefair.lombok") version 'latest.release'
id("io.ebean") version "latest.release"
id("net.ltgt.errorprone") version "latest.release"
}

repositories {
Expand All @@ -15,32 +17,62 @@ java {
}
}

compileJava {
options.release = 17
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs.addAll(['-Xlint:all,-serial', '-parameters'])
options.release.set(17) // javac --release 7→8..22+
options.deprecation = true
options.debug = true

options.errorprone {
enabled = true
disableWarningsInGeneratedCode = true
excludedPaths = ".*/(generated|test).*/.*"
disable("UnusedVariable")
disable("MissingSummary")
errorproneArgs = ["-XepExcludedPaths:.*/test/.*"]
}
}

dependencies {
errorprone("com.google.errorprone:error_prone_core:latest.release")
implementation "com.google.code.findbugs:jsr305:latest.release" // https://javadoc.io/doc/com.google.code.findbugs/jsr305/latest/index.html

implementation 'org.avaje.composite:logback:1.1'
implementation 'org.postgresql:postgresql:42.5.1'
implementation 'io.ebean:ebean:13.11.0'
implementation "io.ebean:ebean:latest.release"

// apt query bean generation
annotationProcessor 'io.ebean:querybean-generator:13.11.0'
annotationProcessor 'io.ebean:querybean-generator:latest.release'


testImplementation 'org.junit.jupiter:junit-jupiter:latest.release'
testImplementation 'io.ebean:ebean-test:latest.release'

testImplementation("ch.qos.logback:logback-classic:1.2.+")

testImplementation 'io.avaje:junit:1.1'
testImplementation 'io.ebean:ebean-test:13.11.0'
testImplementation 'org.postgresql:postgresql:latest.release'
}
configurations.configureEach { // .implementation ? https://tomgregory.com/how-to-exclude-gradle-dependencies/
exclude group: 'io.ebean', module: 'ebean-joda-time'

exclude group: "commons-logging", module: "commons-logging" // spring?
exclude group: "org.apache.logging.log4j", module: "log4j-api"
exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j"
exclude group: "org.jboss.slf4j", module: "slf4j-jboss-logmanager"

exclude group: "com.mchange", module: "c3p0"
}

test {
useJUnitPlatform()
}

ebean {
debugLevel = 1 //0 - 9
debugLevel = 9 //0 - 9
queryBeans = true
}

lombok { version = "latest.release" }

test {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
Expand Down
2 changes: 1 addition & 1 deletion basic-gradle-java/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
20 changes: 20 additions & 0 deletions basic-gradle-java/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#lombok.anyConstructor.addConstructorProperties=true → javac -parameters ➕ copyableAnnotations ➕ @RequiredArgsConstructor(onConstructor_=@JsonCreator)

#lombok.log.fieldName = LOGGER

lombok.addNullAnnotations = javax
#lombok.addNullAnnotations=CUSTOM:com.example.annotations.NonNull:com.example.annotations.Nullable

lombok.var.flagUsage = error

lombok.addLombokGeneratedAnnotation = true

lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier
lombok.copyableAnnotations += com.fasterxml.jackson.annotation.JsonProperty
lombok.copyableAnnotations += com.fasterxml.jackson.databind.annotation.JsonDeserialize
lombok.copyableAnnotations += com.fasterxml.jackson.annotation.JsonFormat

config.stopBubbling = true

lombok.extern.findbugs.addSuppressFBWarnings = false
lombok.addSuppressWarnings = true
46 changes: 12 additions & 34 deletions basic-gradle-java/src/main/java/org/example/domain/BaseDomain.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
import io.ebean.Model;
import io.ebean.annotation.WhenCreated;
import io.ebean.annotation.WhenModified;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.Version;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import java.time.Instant;

@MappedSuperclass
@Getter @Setter
@ToString(doNotUseGetters = true, callSuper = false) // avoid getters!
//@Accessors(fluent = true, chain = true) // instead of @Builder(toBuilder = true)
@NoArgsConstructor @AllArgsConstructor
public abstract class BaseDomain extends Model {

@Id
Expand All @@ -24,35 +33,4 @@ public abstract class BaseDomain extends Model {
@WhenModified
Instant whenModified;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public long getVersion() {
return version;
}

public void setVersion(long version) {
this.version = version;
}

public Instant getWhenCreated() {
return whenCreated;
}

public void setWhenCreated(Instant whenCreated) {
this.whenCreated = whenCreated;
}

public Instant getWhenModified() {
return whenModified;
}

public void setWhenModified(Instant whenModified) {
this.whenModified = whenModified;
}
}
41 changes: 13 additions & 28 deletions basic-gradle-java/src/main/java/org/example/domain/Customer.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package org.example.domain;

import org.example.domain.finder.CustomerFinder;
import io.ebean.annotation.NotNull;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.example.domain.finder.CustomerFinder;

import javax.persistence.Entity;
import javax.persistence.Lob;
import java.time.LocalDate;

@Entity
// DON'T! @Data, @EqualsAndHashCode See https://ebean.io/docs/best-practice/
@Getter @Setter
@ToString(doNotUseGetters = true, callSuper = true) // avoid getters!
@NoArgsConstructor @AllArgsConstructor
//@Accessors(fluent = true, chain = true) // instead of @Builder(toBuilder = true)
public class Customer extends BaseDomain {

public static final CustomerFinder find = new CustomerFinder();
Expand All @@ -23,29 +33,4 @@ public class Customer extends BaseDomain {
public Customer(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public LocalDate getStartDate() {
return startDate;
}

public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}

public String getComments() {
return comments;
}

public void setComments(String comments) {
this.comments = comments;
}

}