-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
109 lines (92 loc) · 3.07 KB
/
build.gradle
File metadata and controls
109 lines (92 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import com.vanniktech.maven.publish.SonatypeHost
plugins {
id 'java-library'
id 'jacoco'
id "org.openapi.generator" version "7.5.0"
id "com.vanniktech.maven.publish" version "0.31.0"
}
group = 'de.codebarista'
version = '0.0.4'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
mavenCentral()
}
dependencies {
compileOnly 'jakarta.annotation:jakarta.annotation-api:3.0.0'
compileOnly 'org.openapitools:jackson-databind-nullable:0.2.6' // for generated shopware model classes
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
/**
* Configures the 'openApiGenerate' task to generate Java classes from the specified OpenAPI 3 specification file
* for Shopware API integration.
*/
openApiGenerate {
generatorName.set("java")
inputSpec.set("$rootDir/shopware_openapi3.json")
outputDir.set("$rootDir/generated/shopware")
apiPackage.set("de.codebarista.shopware.api")
modelPackage.set("de.codebarista.shopware.model")
configOptions.put("dateLibrary", "java8")
configOptions.put("library", "webclient") // use Spring webclient
configOptions.put("useJakartaEe", "true") // Use Jakarta EE dependencies instead of javax
}
/**
* Generates Shopware model classes and places them in the src/main/java/shopware source directory.
* This task depends on the 'openApiGenerate' task.
*/
tasks.register('generateShopwareModelClasses', Copy) {
def mainJavaSrcDir = sourceSets.main.java.srcDirs.iterator().next()
def sourceDir = "$rootDir/generated/shopware/src/main/java/de/codebarista/shopware"
from(sourceDir)
into("${mainJavaSrcDir}/de/codebarista/shopware")
dependsOn tasks.openApiGenerate
doLast {
delete "$rootDir/generated"
}
}
test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
}
mavenPublishing {
pom {
name.set("Shopware Model")
description.set("Auto-generated Java model classes for the Shopware Store API")
url.set("https://github.com/codebarista-de/shopware-model")
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("codebarista.de")
name.set("Codebarista")
}
}
scm {
connection.set("scm:git:git://github.com/codebarista-de/shopware-model.git")
developerConnection.set("scm:git:ssh://github.com/codebarista-de/shopware-model.git")
url.set("https://github.com/codebarista-de/shopware-model")
}
}
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
// Sign when in-memory signing key is provided (CI) or local signing.keyId exists
if (project.hasProperty("signingInMemoryKeyId") || project.hasProperty("signing.keyId")) {
signAllPublications()
}
}
tasks.register('printVersion') {
doLast {
println project.version
}
}