Avoid applying Kotlin JPA plugin

Applying plugins imperatively is discouraged, and since the plugin is
added to the plugins block anyway, it is applied already.

See gh-853
This commit is contained in:
jnizet
2019-03-03 09:43:15 +01:00
committed by Stephane Nicoll
parent 9c9cd09de5
commit 3ea0066fa8
2 changed files with 1 additions and 3 deletions

View File

@@ -45,7 +45,6 @@ public class KotlinJpaGradleBuildCustomizer implements BuildCustomizer<GradleBui
if (this.buildMetadataResolver.hasFacet(build, "jpa")) { if (this.buildMetadataResolver.hasFacet(build, "jpa")) {
build.addPlugin("org.jetbrains.kotlin.plugin.jpa", build.addPlugin("org.jetbrains.kotlin.plugin.jpa",
this.settings.getVersion()); this.settings.getVersion());
build.applyPlugin("kotlin-jpa");
} }
} }

View File

@@ -39,7 +39,7 @@ class KotlinJpaGradleBuildCustomizerTests {
Dependency dependency = Dependency.withId("foo"); Dependency dependency = Dependency.withId("foo");
dependency.setFacets(Collections.singletonList("jpa")); dependency.setFacets(Collections.singletonList("jpa"));
GradleBuild build = getCustomizedBuild(dependency); GradleBuild build = getCustomizedBuild(dependency);
assertThat(build.getAppliedPlugins()).contains("kotlin-jpa"); assertThat(build.getAppliedPlugins()).isEmpty();
assertThat(build.getPlugins()).hasSize(1); assertThat(build.getPlugins()).hasSize(1);
assertThat(build.getPlugins().get(0).getId()) assertThat(build.getPlugins().get(0).getId())
.isEqualTo("org.jetbrains.kotlin.plugin.jpa"); .isEqualTo("org.jetbrains.kotlin.plugin.jpa");
@@ -50,7 +50,6 @@ class KotlinJpaGradleBuildCustomizerTests {
void customizeWhenJpaFacetAbsentShouldNotAddKotlinJpaPlugin() { void customizeWhenJpaFacetAbsentShouldNotAddKotlinJpaPlugin() {
Dependency dependency = Dependency.withId("foo"); Dependency dependency = Dependency.withId("foo");
GradleBuild build = getCustomizedBuild(dependency); GradleBuild build = getCustomizedBuild(dependency);
assertThat(build.getAppliedPlugins()).hasSize(0);
assertThat(build.getPlugins()).hasSize(0); assertThat(build.getPlugins()).hasSize(0);
} }