Skip to content

Commit

Permalink
Merge pull request #1376 from KotlinIsland
Browse files Browse the repository at this point in the history
* gh-1376:
  Polish "Don't include kotlin stdlib for gradle builds"
  Don't include kotlin stdlib for gradle builds

Closes gh-1376
  • Loading branch information
wilkinsona committed Feb 27, 2023
2 parents e8aa8f0 + c8ab4e7 commit d312fe8
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down 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
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -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
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -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
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -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 d312fe8

Please sign in to comment.