Skip to content

Commit

Permalink
Centralise versions for examples (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
fnobilia committed Dec 21, 2020
1 parent 6804b90 commit d18b6c6
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 39 deletions.
16 changes: 0 additions & 16 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,3 @@ updates:
interval: "weekly"
reviewers:
- "fnobilia"
- package-ecosystem: "gradle"
directory: "/examples/junit-5"
schedule:
interval: "weekly"
ignore:
- dependency-name: "io.github.data-rocks-team:schemaregistry-junit5"
reviewers:
- "fnobilia"
- package-ecosystem: "gradle"
directory: "/examples/junit-4"
schedule:
interval: "weekly"
ignore:
- dependency-name: "io.github.data-rocks-team:schemaregistry-junit4"
reviewers:
- "fnobilia"
2 changes: 2 additions & 0 deletions .github/workflows/gradle-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
restore-keys: ${{ runner.os }}-example-gradle
- name: Build with Gradle
run: ./gradlew publishToMavenLocal -PdisableCheckstyle -PdisableJacoco -PdisablePmd -x test
- name: Set dependency versions
run: ./gradlew setDependenciesForExample
- name: Run Junit5 example
run: cd ./examples/junit-5 && ./gradlew build
- name: Run Junit4 example
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ Every build is automatically tested against the latest patch version of every mi
- [JUnit 5 example](/examples/junit-5)
- [JUnit 4 example](/examples/junit-4)

Before compiling any example, run `./gradlew setDependenciesForExample` in the main project. This
gradle task will ensure that the example project will use the same dependency versions used in the
main project. To ensure that `setDependenciesForExample` works as expected, dependencies
version should be defined in the `ext {}` section in the [main build.gradle](build.gradle) and the
example project should define versions as `nameOfTheDependencyVersion = PLACEHOLDER` (an example
can be found [here](examples/junit-5/build.gradle)).

## Contributing
Found a bug? Think you've got an awesome feature you want to add? We welcome contributions!

Expand Down
50 changes: 36 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ allprojects {
}
}

subprojects {
ext {
assertjVersion = '3.18.1'
apacheCuratorVersion = '5.1.0'
confluentVersion = '6.0.1'
kafkaJunitVersion = '3.2.2'
jsonSchemaVersion = '1.12.1'
junit4Version = '4.13.1'
junitJupiterVersion = '5.7.0'
lombokVersion = '1.18.16'
protobufVersion = '3.14.0'
slf4jVersion = '1.7.30'
testcontainersVersion = '1.15.1'
}

ext {
assertjVersion = '3.18.1'
apacheCuratorVersion = '5.1.0'
confluentVersion = '6.0.1'
kafkaJunitVersion = '3.2.2'
jsonSchemaVersion = '1.12.1'
junit4Version = '4.13.1'
junitJupiterVersion = '5.7.0'
lombokVersion = '1.18.16'
protobufVersion = '3.14.0'
slf4jVersion = '1.7.30'
testcontainersVersion = '1.15.1'
}
subprojects {

// Every module is a Java library
apply plugin: 'java-library'
Expand Down Expand Up @@ -74,3 +74,25 @@ subprojects {
// Add flag to run specific group of tests
apply from: "$rootProject.projectDir/on-off-test.gradle"
}

task setDependenciesForExample {
group 'Configure Example'
description 'Set dependencies for example using centralised ext variables'
doLast {
fileTree("examples")
.filter { it.isFile() }
.filter { it.name == 'build.gradle' }
.files
.path
.each {file ->
File buildGradle = new File(file)
String content = buildGradle.text

project.ext.properties
.each{ k, v ->
content = content.replaceAll("$k = 'PLACEHOLDER'", "$k = '$v'")}

buildGradle.write(content)
}
}
}
12 changes: 8 additions & 4 deletions examples/junit-4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@ repositories {
}

ext {
confluentVersion = '6.0.1'
// Run ./gradlew setDependenciesForExample to set this properties
assertjVersion = 'PLACEHOLDER'
confluentVersion = 'PLACEHOLDER'
kafkaJunitVersion = 'PLACEHOLDER'
junit4Version = 'PLACEHOLDER'
}

dependencies {
implementation "io.confluent:kafka-avro-serializer:$confluentVersion"
implementation "io.confluent:kafka-schema-registry-client:$confluentVersion"

testImplementation 'com.salesforce.kafka.test:kafka-junit4:3.2.2'
testImplementation "com.salesforce.kafka.test:kafka-junit4:$kafkaJunitVersion"

// schema-registry junit
testImplementation 'io.github.data-rocks-team:schemaregistry-junit4:local'
testImplementation "io.confluent:kafka-schema-registry:$confluentVersion"

testImplementation 'junit:junit:4.13.1'
testImplementation "junit:junit:$junit4Version"

testImplementation 'org.assertj:assertj-core:3.18.1'
testImplementation "org.assertj:assertj-core:$assertjVersion"
}
14 changes: 9 additions & 5 deletions examples/junit-5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,27 @@ repositories {
}

ext {
confluentVersion = '6.0.1'
// Run ./gradlew setDependenciesForExample to set this properties
assertjVersion = 'PLACEHOLDER'
confluentVersion = 'PLACEHOLDER'
kafkaJunitVersion = 'PLACEHOLDER'
junitJupiterVersion = 'PLACEHOLDER'
}

dependencies {
implementation "io.confluent:kafka-avro-serializer:$confluentVersion"
implementation "io.confluent:kafka-schema-registry-client:$confluentVersion"

testImplementation 'com.salesforce.kafka.test:kafka-junit5:3.2.2'
testImplementation "com.salesforce.kafka.test:kafka-junit5:$kafkaJunitVersion"

// schema-registry junit
testImplementation 'io.github.data-rocks-team:schemaregistry-junit5:local'
testImplementation "io.confluent:kafka-schema-registry:$confluentVersion"

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"

testImplementation 'org.assertj:assertj-core:3.17.2'
testImplementation "org.assertj:assertj-core:$assertjVersion"
}

test {
Expand Down

0 comments on commit d18b6c6

Please sign in to comment.