Skip to content

Commit

Permalink
Don't include kotlin stdlib for gradle builds
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland authored and wilkinsona committed Feb 27, 2023
1 parent e8aa8f0 commit 3f1e44b
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 21 deletions.
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

0 comments on commit 3f1e44b

Please sign in to comment.