Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't include org.jetbrains.kotlin:kotlin-stdlib-jdk8 as a dependency in Gradle projects at the Kotlin Gradle plugin adds the dependency automatically #1376

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class KotlinDependenciesConfigurer implements BuildCustomizer<Build> {

@Override
public void customize(Build build) {
build.dependencies().add("kotlin-stdlib", Dependency
.withCoordinates("org.jetbrains.kotlin", "kotlin-stdlib-jdk8").scope(DependencyScope.COMPILE));
build.dependencies().add("kotlin-reflect",
Dependency.withCoordinates("org.jetbrains.kotlin", "kotlin-reflect").scope(DependencyScope.COMPILE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.spring.initializr.generator.spring.code.kotlin;

import io.spring.initializr.generator.buildsystem.Dependency;
import io.spring.initializr.generator.buildsystem.DependencyScope;
import io.spring.initializr.generator.buildsystem.maven.MavenBuild;
import io.spring.initializr.generator.spring.build.BuildCustomizer;

Expand Down Expand Up @@ -50,6 +52,8 @@ public void customize(MavenBuild build) {
});
kotlinMavenPlugin.dependency("org.jetbrains.kotlin", "kotlin-maven-allopen", "${kotlin.version}");
});
build.dependencies().add("kotlin-stdlib", Dependency
.withCoordinates("org.jetbrains.kotlin", "kotlin-stdlib-jdk8").scope(DependencyScope.COMPILE));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.spring.initializr.generator.spring.code.kotlin;

import io.spring.initializr.generator.buildsystem.Dependency;
import io.spring.initializr.generator.buildsystem.DependencyScope;
import io.spring.initializr.generator.buildsystem.gradle.GradleBuild;
import io.spring.initializr.generator.buildsystem.maven.MavenBuild;
import org.junit.jupiter.api.Test;
Expand All @@ -35,12 +34,7 @@ class KotlinDependenciesConfigurerTests {
void configuresDependenciesForGradleBuild() {
GradleBuild build = new GradleBuild();
new KotlinDependenciesConfigurer().customize(build);
assertThat(build.dependencies().ids()).containsOnly("kotlin-stdlib", "kotlin-reflect");
Dependency kotlinStdlib = build.dependencies().get("kotlin-stdlib");
assertThat(kotlinStdlib.getGroupId()).isEqualTo("org.jetbrains.kotlin");
assertThat(kotlinStdlib.getArtifactId()).isEqualTo("kotlin-stdlib-jdk8");
assertThat(kotlinStdlib.getVersion()).isNull();
assertThat(kotlinStdlib.getScope()).isEqualTo(DependencyScope.COMPILE);
assertThat(build.dependencies().ids()).containsOnly("kotlin-reflect");
Dependency kotlinReflect = build.dependencies().get("kotlin-reflect");
assertThat(kotlinReflect.getGroupId()).isEqualTo("org.jetbrains.kotlin");
assertThat(kotlinReflect.getArtifactId()).isEqualTo("kotlin-reflect");
Expand All @@ -51,12 +45,7 @@ void configuresDependenciesForGradleBuild() {
void configuresDependenciesForMavenBuild() {
MavenBuild build = new MavenBuild();
new KotlinDependenciesConfigurer().customize(build);
assertThat(build.dependencies().ids()).containsOnly("kotlin-stdlib", "kotlin-reflect");
Dependency kotlinStdlib = build.dependencies().get("kotlin-stdlib");
assertThat(kotlinStdlib.getGroupId()).isEqualTo("org.jetbrains.kotlin");
assertThat(kotlinStdlib.getArtifactId()).isEqualTo("kotlin-stdlib-jdk8");
assertThat(kotlinStdlib.getVersion()).isNull();
assertThat(kotlinStdlib.getScope()).isEqualTo(DependencyScope.COMPILE);
assertThat(build.dependencies().ids()).containsOnly("kotlin-reflect");
Dependency kotlinReflect = build.dependencies().get("kotlin-reflect");
assertThat(kotlinReflect.getGroupId()).isEqualTo("org.jetbrains.kotlin");
assertThat(kotlinReflect.getArtifactId()).isEqualTo("kotlin-reflect");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Arrays;
import java.util.List;

import io.spring.initializr.generator.buildsystem.DependencyScope;
import io.spring.initializr.generator.buildsystem.maven.MavenBuild;
import io.spring.initializr.generator.buildsystem.maven.MavenPlugin.Configuration;
import io.spring.initializr.generator.buildsystem.maven.MavenPlugin.Dependency;
Expand Down Expand Up @@ -98,6 +99,18 @@ void kotlinMavenPluginWithSeveralArgs() {
});
}

@Test
void kotlinMavenKotlinStdlibIsConfigured() {
MavenBuild build = new MavenBuild();
new KotlinMavenBuildCustomizer(new TestKotlinProjectSettings()).customize(build);
assertThat(build.dependencies().ids()).containsOnly("kotlin-stdlib");
io.spring.initializr.generator.buildsystem.Dependency kotlinStdlib = build.dependencies().get("kotlin-stdlib");
assertThat(kotlinStdlib.getGroupId()).isEqualTo("org.jetbrains.kotlin");
assertThat(kotlinStdlib.getArtifactId()).isEqualTo("kotlin-stdlib-jdk8");
assertThat(kotlinStdlib.getVersion()).isNull();
assertThat(kotlinStdlib.getScope()).isEqualTo(DependencyScope.COMPILE);
}

private static class TestKotlinProjectSettings extends SimpleKotlinProjectSettings {

TestKotlinProjectSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ repositories {
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ repositories {
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ repositories {
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
Expand Down