From efa3afb39750eefb1a3054ec95529ad6defd3009 Mon Sep 17 00:00:00 2001 From: jbock Date: Fri, 26 Apr 2024 15:29:42 +0200 Subject: [PATCH] make generated constructor private --- compiler/build.gradle | 2 ++ compiler/src/main/java/net/jbock/writing/ParserClass.java | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/build.gradle b/compiler/build.gradle index f33442a3..5ef07ef3 100644 --- a/compiler/build.gradle +++ b/compiler/build.gradle @@ -51,6 +51,7 @@ dependencies { shadow(jbock) compileOnly(simple_component) annotationProcessor('io.github.jbock-java:simple-component-compiler:1.024') + testRuntimeOnly('org.junit.platform:junit-platform-launcher') testImplementation('io.github.jbock-java:compile-testing:0.19.12') testImplementation('org.junit.jupiter:junit-jupiter:5.10.2') testImplementation('org.mockito:mockito-core:5.11.0') @@ -68,6 +69,7 @@ jar { test { useJUnitPlatform() + jvmArgs('-Xshare:off') testLogging { events('failed') } diff --git a/compiler/src/main/java/net/jbock/writing/ParserClass.java b/compiler/src/main/java/net/jbock/writing/ParserClass.java index 450cdfce..89a271a3 100644 --- a/compiler/src/main/java/net/jbock/writing/ParserClass.java +++ b/compiler/src/main/java/net/jbock/writing/ParserClass.java @@ -1,6 +1,5 @@ package net.jbock.writing; -import io.jbock.javapoet.AnnotationSpec; import io.jbock.javapoet.MethodSpec; import io.jbock.javapoet.TypeSpec; import io.jbock.simple.Inject; @@ -62,9 +61,7 @@ TypeSpec define() { spec.addMethod(createModelMethod.get()); Modifier[] modifiers = sourceElement().accessModifiers().toArray(new Modifier[0]); - spec.addMethod(MethodSpec.constructorBuilder().addModifiers(modifiers) - .addJavadoc("Constructor is deprecated, use the static methods instead.") - .addAnnotation(AnnotationSpec.builder(Deprecated.class).addMember("forRemoval", "true").build()) + spec.addMethod(MethodSpec.constructorBuilder().addModifiers(Modifier.PRIVATE) .build()); return spec.addOriginatingElement(sourceElement().element())