diff --git a/subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/java/JavaLibraryPlugin.java b/subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/java/JavaLibraryPlugin.java index b47e4396..39570ab4 100644 --- a/subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/java/JavaLibraryPlugin.java +++ b/subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/java/JavaLibraryPlugin.java @@ -1,6 +1,8 @@ package org.shipkit.internal.gradle.java; -import org.gradle.api.*; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.Task; import org.gradle.api.file.CopySpec; import org.gradle.api.tasks.bundling.Jar; import org.shipkit.internal.gradle.util.JavaPluginUtil; @@ -37,28 +39,20 @@ public class JavaLibraryPlugin implements Plugin { public void apply(final Project project) { project.getPlugins().apply("java"); - final CopySpec license = project.copySpec(new Action() { - public void execute(CopySpec copy) { - copy.from(project.getRootDir()).include("LICENSE"); - } - }); + final CopySpec license = project.copySpec(copy -> copy.from(project.getRootDir()).include("LICENSE")); ((Jar) project.getTasks().getByName("jar")).with(license); - final Jar sourcesJar = project.getTasks().create(SOURCES_JAR_TASK, Jar.class, new Action() { - public void execute(Jar jar) { - jar.from(JavaPluginUtil.getMainSourceSet(project).getAllSource()); - jar.setClassifier("sources"); - jar.with(license); - } + final Jar sourcesJar = project.getTasks().create(SOURCES_JAR_TASK, Jar.class, jar -> { + jar.from(JavaPluginUtil.getMainSourceSet(project).getAllSource()); + jar.setClassifier("sources"); + jar.with(license); }); - final Task javadocJar = project.getTasks().create(JAVADOC_JAR_TASK, Jar.class, new Action() { - public void execute(Jar jar) { - jar.from(project.getTasks().getByName("javadoc")); - jar.setClassifier("javadoc"); - jar.with(license); - } + final Task javadocJar = project.getTasks().create(JAVADOC_JAR_TASK, Jar.class, jar -> { + jar.from(project.getTasks().getByName("javadoc")); + jar.setClassifier("javadoc"); + jar.with(license); }); project.getArtifacts().add("archives", sourcesJar); diff --git a/subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/java/JavaPublishPlugin.java b/subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/java/JavaPublishPlugin.java index 0a794855..3466c193 100644 --- a/subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/java/JavaPublishPlugin.java +++ b/subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/java/JavaPublishPlugin.java @@ -1,15 +1,14 @@ package org.shipkit.internal.gradle.java; -import org.gradle.api.Action; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.Task; import org.gradle.api.logging.Logger; import org.gradle.api.logging.Logging; -import org.gradle.api.publish.PublicationContainer; import org.gradle.api.publish.maven.MavenPublication; import org.gradle.api.tasks.bundling.Jar; import org.shipkit.gradle.configuration.ShipkitConfiguration; +import org.shipkit.internal.gradle.configuration.DeferredConfiguration; import org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin; import org.shipkit.internal.gradle.snapshot.LocalSnapshotPlugin; import org.shipkit.internal.gradle.util.GradleDSLHelper; @@ -56,19 +55,17 @@ public void apply(final Project project) { final Jar sourcesJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.SOURCES_JAR_TASK); final Jar javadocJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.JAVADOC_JAR_TASK); - GradleDSLHelper.publications(project, new Action() { - public void execute(PublicationContainer publications) { - MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, new Action() { - public void execute(MavenPublication publication) { - publication.from(project.getComponents().getByName("java")); - publication.artifact(sourcesJar); - publication.artifact(javadocJar); - publication.setArtifactId(((Jar) project.getTasks().getByName("jar")).getBaseName()); - PomCustomizer.customizePom(project, conf, publication); - } + GradleDSLHelper.publications(project, publications -> { + MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, publication -> { + publication.from(project.getComponents().getByName("java")); + publication.artifact(sourcesJar); + publication.artifact(javadocJar); + DeferredConfiguration.deferredConfiguration(project, () -> { + publication.setArtifactId(((Jar) project.getTasks().getByName("jar")).getBaseName()); }); - LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId()); - } + PomCustomizer.customizePom(project, conf, publication); + }); + LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId()); }); //so that we flesh out problems with maven publication during the build process