🚧 Gradle 6 - Platforms
This commit is contained in:
29
gradle-6/dependency-constraints/build.gradle.kts
Normal file
29
gradle-6/dependency-constraints/build.gradle.kts
Normal file
@@ -0,0 +1,29 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
group = "com.baeldung"
|
||||
version = "1.0.0"
|
||||
|
||||
dependencies {
|
||||
api("io.reactivex.rxjava2:rxjava:2.2.16")
|
||||
implementation("com.google.guava:guava") {
|
||||
version {
|
||||
require("10.0")
|
||||
prefer("28.1-jre")
|
||||
because("Only uses ImmutableList type, so any version since 2.0 will do, but tested with 28.1-jre")
|
||||
}
|
||||
}
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.2")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.5.2")
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
sourceCompatibility = "1.8"
|
||||
targetCompatibility = "1.8"
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.gradle;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.reactivex.Observable;
|
||||
import java.util.List;
|
||||
|
||||
/** Demonstrates a library type that returns an RxJava type. */
|
||||
public class RxHelloWorld {
|
||||
|
||||
/** @return an {@link Observable} that emits events "hello" and "world" before completing. */
|
||||
public static Observable<String> hello() {
|
||||
// Guava ImmutableList class is an implementation detail.
|
||||
List<String> values = ImmutableList.of("hello", "world");
|
||||
return Observable.fromIterable(values);
|
||||
}
|
||||
|
||||
private RxHelloWorld() {}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.gradle;
|
||||
|
||||
import static com.baeldung.gradle.RxHelloWorld.hello;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit test for {@link RxHelloWorld}. */
|
||||
final class RxHelloWorldUnitTest {
|
||||
|
||||
@Test
|
||||
void it_emits_hello_world_values() {
|
||||
hello().test().assertValues("hello", "world").assertComplete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user