There is a application on spring-boot and gradle and need to generate dto's using json schema. Try to use jsonschema2pojo plugin for do it and took example from here (changed only plugins block used plugins closure instead apply keyword
build.gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.jsonschema2pojo:jsonschema2pojo-gradle-plugin'
}
}
plugins {
id 'java'
id 'jsonschema2pojo'
id 'org.springframework.boot' version '2.7.5'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
group = 'nuclear.bot'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
jsonSchema2Pojo {
generateBuilders = false
usePrimitives = false
source = files("src/main/json-schema")
targetDirectory = file("${project.buildDir}/generated-sources/js2p")
targetPackage = 'crom.tech.api.models'
propertyWordDelimiters = [] as char[]
useLongIntegers = false
useBigIntegers = false
useDoubleNumbers = true
useBigDecimals = false
includeHashcodeAndEquals = true
includeToString = true
annotationStyle = 'jackson2'
customAnnotator = 'org.jsonschema2pojo.NoopAnnotator'
includeJsr303Annotations = false
sourceType = 'jsonschema'
removeOldOutput = true
outputEncoding = 'UTF-8'
useJodaDates = false
useCommonsLang3 = false
initializeCollections = true
classNamePrefix = ""
classNameSuffix = ""
fileExtensions = [] as String[]
includeConstructors = true
serializable = true
includeAccessors = true
includeDynamicAccessors = false
}
But when I try to nuild project, there is error message:
Build file 'C:\learn\Nuclear-bot\Nuclear-bot-parsing-processor\build.gradle' line: 12
Plugin [id: 'jsonschema2pojo'] was not found in any of the following sources:
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.