Skip to content

Commit e80a2f3

Browse files
committed
chore: initialize project gradle structure and configuration files
1 parent a56a07e commit e80a2f3

20 files changed

+730
-874
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
# Configuration file for EditorConfig: http://editorconfig.org
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_style = space
9+
indent_size = 4
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
# space indentation for JSON and YML
14+
[*.{json,json5,yml,yaml}]
15+
indent_size = 2
16+
17+
[*.kt]
18+
ktlint_standard_enum-entry-name-case = disabled

.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.gradle
2+
.idea
3+
4+
build/
5+
!gradle/wrapper/gradle-wrapper.jar
6+
!**/src/main/**/build/
7+
!**/src/test/**/build/
8+
9+
### IntelliJ IDEA ###
10+
.idea/modules.xml
11+
.idea/jarRepositories.xml
12+
.idea/compiler.xml
13+
.idea/libraries/
14+
*.iws
15+
*.iml
16+
*.ipr
17+
out/
18+
!**/src/main/**/out/
19+
!**/src/test/**/out/
20+
21+
### Kotlin ###
22+
.kotlin
23+
24+
### Eclipse ###
25+
.apt_generated
26+
.classpath
27+
.factorypath
28+
.project
29+
.settings
30+
.springBeans
31+
.sts4-cache
32+
bin/
33+
!**/src/main/**/bin/
34+
!**/src/test/**/bin/
35+
36+
### NetBeans ###
37+
/nbproject/private/
38+
/nbbuild/
39+
/dist/
40+
/nbdist/
41+
/.nb-gradle/
42+
43+
### VS Code ###
44+
.vscode/
45+
46+
### Mac OS ###
47+
.DS_Store

build.gradle.kts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper
3+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4+
import java.time.Duration
5+
6+
plugins {
7+
id("java")
8+
id("org.jetbrains.kotlin.jvm") version "2.1.10"
9+
id("org.jlleitschuh.gradle.ktlint") version "12.1.2"
10+
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
11+
}
12+
13+
group = project.property("GROUP_ID") as String
14+
15+
apply("gradle-tasks/specs.gradle.kts")
16+
apply("$rootDir/gradle-tasks/snapshot.gradle")
17+
18+
allprojects {
19+
repositories {
20+
mavenCentral()
21+
maven {
22+
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
23+
}
24+
}
25+
}
26+
27+
subprojects {
28+
apply(plugin = "java")
29+
apply(plugin = "org.jetbrains.kotlin.jvm")
30+
apply(plugin = "org.jlleitschuh.gradle.ktlint")
31+
32+
plugins.withId("org.jetbrains.kotlin.jvm") {
33+
kotlin {
34+
jvmToolchain(8)
35+
}
36+
}
37+
38+
plugins.withType<KotlinBasePluginWrapper>().configureEach {
39+
tasks.withType<KotlinCompile>().configureEach {
40+
compilerOptions {
41+
jvmTarget.set(JvmTarget.JVM_1_8)
42+
}
43+
}
44+
}
45+
46+
java {
47+
withSourcesJar()
48+
withJavadocJar()
49+
50+
sourceCompatibility = JavaVersion.VERSION_1_8
51+
targetCompatibility = JavaVersion.VERSION_1_8
52+
53+
// Gradle 7+ Java toolchain approach (also sets 1.8)
54+
toolchain {
55+
languageVersion.set(JavaLanguageVersion.of(8))
56+
}
57+
}
58+
59+
ktlint {
60+
debug.set(true)
61+
version.set("1.5.0")
62+
verbose.set(true)
63+
64+
additionalEditorconfig.set(
65+
mapOf(
66+
"max_line_length" to "200",
67+
"indent_style" to "space",
68+
"indent_size" to "4",
69+
"insert_final_newline" to "true",
70+
"end_of_line" to "lf",
71+
),
72+
)
73+
}
74+
}
75+
76+
nexusPublishing {
77+
repositories {
78+
sonatype {
79+
username.set(System.getenv("SONATYPE_USERNAME"))
80+
password.set(System.getenv("SONATYPE_PASSWORD"))
81+
}
82+
}
83+
84+
transitionCheckOptions {
85+
maxRetries.set(60)
86+
delayBetween.set(Duration.ofMillis(5000))
87+
}
88+
}

buildSrc/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
api("org.openapitools:openapi-generator:7.11.0")
11+
implementation("com.samskivert:jmustache:1.15")
12+
}

