Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Configuration file for EditorConfig: http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

# space indentation for JSON and YML
[*.{json,json5,yml,yaml}]
indent_size = 2

[*.kt]
ktlint_standard_enum-entry-name-case = disabled
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.gradle
.idea

build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Kotlin ###
.kotlin

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
88 changes: 88 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.Duration

plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "2.1.10"
id("org.jlleitschuh.gradle.ktlint") version "12.1.2"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}

group = project.property("GROUP_ID") as String

apply("$rootDir/gradle-tasks/specs.gradle.kts")
apply("$rootDir/gradle-tasks/snapshot.gradle")

allprojects {
repositories {
mavenCentral()
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
}

subprojects {
apply(plugin = "java")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jlleitschuh.gradle.ktlint")

plugins.withId("org.jetbrains.kotlin.jvm") {
kotlin {
jvmToolchain(8)
}
}

plugins.withType<KotlinBasePluginWrapper>().configureEach {
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
}

java {
withSourcesJar()
withJavadocJar()

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

// Gradle 7+ Java toolchain approach (also sets 1.8)
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}

ktlint {
debug.set(true)
version.set("1.5.0")
verbose.set(true)

additionalEditorconfig.set(
mapOf(
"max_line_length" to "200",
"indent_style" to "space",
"indent_size" to "4",
"insert_final_newline" to "true",
"end_of_line" to "lf",
),
)
}
}

nexusPublishing {
repositories {
sonatype {
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}

transitionCheckOptions {
maxRetries.set(60)
delayBetween.set(Duration.ofMillis(5000))
}
}
12 changes: 12 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}

dependencies {
api("org.openapitools:openapi-generator:7.11.0")
implementation("com.samskivert:jmustache:1.15")
}
9 changes: 9 additions & 0 deletions generator/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id("com.expediagroup.sdk.openapigenerator") version "0.0.9-alpha"
}

group = project.property("GROUP_ID") as String

dependencies {
api("org.openapitools:openapi-generator:7.11.0")
}
1 change: 1 addition & 0 deletions generator/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace=xap
44 changes: 44 additions & 0 deletions gradle-tasks/publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
project.extensions.configure<PublishingExtension> {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
artifactId = project.property("ARTIFACT_NAME") as String
groupId = project.property("GROUP_ID") as String
version = if (project.findProperty("SNAPSHOT_VERSION") != null) {
project.findProperty("SNAPSHOT_VERSION") as String
} else {
project.property("VERSION") as String
}
description = project.findProperty("DESCRIPTION") as String?

pom {
name.set(project.property("ARTIFACT_NAME") as String)
description.set(project.findProperty("DESCRIPTION") as String?)
url.set(project.property("POM_URL") as String)

licenses {
license {
name.set(project.property("LICENSE_NAME") as String)
url.set(project.property("LICENSE_URL") as String)
distribution.set(project.property("LICENSE_DISTRIBUTION") as String)
comments.set(project.property("LICENSE_COMMENTS") as String)
}
}

developers {
developer {
name.set(project.property("DEVELOPER_NAME") as String)
organization.set(project.property("DEVELOPER_ORG") as String)
organizationUrl.set(project.property("DEVELOPER_ORG_URL") as String)
}
}

scm {
url.set(project.property("POM_SCM_URL") as String)
connection.set(project.property("POM_SCM_CONNECTION") as String)
developerConnection.set(project.property("POM_SCM_DEVELOPER_CONNECTION") as String)
}
}
}
}
}
20 changes: 20 additions & 0 deletions gradle-tasks/sdk-properties.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import org.gradle.language.jvm.tasks.ProcessResources

// Retrieve properties from the Gradle project
val artifactName = project.property("ARTIFACT_NAME") as String
val version = project.property("VERSION") as String
val groupId = project.property("GROUP_ID") as String

// Prepare the content for sdk.properties
val sdkPropertiesContent = """
artifactName=$artifactName
version=$version
groupId=$groupId
""".trimIndent()

// Configure the processResources task to include sdk.properties
tasks.named<ProcessResources>("processResources") {
from(project.resources.text.fromString(sdkPropertiesContent)) {
rename { "sdk.properties" }
}
}
9 changes: 9 additions & 0 deletions gradle-tasks/signing.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extensions.configure<SigningExtension> {
val signingKey = System.getenv("GPG_SECRET")
val signingPassword = System.getenv("GPG_PASSPHRASE")

useInMemoryPgpKeys(signingKey, signingPassword)

val publishing = project.extensions.getByType<PublishingExtension>()
sign(publishing.publications)
}
27 changes: 27 additions & 0 deletions gradle-tasks/snapshot.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Nexus publishing plugin relies on the root project version to determine which repository to use (releases | snapshots)
// We're setting the root project to a dummy version (1.0.0-SNAPSHOT) to instruct the plugin to use the snapshot repo.
// This version won't be published. The publishSnapshots task will publish submodules with the defined version in their gradle.properties
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(":publishSnapshots")) {
rootProject.version = "1.0.0-SNAPSHOT"
println "📌 Setting root project version to 1.0.0-SNAPSHOT for publishSnapshots task"
}
}

tasks.register("publishSnapshots") {
def snapshotModules = rootProject.subprojects.findAll { project ->
project.version.toString().contains("-SNAPSHOT") && project.tasks.named("publish") != null
}

if (!snapshotModules.isEmpty()) {
dependsOn snapshotModules.collect { ":${it.name}:publish" }
}

doLast {
if (snapshotModules.isEmpty()) {
println "❌ No snapshot modules to publish."
} else {
println "📦 Successfully published snapshots for: ${snapshotModules*.name}"
}
}
}
24 changes: 24 additions & 0 deletions gradle-tasks/specs.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
tasks.register<Exec>("mergeSpecs") {
commandLine("npx", "openapi-merge-cli")
workingDir = File(rootDir, "specs")
}

tasks.register<Exec>("transformSpecs") {
dependsOn("mergeSpecs")

commandLine(
"npx --yes -p @expediagroup/spec-transformer cli --headers --operationIdsToTags -i specs.yaml -o specs.yaml"
.split(" ")
)
workingDir = File(rootDir, "specs")
}

tasks.register("prepareSpecs") {
dependsOn("mergeSpecs", "transformSpecs")

doLast {
File("$rootDir", "specs/specs.yaml").copyTo(
File("$rootDir", "generator/src/main/resources/transformedSpecs.yaml"),
)
}
}
26 changes: 26 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
kotlin.code.style=official

# Publishing defaults
GROUP_ID=com.expediagroup

# POM
POM_URL=https://github.com/ExpediaGroup/xap-java-sdk

# POM LICENSE
LICENSE_NAME=The Apache License, Version 2.0
LICENSE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
LICENSE_DISTRIBUTION=repo
LICENSE_COMMENTS=A business-friendly OSS license

# POM DEVELOPERS
DEVELOPER_NAME=Expedia Group Committers
DEVELOPER_ORG=Expedia Group
DEVELOPER_ORG_URL=https://www.expediagroup.com/

# SCM
POM_SCM_URL=https://github.com/ExpediaGroup/xap-java-sdk
POM_SCM_CONNECTION=scm:git:git://github.com/ExpediaGroup/xap-java-sdk.git
POM_SCM_DEVELOPER_CONNECTION=scm:git:ssh://github.com/ExpediaGroup/xap-java-sdk.git

# JVM PARAMS
org.gradle.jvmargs=-Xmx2g
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading