Skip to content

Commit

Permalink
Add use-case 5 : Baleen as multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
kdallmeyer-sr committed Jul 29, 2019
1 parent 7c92888 commit ce10b1a
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 65 deletions.
19 changes: 0 additions & 19 deletions baleen-v2-tests/README.md

This file was deleted.

29 changes: 29 additions & 0 deletions baleen-v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Preparation for version 2

Do test driven development for version 2

```bash
./gradlew build -Pversion2
./gradlew :baleen-v2:build -Pversion2

```

## Use Case 1 - Given we have the data, we define the schema manually and validate the data

[UseCase1Test.kt](baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt)

## Use Case 2 - Given we have the data, we learn the schema and validate the data

[UseCase2Test.kt](baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt)

## Use Case 3 - Given a external schema (Avro, XSD, Json-Schema, Kotlin data class), build Baleen schema and validate the data

[UseCase3Test.kt](baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt)

## Use Case 4 - Given a Baleen schema, create external schema (Avro, XSD, Json-Schema, Kotlin data class) and validate the data with the external schema

[UseCase4Test.kt](baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt)

## Use Case 5 - Baleen is multiplatform and can be run on JVM, in Javascript from node and from the browser, and from Python via Cinteropt

[baleen-v2/build.gradle](baleen-v2/build.gradle)
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ repositories {
test {
ignoreFailures = true
}

if (!project.hasProperty("version2")) {
project.tasks.each {
it.onlyIf { false }
}
}
2 changes: 2 additions & 0 deletions baleen-v2/baleen-v2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/commonMain
src/commonTest
43 changes: 43 additions & 0 deletions baleen-v2/baleen-v2/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
id 'org.jetbrains.kotlin.multiplatform'
}

kotlin {
// Targets
jvm() // Creates a JVM target with the default name 'jvm'
js() // JS target named 'js'

sourceSets {
commonMain {
kotlin {
srcDir project(":baleen").file("src/main/kotlin")
}

dependencies {
implementation kotlin('stdlib-common')
}
}
commonTest {
// kotlin {
// srcDir project(":baleen").file("src/test/kotlin")
// }

dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}

jvmTest {
dependencies {
implementation kotlin('test-junit')
}
}
}
}

if (!project.hasProperty("version2")) {
project.tasks.each {
it.onlyIf { false }
}
}
94 changes: 49 additions & 45 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ plugins {
id 'idea'
id "org.jetbrains.dokka" version "0.9.18" apply false
id 'org.jetbrains.kotlin.jvm' version '1.3.41' apply false
id 'org.jmailen.kotlinter' version '2.1.0' apply false
id 'org.jetbrains.kotlin.multiplatform' version '1.3.41' apply false
id 'org.jmailen.kotlinter' version '2.10' apply false
}

subprojects {
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'maven-publish'
apply plugin: 'kotlin'
apply plugin: 'org.jmailen.kotlinter'
apply plugin: 'signing'

Expand All @@ -17,62 +17,66 @@ subprojects {
jcenter()
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
testImplementation 'org.assertj:assertj-core:3.12.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.0'
}
if(it.name != "baleen-v2") {
apply plugin: 'kotlin'

test {
useJUnitPlatform()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
testImplementation 'org.assertj:assertj-core:3.12.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.0'
}

task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
test {
useJUnitPlatform()
}

task javadocJar(type: Jar, dependsOn: dokka) {
classifier = 'javadoc'
from dokka
}
task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives jar
archives sourceJar
archives javadocJar
}
task javadocJar(type: Jar, dependsOn: dokka) {
classifier = 'javadoc'
from dokka
}

signing {
sign publishing.publications
}
artifacts {
archives jar
archives sourceJar
archives javadocJar
}

signing {
sign publishing.publications
}

publishing {
publications {
mavenJava(MavenPublication) {
customizePom(pom)
publishing {
publications {
mavenJava(MavenPublication) {
customizePom(pom)

from components.java
from components.java

artifact sourceJar
artifact javadocJar
artifact sourceJar
artifact javadocJar
}
}
}
repositories {
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username sonatypeUsername
password sonatypePassword
repositories {
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username sonatypeUsername
password sonatypePassword
}
}
}
}
}

model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include 'baleen-jsonschema-generator'
include 'jsonschema-baleen-generator'
include 'baleen-xml'
include 'baleen-xsd-generator'
include 'baleen-v2-tests'
include 'baleen-v2:baleen-v2'
include 'baleen-v2:baleen-v2-tests'

rootProject.name = 'baleen'

0 comments on commit ce10b1a

Please sign in to comment.