Skip to content

Commit

Permalink
Setup: init (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
zklgame authored Sep 27, 2023
1 parent 071cbb6 commit 4e95e20
Show file tree
Hide file tree
Showing 16 changed files with 727 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

26 changes: 26 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test Build
on:
pull_request:
push:
branches:
- 'main'

jobs:
tests:
name: "Test build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 8
- uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.3
- run: git submodule update --init --recursive && sleep 10 && gradle build
- name: Dump docker logs
if: always()
uses: jwalton/gh-docker-logs@v2
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

.idea
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "xdb-apis"]
path = xdb-apis
url = https://github.com/xdblab/xdb-apis
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# xdb-java-sdk
# xdb-java-sdk
196 changes: 196 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* To learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.3/samples
* This project uses @Incubating APIs which are subject to change.
*/

plugins {
id 'java-library'
id "org.openapi.generator" version "6.6.0"
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id "maven-publish"
id 'signing'
id 'jacoco'
id 'com.diffplug.spotless' version "6.13.0"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}

repositories {
mavenCentral()
}

dependencies {
// for openapi generator
implementation 'com.google.guava:guava:32.1.2-jre'
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
implementation 'io.github.openfeign:feign-okhttp:12.5'
implementation 'io.github.openfeign:feign-jackson:12.5'
implementation 'io.github.openfeign:feign-slf4j:12.5'
implementation 'io.github.openfeign.form:feign-form:3.8.0'
implementation 'org.openapitools:jackson-databind-nullable:0.2.6'
implementation 'javax.annotation:javax.annotation-api:1.3.2'

// lombok
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
testCompileOnly 'org.projectlombok:lombok:1.18.30'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'
}

// open api

openApiValidate {
inputSpec.set("$rootDir/xdb-apis/api-schema/xdb.yaml")
}

openApiGenerate {
generatorName = "java"
inputSpec = "$rootDir/xdb-apis/api-schema/xdb.yaml".toString()
outputDir = "$buildDir/generated".toString()
apiPackage = "io.xdb.gen.api"
modelPackage = "io.xdb.gen.models"
invokerPackage = "io.xdb.gen.api"
configOptions = [
configPackage: "io.xdb.gen.configuration",
basePackage : "io.xdb.gen",
library : "feign",
interfaceOnly: "true"
]
}

compileJava.dependsOn tasks.openApiGenerate
sourceSets.main.java.srcDirs += "$buildDir/generated/src/main/java"

tasks.named('sourcesJar').configure {
dependsOn tasks.openApiGenerate
}

// test

tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

jacocoTestReport {
reports {
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}

check.dependsOn tasks.jacocoTestReport

// spotless

spotless {
def prettierPlugins = [
"prettier": "2.5.1",
"prettier-plugin-java": "1.6.1",
]

def ignoredDirs = [
'.gradle/**',
'.idea/**',
'build/**'
]

format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '.gitignore'
targetExclude(ignoredDirs)

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
format 'markdown', {
target '*.md'
targetExclude(ignoredDirs)

prettier(prettierPlugins).config([
'parser': 'markdown'
])
}
java {
targetExclude(ignoredDirs)

importOrder()

removeUnusedImports()

prettier(prettierPlugins).config([
'parser': 'java',
'tabWidth': 4,
'printWidth': 120
])
}
}

test.dependsOn tasks.spotlessApply

// publish

publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)

pom {
name = "xdb-java-sdk"
description = "xdb java sdk core"
url = 'https://github.com/xdblab/xdb-java-sdk'

scm {
connection = 'scm:[email protected]:xdblab/xdb-java-sdk.git'
developerConnection = 'scm:[email protected]:xdblab/xdb-java-sdk.git'
url = 'https://github.com/xdblab/xdb-java-sdk'
}

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id = 'zhukaili'
name = 'Kaili Zhu'
email = '[email protected]'
}
}
}
}
}
}

signing {
sign publishing.publications.mavenJava
}

group = "io.xdb"
version = "0.0.1"

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
// username = project.property('myNexusUsername')
// password = project.property('myNexusPassword')
}
}
}
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

org.gradle.parallel=true
org.gradle.caching=true

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.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 4e95e20

Please sign in to comment.