Skip to content

Commit

Permalink
Lots of refactoring.
Browse files Browse the repository at this point in the history
Replaced JStachio templates with JavaPoet - better suited for Java code.
Got a few Micronaut test cases working.
  • Loading branch information
edward3h committed Aug 21, 2024
1 parent c4eb430 commit 2da7858
Show file tree
Hide file tree
Showing 81 changed files with 2,150 additions and 990 deletions.
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ java {

dependencies {
implementation(libs.embeddedpostgres)
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.0.BETA1")
runtimeOnly(libs.liquibase.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void apply(Project project) {

var processorConfigTask = project.getTasks().register("processorConfig", ProcessorConfigTask.class, task -> {
task.getConfigFile().set(project.getLayout().getBuildDirectory().file("config.json"));
task.getApplicationConfigFile().convention(project.getLayout().getBuildDirectory().file("resources/test/application-test.yml"));
task.getDependencyInjectionStyle().convention("JAKARTA");
task.getLiquibaseChangelog().convention(project.getLayout().getProjectDirectory().file("src/main/resources/changelog.xml"));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.services.ServiceReference;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.*;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

@UntrackedTask(because = "A new Postgres instance is started for each Gradle run, and the database port and name are chosen at random.")
public abstract class ProcessorConfigTask extends DefaultTask {
@ServiceReference("embeddedPostgres")
abstract Property<EmbeddedPostgresService> getService();

@OutputFile
abstract RegularFileProperty getConfigFile();

@OutputFile
abstract RegularFileProperty getApplicationConfigFile();

@InputFile
abstract RegularFileProperty getLiquibaseChangelog();

Expand All @@ -32,6 +33,7 @@ public void run() {
var connectionInfo = getService().get().getPreparedDatabase(liquibaseFile);
// the ":shared" json support is not available in buildSrc
var config =
//language=JSON
"""
{
"dataSources": {
Expand All @@ -56,5 +58,21 @@ public void run() {
} catch (IOException e) {
throw new RuntimeException(e);
}
var applicationConfig =
//language=yaml
"""
datasources:
default:
url: "jdbc:postgresql://localhost:%d/%s?user=%s"
""".formatted(connectionInfo.getPort(), connectionInfo.getDbName(), connectionInfo.getUser());
if (getApplicationConfigFile().isPresent()) {
outputPath = getApplicationConfigFile().get().getAsFile().toPath();
try {
Files.writeString(outputPath, applicationConfig, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

}
}
11 changes: 11 additions & 0 deletions buildSrc/src/main/kotlin/java-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
`java-library`
id("com.diffplug.spotless")
}

repositories {
Expand All @@ -25,3 +26,13 @@ dependencies {
testImplementation("com.google.truth.extensions:truth-java8-extension:1.1.5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

spotless {
java {
cleanthat()
importOrder()
removeUnusedImports()
palantirJavaFormat()
formatAnnotations()
}
}
9 changes: 5 additions & 4 deletions catalog.settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ dependencyResolutionManagement {
versionCatalogs {
create("libs") {
version("avaje-json", "1.7")
version("jstachio", "1.3.2")
version("junit", "5.10.0")
version("recordbuilder", "37")
version("mapstruct", "1.5.5.Final")
version("ethelred-util", "2.2")

library("avaje-json", "io.avaje", "avaje-jsonb").versionRef("avaje-json")
library("avaje-json-processor", "io.avaje", "avaje-jsonb-generator").versionRef("avaje-json")
Expand All @@ -21,9 +21,6 @@ dependencyResolutionManagement {
library("utilitary", "com.karuslabs:utilitary:2.0.1")
library("postgresql", "org.postgresql:postgresql:42.5.1")

library("jstachio-processor", "io.jstach", "jstachio-apt").versionRef("jstachio")
library("jstachio-compile", "io.jstach", "jstachio-annotation").versionRef("jstachio")

library("junit-api", "org.junit.jupiter", "junit-jupiter-api").versionRef("junit")
library("junit-params", "org.junit.jupiter", "junit-jupiter-params").versionRef("junit")

Expand All @@ -38,10 +35,14 @@ dependencyResolutionManagement {

library("jspecify", "org.jspecify:jspecify:0.3.0")

library("javapoet", "com.palantir.javapoet:javapoet:0.2.0")
library("guava", "com.google.guava:guava:32.1.3-jre")
library("compile-testing", "com.google.testing.compile:compile-testing:0.21.0")
library("compile-testing-extension", "io.github.kiskae:compile-testing-extension:1.0.2")

library("ethelred-util", "org.ethelred.util", "common").versionRef("ethelred-util")
library("yaml", "org.yaml:snakeyaml:2.2")

bundle("compile-testing", listOf("guava", "compile-testing", "compile-testing-extension"))
}
}
Expand Down
5 changes: 2 additions & 3 deletions processor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies {
annotationProcessor(libs.metainfservices)
annotationProcessor(libs.avaje.prisms)
annotationProcessor(libs.recordbuilder.processor)
annotationProcessor(libs.jstachio.processor)
implementation(project(":shared"))
implementation(project(":querymeta"))
implementation(libs.utilitary)
Expand All @@ -15,14 +14,14 @@ dependencies {
implementation(libs.metainfservices)
implementation(libs.postgresql)
implementation(libs.recordbuilder.core)
implementation(libs.jstachio.compile)
implementation(libs.mapstruct.processor)
implementation(libs.javapoet)
implementation(libs.ethelred.util)
testAnnotationProcessor(libs.mapstruct.processor)
testImplementation(project(":runtime"))
testImplementation(libs.jakarta.inject)
testImplementation(libs.bundles.compile.testing)
testImplementation(libs.embeddedpostgres)
testImplementation(libs.liquibase.core)
testImplementation(libs.mapstruct.compile)

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
package org.ethelred.kiwiproc.processor;public record ContainerType() {
package org.ethelred.kiwiproc.processor;

public record ContainerType(ValidContainerType type, KiwiType containedType) implements KiwiType {

@Override
public String packageName() {
return type.javaType().getPackageName();
}

@Override
public String className() {
return type.javaType().getSimpleName();
}
}
Loading

0 comments on commit 2da7858

Please sign in to comment.