Skip to content

Commit

Permalink
New client library.
Browse files Browse the repository at this point in the history
  • Loading branch information
cstroe committed Jan 22, 2020
1 parent 63e73f0 commit 02e265c
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 4 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ Running the integration tests via the Gradle task:
## Publishing

```
./gradlew clean build :checklister-web:bootJar
./gradlew clean build :web:bootJar
docker build -t blacktower:5000/cosapps/checklister:<version> .
docker push docker build -t blacktower:5000/cosapps/checklister:<version>
docker push blacktower:5000/cosapps/checklister:<version>
```

## Generating the Client Library

```
./gradlew :client:openApiGenerate
cd subprojects/client/build/openapi
cp ../../build.gradle.custom build.gradle
chmod a+x gradlew
./gradlew
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.1.2-SNAPSHOT
version=0.1.2
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ include("dto",
"eventsink-kafka",
"web",
"history",
"integrationTest")
"integrationTest",
"client")

for (project in rootProject.children) {
project.apply {
Expand Down
138 changes: 138 additions & 0 deletions subprojects/client/build.gradle.custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}

plugins {
id 'java-library'
id 'maven-publish'
}

group = 'cloud.cosmin.checklister'
version = '0.1.2-SNAPSHOT'

repositories {
jcenter()
}

sourceSets {
main.java.srcDirs = ['src/main/java']
}

if(hasProperty('target') && target == 'android') {

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}

dependencies {
provided 'javax.annotation:jsr250-api:1.0'
}
}

afterEvaluate {
android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
task.description = "Create jar artifact for ${variant.name}"
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task);
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

artifacts {
archives sourcesJar
}

} else {

apply plugin: 'java'
apply plugin: 'maven'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

install {
repositories.mavenInstaller {
pom.artifactId = 'client'
}
}

task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}

dependencies {
compile 'io.swagger:swagger-annotations:1.5.22'
compile "com.google.code.findbugs:jsr305:3.0.2"
compile 'com.squareup.okhttp3:okhttp:3.14.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.14.2'
compile 'com.google.code.gson:gson:2.8.5'
compile 'io.gsonfire:gson-fire:1.8.3'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
compile 'javax.annotation:javax.annotation-api:1.3.2'
testCompile 'junit:junit:4.12'
}

javadoc {
options.tags = [ "http.response.details:a:Http Response Details" ]
}

java {
withSourcesJar()
}

publishing {
repositories {
maven {
credentials {
username "admin"
password "password123"
}
url = "http://localhost:8080/repository/snapshots"
}
}

publications {
checklister(MavenPublication) {
from components.java
}
}
}
29 changes: 29 additions & 0 deletions subprojects/client/client.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
// https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc
id("org.openapi.generator") version "4.2.2"
}

openApiGenerate {
generatorName.set("java")
inputSpec.set("${project.rootDir}/openapi.json")
outputDir.set("${project.buildDir}/openapi")

generateApiTests.set(false)
generateModelTests.set(false)

// Ignore file doesn't work as expected.
//val ignoreFile = "${project.projectDir}/openapi-generator-ignore"
//println("ignoreFileOverride = " + ignoreFile)
//ignoreFileOverride.set(ignoreFile)

configOptions.set(
mapOf(
"invokerPackage" to "cloud.cosmin.checklister.client",
"apiPackage" to "cloud.cosmin.checklister.client.api",
"modelPackage" to "cloud.cosmin.checklister.client.model",
"groupId" to "cosmin.cloud.checklister",
"artifactId" to "client",
"dateLibrary" to "java8"
)
)
}
3 changes: 3 additions & 0 deletions subprojects/client/openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These files will not be overwritten when the generator is invoked:
/build.gradle
/build.sbt

0 comments on commit 02e265c

Please sign in to comment.