generator/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import com.expediagroup.sdk.xap.generator.mustache.AllowedMediaTypesLambda
2+
import org.openapitools.codegen.CodegenConstants
3+
4+
plugins {
5+
id("com.expediagroup.sdk.openapigenerator") version "0.0.3-beta-SNAPSHOT"
6+
}
7+
8+
group = project.property("GROUP_ID") as String
9+
10+
dependencies {
11+
api("org.openapitools:openapi-generator:7.11.0")
12+
}

generator/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
namespace=xap

gradle-tasks/publish.gradle.kts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
project.extensions.configure<PublishingExtension> {
2+
publications {
3+
create<MavenPublication>("mavenJava") {
4+
from(components["java"])
5+
artifactId = project.property("ARTIFACT_NAME") as String
6+
groupId = project.property("GROUP_ID") as String
7+
version = if (project.findProperty("SNAPSHOT_VERSION") != null) {
8+
project.findProperty("SNAPSHOT_VERSION") as String
9+
} else {
10+
project.property("VERSION") as String
11+
}
12+
description = project.findProperty("DESCRIPTION") as String?
13+
14+
pom {
15+
name.set(project.property("ARTIFACT_NAME") as String)
16+
description.set(project.findProperty("DESCRIPTION") as String?)
17+
url.set(project.property("POM_URL") as String)
18+
19+
licenses {
20+
license {
21+
name.set(project.property("LICENSE_NAME") as String)
22+
url.set(project.property("LICENSE_URL") as String)
23+
distribution.set(project.property("LICENSE_DISTRIBUTION") as String)
24+
comments.set(project.property("LICENSE_COMMENTS") as String)
25+
}
26+
}
27+
28+
developers {
29+
developer {
30+
name.set(project.property("DEVELOPER_NAME") as String)
31+
organization.set(project.property("DEVELOPER_ORG") as String)
32+
organizationUrl.set(project.property("DEVELOPER_ORG_URL") as String)
33+
}
34+
}
35+
36+
scm {
37+
url.set(project.property("POM_SCM_URL") as String)
38+
connection.set(project.property("POM_SCM_CONNECTION") as String)
39+
developerConnection.set(project.property("POM_SCM_DEVELOPER_CONNECTION") as String)
40+
}
41+
}
42+
}
43+
}
44+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import org.gradle.language.jvm.tasks.ProcessResources
2+
3+
// Retrieve properties from the Gradle project
4+
val artifactName = project.property("ARTIFACT_NAME") as String
5+
val version = project.property("VERSION") as String
6+
val groupId = project.property("GROUP_ID") as String
7+
8+
// Prepare the content for sdk.properties
9+
val sdkPropertiesContent = """
10+
artifactName=$artifactName
11+
version=$version
12+
groupId=$groupId
13+
""".trimIndent()
14+
15+
// Configure the processResources task to include sdk.properties
16+
tasks.named<ProcessResources>("processResources") {
17+
from(project.resources.text.fromString(sdkPropertiesContent)) {
18+
rename { "sdk.properties" }
19+
}
20+
}

gradle-tasks/signing.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extensions.configure<SigningExtension> {
2+
val signingKey = System.getenv("GPG_SECRET")
3+
val signingPassword = System.getenv("GPG_PASSPHRASE")
4+
5+
useInMemoryPgpKeys(signingKey, signingPassword)
6+
7+
val publishing = project.extensions.getByType<PublishingExtension>()
8+
sign(publishing.publications)
9+
}

gradle-tasks/snapshot.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Nexus publishing plugin relies on the root project version to determine which repository to use (releases | snapshots)
2+
// We're setting the root project to a dummy version (1.0.0-SNAPSHOT) to instruct the plugin to use the snapshot repo.
3+
// This version won't be published. The publishSnapshots task will publish submodules with the defined version in their gradle.properties
4+
gradle.taskGraph.whenReady { taskGraph ->
5+
if (taskGraph.hasTask(":publishSnapshots")) {
6+
rootProject.version = "1.0.0-SNAPSHOT"
7+
println "📌 Setting root project version to 1.0.0-SNAPSHOT for publishSnapshots task"
8+
}
9+
}
10+
11+
tasks.register("publishSnapshots") {
12+
def snapshotModules = rootProject.subprojects.findAll { project ->
13+
project.version.toString().contains("-SNAPSHOT") && project.tasks.named("publish") != null
14+
}
15+
16+
if (!snapshotModules.isEmpty()) {
17+
dependsOn snapshotModules.collect { ":${it.name}:publish" }
18+
}
19+
20+
doLast {
21+
if (snapshotModules.isEmpty()) {
22+
println "❌ No snapshot modules to publish."
23+
} else {
24+
println "📦 Successfully published snapshots for: ${snapshotModules*.name}"
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)