From 763bd7b739de2460cb82cc40f124c1e3061b832b Mon Sep 17 00:00:00 2001 From: James Yuzawa Date: Wed, 12 Jul 2023 08:22:55 -0400 Subject: [PATCH] convert --- .../gradle/eclipse/apt/AptEclipsePlugin.java | 10 ++++----- .../gradle/eclipse/apt/AptPlugin.java | 21 +++++++++---------- .../gradle/osgi/BndManifestPlugin.java | 13 ++++++------ 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/diffplug/gradle/eclipse/apt/AptEclipsePlugin.java b/src/main/java/com/diffplug/gradle/eclipse/apt/AptEclipsePlugin.java index 17531a410..b2d4c479f 100644 --- a/src/main/java/com/diffplug/gradle/eclipse/apt/AptEclipsePlugin.java +++ b/src/main/java/com/diffplug/gradle/eclipse/apt/AptEclipsePlugin.java @@ -25,7 +25,7 @@ import org.gradle.api.internal.PropertiesTransformer; import org.gradle.api.plugins.ExtensionAware; import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.plugins.JavaPluginConvention; +import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.tasks.Delete; import org.gradle.api.tasks.SourceSet; import org.gradle.internal.xml.XmlTransformer; @@ -62,12 +62,12 @@ public void apply(final Project project) { .withType( JavaPlugin.class, javaPlugin -> { - JavaPluginConvention javaConvention = - project.getConvention().getPlugin(JavaPluginConvention.class); + JavaPluginExtension javaExtension = + project.getExtensions().getByType(JavaPluginExtension.class); SourceSet mainSourceSet = - javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); + javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet testSourceSet = - javaConvention.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME); + javaExtension.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME); configureEclipse(project, mainSourceSet, testSourceSet); }); diff --git a/src/main/java/com/diffplug/gradle/eclipse/apt/AptPlugin.java b/src/main/java/com/diffplug/gradle/eclipse/apt/AptPlugin.java index f909c4eb2..5a4d707ea 100644 --- a/src/main/java/com/diffplug/gradle/eclipse/apt/AptPlugin.java +++ b/src/main/java/com/diffplug/gradle/eclipse/apt/AptPlugin.java @@ -31,9 +31,10 @@ import org.gradle.api.internal.HasConvention; import org.gradle.api.plugins.GroovyBasePlugin; import org.gradle.api.plugins.JavaBasePlugin; -import org.gradle.api.plugins.JavaPluginConvention; +import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.reflect.HasPublicType; import org.gradle.api.reflect.TypeOf; +import org.gradle.api.tasks.GroovySourceDirectorySet; import org.gradle.api.tasks.GroovySourceSet; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Internal; @@ -62,9 +63,9 @@ public void apply(final Project project) { .withType( JavaBasePlugin.class, javaBasePlugin -> { - final JavaPluginConvention javaConvention = - project.getConvention().getPlugin(JavaPluginConvention.class); - javaConvention + final JavaPluginExtension javaExtension = + project.getExtensions().getByType(JavaPluginExtension.class); + javaExtension .getSourceSets() .all( sourceSet -> { @@ -84,17 +85,15 @@ public void apply(final Project project) { .withType( GroovyBasePlugin.class, groovyBasePlugin -> { - JavaPluginConvention javaConvention = - project.getConvention().getPlugin(JavaPluginConvention.class); - javaConvention + JavaPluginExtension javaExtension = + project.getExtensions().getByType(JavaPluginExtension.class); + javaExtension .getSourceSets() .all( sourceSet -> { SourceDirectorySet groovy = - ((HasConvention) sourceSet) - .getConvention() - .getPlugin(GroovySourceSet.class) - .getGroovy(); + sourceSet.getExtensions() + .getByType(GroovySourceDirectorySet.class); configureCompileTaskForSourceSet( project, sourceSet, diff --git a/src/main/java/com/diffplug/gradle/osgi/BndManifestPlugin.java b/src/main/java/com/diffplug/gradle/osgi/BndManifestPlugin.java index e6025879b..b1dea4061 100644 --- a/src/main/java/com/diffplug/gradle/osgi/BndManifestPlugin.java +++ b/src/main/java/com/diffplug/gradle/osgi/BndManifestPlugin.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2022 DiffPlug + * Copyright (C) 2016-2023 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ */ package com.diffplug.gradle.osgi; - import aQute.bnd.osgi.Builder; import aQute.bnd.osgi.Constants; import com.diffplug.common.base.*; @@ -38,7 +37,7 @@ import org.gradle.api.Task; import org.gradle.api.java.archives.Attributes; import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.plugins.JavaPluginConvention; +import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetOutput; import org.gradle.api.tasks.bundling.Jar; @@ -150,8 +149,8 @@ public void execute(Task unused) { } private static Path outputManifest(Jar jarTask) { - JavaPluginConvention javaConvention = jarTask.getProject().getConvention().getPlugin(JavaPluginConvention.class); - SourceSet main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); + JavaPluginExtension javaExtension = jarTask.getProject().getExtensions().getByType(JavaPluginExtension.class); + SourceSet main = javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); return main.getOutput().getResourcesDir().toPath().resolve("META-INF/MANIFEST.MF"); } @@ -188,8 +187,8 @@ private static String takeBndAction(Project project, Jar jarTask, Throwing.Funct builder.addClasspath(runtimeConfig); // put the class files and resources into the jar - JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); - SourceSetOutput main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput(); + JavaPluginExtension javaExtension = project.getExtensions().getByType(JavaPluginExtension.class); + SourceSetOutput main = javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput(); // delete empty folders so that bnd doesn't make Export-Package entries for them Set includeresource = new LinkedHashSet<>(); deleteEmptyFoldersIfExists(main.getResourcesDir());