🚧 Gradle 6 - Dependency constraints
This commit is contained in:
parent
36be6908fe
commit
f95a1a2011
|
@ -6,9 +6,36 @@ plugins {
|
|||
group = "com.baeldung"
|
||||
version = "1.0.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api("io.reactivex.rxjava2:rxjava:2.2.16")
|
||||
implementation("com.google.guava:guava") {
|
||||
version {
|
||||
require("2.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()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
register("mavenJava", MavenPublication::class) {
|
||||
register<MavenPublication>("mavenJava") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package com.baeldung.gradle;
|
||||
|
||||
public class HelloWorld {
|
||||
|
||||
public String sayHello() {
|
||||
return "Hello, world!";
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue