From 7fbb2f3369eb264b31d1f78495f97317df3ab13a Mon Sep 17 00:00:00 2001 From: Konstantin Gribov Date: Fri, 22 Apr 2022 07:50:55 +0300 Subject: [PATCH] Use SourceSetContainer and lazy APIs in Gradle plugins Signed-off-by: Konstantin Gribov --- .../java/io/quarkus/gradle/QuarkusPlugin.java | 45 ++++++------- .../gradle/tasks/QuarkusGenerateCode.java | 67 +++++++++---------- .../gradle/tasks/QuarkusGradleUtils.java | 12 ++-- .../gradle/QuarkusExtensionPlugin.java | 10 +-- .../GradleApplicationModelBuilder.java | 43 ++++++------ .../tooling/dependency/DependencyUtils.java | 10 +-- 6 files changed, 89 insertions(+), 98 deletions(-) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java index 8a42717850df9..398111194bfb8 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java @@ -4,7 +4,6 @@ import java.nio.file.Path; import java.util.HashSet; import java.util.Set; -import java.util.function.Consumer; import java.util.stream.Collectors; import javax.inject.Inject; @@ -21,7 +20,6 @@ import org.gradle.api.artifacts.ProjectDependency; import org.gradle.api.plugins.BasePlugin; import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.TaskContainer; @@ -166,24 +164,9 @@ private void registerTasks(Project project, QuarkusPluginExtension quarkusExt) { configureBuildNativeTask(project); - final Consumer configureTestTask = t -> { - // Quarkus test configuration action which should be executed before any Quarkus test - // Use anonymous classes in order to leverage task avoidance. - t.doFirst(new Action() { - @Override - public void execute(Task test) { - quarkusExt.beforeTest(t); - } - }); - // also make each task use the JUnit platform since it's the only supported test environment - t.useJUnitPlatform(); - // quarkusBuild is expected to run after the project has passed the tests - quarkusBuild.configure(task -> task.shouldRunAfter(t)); - }; - project.getPlugins().withType( BasePlugin.class, - basePlugin -> tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn(quarkusBuild)); + basePlugin -> tasks.named(BasePlugin.ASSEMBLE_TASK_NAME, task -> task.dependsOn(quarkusBuild))); project.getPlugins().withType( JavaPlugin.class, javaPlugin -> { @@ -245,8 +228,7 @@ public void execute(Task test) { quarkusBuild.configure( task -> task.dependsOn(classesTask, resourcesTask, tasks.named(JavaPlugin.JAR_TASK_NAME))); - SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class) - .getSourceSets(); + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME); @@ -295,8 +277,20 @@ public void execute(Task test) { testNative.setClasspath(nativeTestSourceSet.getRuntimeClasspath()); }); - tasks.withType(Test.class).forEach(configureTestTask); - tasks.withType(Test.class).whenTaskAdded(configureTestTask::accept); + tasks.withType(Test.class).configureEach(t -> { + // Quarkus test configuration action which should be executed before any Quarkus test + // Use anonymous classes in order to leverage task avoidance. + t.doFirst(new Action() { + @Override + public void execute(Task task) { + quarkusExt.beforeTest(t); + } + }); + // also make each task use the JUnit platform since it's the only supported test environment + t.useJUnitPlatform(); + }); + // quarkusBuild is expected to run after the project has passed the tests + quarkusBuild.configure(task -> task.shouldRunAfter(tasks.withType(Test.class))); SourceSet generatedSourceSet = sourceSets.create(QuarkusGenerateCode.QUARKUS_GENERATED_SOURCES); SourceSet generatedTestSourceSet = sourceSets.create(QuarkusGenerateCode.QUARKUS_TEST_GENERATED_SOURCES); @@ -384,8 +378,7 @@ private void afterEvaluate(Project project) { .sourceSetExtension(); if (sourceSetExtension.extraNativeTest() != null) { - SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class) - .getSourceSets(); + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); SourceSet nativeTestSourceSets = sourceSets.getByName(NATIVE_TEST_SOURCE_SET_NAME); nativeTestSourceSets.setCompileClasspath( nativeTestSourceSets.getCompileClasspath() @@ -396,9 +389,9 @@ private void afterEvaluate(Project project) { .plus(sourceSets.getByName(INTEGRATION_TEST_SOURCE_SET_NAME).getOutput()) .plus(sourceSetExtension.extraNativeTest().getOutput())); - configurations.findByName(NATIVE_TEST_IMPLEMENTATION_CONFIGURATION_NAME).extendsFrom( + configurations.getByName(NATIVE_TEST_IMPLEMENTATION_CONFIGURATION_NAME).extendsFrom( configurations.findByName(sourceSetExtension.extraNativeTest().getImplementationConfigurationName())); - configurations.findByName(NATIVE_TEST_RUNTIME_ONLY_CONFIGURATION_NAME).extendsFrom( + configurations.getByName(NATIVE_TEST_RUNTIME_ONLY_CONFIGURATION_NAME).extendsFrom( configurations.findByName(sourceSetExtension.extraNativeTest().getRuntimeOnlyConfigurationName())); } } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java index 8a3889f0424f0..e0c1ed989c64e 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java @@ -16,11 +16,11 @@ import org.gradle.api.GradleException; import org.gradle.api.artifacts.Configuration; -import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.tasks.CompileClasspath; import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.TaskAction; import io.quarkus.bootstrap.BootstrapException; @@ -108,42 +108,39 @@ public void prepareQuarkus() { .setIsolateDeployment(true) .build().bootstrap()) { - final JavaPluginConvention javaConvention = getProject().getConvention().findPlugin(JavaPluginConvention.class); - if (javaConvention != null) { - final String generateSourcesDir = test ? QUARKUS_TEST_GENERATED_SOURCES : QUARKUS_GENERATED_SOURCES; - final SourceSet generatedSources = javaConvention.getSourceSets().findByName(generateSourcesDir); - List paths = new ArrayList<>(); - generatedSources.getOutput() - .filter(f -> f.getName().equals(generateSourcesDir)) - .forEach(f -> paths.add(f.toPath())); - if (paths.isEmpty()) { - throw new GradleException("Failed to create quarkus-generated-sources"); - } - - getLogger().debug("Will trigger preparing sources for source directory: {} buildDir: {}", - sourcesDirectories, getProject().getBuildDir().getAbsolutePath()); - - QuarkusClassLoader deploymentClassLoader = appCreationContext.createDeploymentClassLoader(); - Class codeGenerator = deploymentClassLoader.loadClass(CodeGenerator.class.getName()); - - Optional initAndRun = Arrays.stream(codeGenerator.getMethods()) - .filter(m -> m.getName().equals(INIT_AND_RUN)) - .findAny(); - if (initAndRun.isEmpty()) { - throw new GradleException("Failed to find " + INIT_AND_RUN + " method in " + CodeGenerator.class.getName()); - } - - initAndRun.get().invoke(null, deploymentClassLoader, - PathList.from(sourcesDirectories), - paths.get(0), - buildDir, - sourceRegistrar, - appCreationContext.getApplicationModel(), - realProperties, - launchMode.name(), - test); + SourceSetContainer sourceSets = getProject().getExtensions().getByType(SourceSetContainer.class); + final String generateSourcesDir = test ? QUARKUS_TEST_GENERATED_SOURCES : QUARKUS_GENERATED_SOURCES; + final SourceSet generatedSources = sourceSets.getByName(generateSourcesDir); + List paths = new ArrayList<>(); + generatedSources.getOutput() + .filter(f -> f.getName().equals(generateSourcesDir)) + .forEach(f -> paths.add(f.toPath())); + if (paths.isEmpty()) { + throw new GradleException("Failed to create quarkus-generated-sources"); + } + + getLogger().debug("Will trigger preparing sources for source directory: {} buildDir: {}", + sourcesDirectories, getProject().getBuildDir().getAbsolutePath()); + QuarkusClassLoader deploymentClassLoader = appCreationContext.createDeploymentClassLoader(); + Class codeGenerator = deploymentClassLoader.loadClass(CodeGenerator.class.getName()); + + Optional initAndRun = Arrays.stream(codeGenerator.getMethods()) + .filter(m -> m.getName().equals(INIT_AND_RUN)) + .findAny(); + if (initAndRun.isEmpty()) { + throw new GradleException("Failed to find " + INIT_AND_RUN + " method in " + CodeGenerator.class.getName()); } + + initAndRun.get().invoke(null, deploymentClassLoader, + PathList.from(sourcesDirectories), + paths.get(0), + buildDir, + sourceRegistrar, + appCreationContext.getApplicationModel(), + realProperties, + launchMode.name(), + test); } catch (BootstrapException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e) { throw new GradleException("Failed to generate sources in the QuarkusPrepare task", e); } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGradleUtils.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGradleUtils.java index c180773de6c51..fc38292cf7498 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGradleUtils.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGradleUtils.java @@ -12,8 +12,8 @@ import org.gradle.api.Project; import org.gradle.api.file.FileCollection; -import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.SourceSetContainer; import io.quarkus.bootstrap.util.IoUtils; @@ -21,12 +21,12 @@ public class QuarkusGradleUtils { private static final String ERROR_COLLECTING_PROJECT_CLASSES = "Failed to collect project's classes in a temporary dir"; + public static SourceSetContainer getSourceSets(Project project) { + return project.getExtensions().getByType(SourceSetContainer.class); + } + public static SourceSet getSourceSet(Project project, String sourceSetName) { - final JavaPluginConvention javaConvention = project.getConvention().findPlugin(JavaPluginConvention.class); - if (javaConvention == null) { - throw new IllegalArgumentException("The project does not include the Java plugin"); - } - return javaConvention.getSourceSets().getByName(sourceSetName); + return getSourceSets(project).getByName(sourceSetName); } public static String getClassesDir(SourceSet sourceSet, File tmpDir, boolean test) { diff --git a/devtools/gradle/gradle-extension-plugin/src/main/java/io/quarkus/extension/gradle/QuarkusExtensionPlugin.java b/devtools/gradle/gradle-extension-plugin/src/main/java/io/quarkus/extension/gradle/QuarkusExtensionPlugin.java index 9c0d267119c66..28353026924ee 100644 --- a/devtools/gradle/gradle-extension-plugin/src/main/java/io/quarkus/extension/gradle/QuarkusExtensionPlugin.java +++ b/devtools/gradle/gradle-extension-plugin/src/main/java/io/quarkus/extension/gradle/QuarkusExtensionPlugin.java @@ -12,8 +12,8 @@ import org.gradle.api.artifacts.ModuleVersionIdentifier; import org.gradle.api.artifacts.ResolvedArtifact; import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.TaskContainer; import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.testing.Test; @@ -49,8 +49,8 @@ public void apply(Project project) { private void registerTasks(Project project, QuarkusExtensionConfiguration quarkusExt) { TaskContainer tasks = project.getTasks(); - JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class); - SourceSet mainSourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); + SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); Configuration runtimeModuleClasspath = project.getConfigurations() .getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME); @@ -65,7 +65,7 @@ private void registerTasks(Project project, QuarkusExtensionConfiguration quarku javaPlugin -> { tasks.named(JavaPlugin.PROCESS_RESOURCES_TASK_NAME, task -> task.finalizedBy(extensionDescriptorTask)); tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, task -> task.dependsOn(extensionDescriptorTask)); - tasks.withType(Test.class, test -> test.useJUnitPlatform()); + tasks.withType(Test.class).configureEach(Test::useJUnitPlatform); addAnnotationProcessorDependency(project); }); @@ -84,7 +84,7 @@ private void registerTasks(Project project, QuarkusExtensionConfiguration quarku task.setDeploymentModuleClasspath(deploymentModuleClasspath); }); - deploymentProject.getTasks().withType(Test.class, test -> { + deploymentProject.getTasks().withType(Test.class).configureEach(test -> { test.useJUnitPlatform(); test.doFirst(task -> { final Map props = test.getSystemProperties(); diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java index 967fdf7d48ab8..70beafce4e434 100644 --- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java +++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java @@ -12,6 +12,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Properties; import java.util.Set; @@ -24,8 +25,8 @@ import org.gradle.api.file.FileCollection; import org.gradle.api.file.FileTree; import org.gradle.api.initialization.IncludedBuild; -import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.compile.AbstractCompile; import org.gradle.language.jvm.tasks.ProcessResources; import org.gradle.tooling.provider.model.ParameterizedToolingModelBuilder; @@ -124,20 +125,17 @@ public static ResolvedDependency getProjectArtifact(Project project, boolean wor .setArtifactId(project.getName()) .setVersion(project.getVersion().toString()); - final JavaPluginConvention javaConvention = project.getConvention().findPlugin(JavaPluginConvention.class); - if (javaConvention == null) { - throw new GradleException("Failed to locate Java plugin extension in " + project.getPath()); - } + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); final WorkspaceModule.Mutable mainModule = WorkspaceModule.builder() .setModuleId(new GAV(appArtifact.getGroupId(), appArtifact.getArtifactId(), appArtifact.getVersion())) .setModuleDir(project.getProjectDir().toPath()) .setBuildDir(project.getBuildDir().toPath()) .setBuildFile(project.getBuildFile().toPath()); - initProjectModule(project, mainModule, javaConvention.getSourceSets().findByName(SourceSet.MAIN_SOURCE_SET_NAME), + initProjectModule(project, mainModule, sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME), SourceSet.MAIN_SOURCE_SET_NAME, ArtifactSources.MAIN); if (workspaceDiscovery) { - initProjectModule(project, mainModule, javaConvention.getSourceSets().findByName(SourceSet.TEST_SOURCE_SET_NAME), + initProjectModule(project, mainModule, sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME), SourceSet.TEST_SOURCE_SET_NAME, ArtifactSources.TEST); } @@ -167,11 +165,13 @@ private void collectExtensionDependencies(Project project, Configuration deploym final ResolvedConfiguration rc = deploymentConfiguration.getResolvedConfiguration(); for (ResolvedArtifact a : rc.getResolvedArtifacts()) { if (a.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) { - final Project projectDep = project.getRootProject().findProject( - ((ProjectComponentIdentifier) a.getId().getComponentIdentifier()).getProjectPath()); - final JavaPluginConvention javaExtension = projectDep == null ? null - : projectDep.getConvention().findPlugin(JavaPluginConvention.class); - SourceSet mainSourceSet = javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); + ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) a.getId() + .getComponentIdentifier(); + final Project projectDep = project.getRootProject().findProject(projectComponentIdentifier.getProjectPath()); + Objects.requireNonNull(projectDep, "project " + projectComponentIdentifier.getProjectPath() + " should exist"); + SourceSetContainer sourceSets = projectDep.getExtensions().getByType(SourceSetContainer.class); + + SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); ResolvedDependencyBuilder dep = modelBuilder.getDependency( toAppDependenciesKey(a.getModuleVersion().getId().getGroup(), a.getName(), a.getClassifier())); if (dep == null) { @@ -276,8 +276,8 @@ private void collectDependencies(org.gradle.api.artifacts.ResolvedDependency res final Project projectDep = project.getRootProject().findProject( ((ProjectComponentIdentifier) a.getId().getComponentIdentifier()).getProjectPath()); - final JavaPluginConvention javaExtension = projectDep == null ? null - : projectDep.getConvention().findPlugin(JavaPluginConvention.class); + SourceSetContainer sourceSets = projectDep == null ? null + : projectDep.getExtensions().findByType(SourceSetContainer.class); final String classifier = a.getClassifier(); if (classifier == null || classifier.isEmpty()) { @@ -286,22 +286,22 @@ private void collectDependencies(org.gradle.api.artifacts.ResolvedDependency res final PathList.Builder pathBuilder = PathList.builder(); addSubstitutedProject(pathBuilder, includedBuild.getProjectDir()); paths = pathBuilder.build(); - } else if (javaExtension != null) { + } else if (sourceSets != null) { final PathList.Builder pathBuilder = PathList.builder(); projectModule = initProjectModuleAndBuildPaths(projectDep, a, modelBuilder, depBuilder, - javaExtension, pathBuilder, SourceSet.MAIN_SOURCE_SET_NAME, false); + pathBuilder, SourceSet.MAIN_SOURCE_SET_NAME, false); paths = pathBuilder.build(); } - } else if (javaExtension != null) { + } else if (sourceSets != null) { if ("test".equals(classifier)) { final PathList.Builder pathBuilder = PathList.builder(); projectModule = initProjectModuleAndBuildPaths(projectDep, a, modelBuilder, depBuilder, - javaExtension, pathBuilder, SourceSet.TEST_SOURCE_SET_NAME, true); + pathBuilder, SourceSet.TEST_SOURCE_SET_NAME, true); paths = pathBuilder.build(); } else if ("test-fixtures".equals(classifier)) { final PathList.Builder pathBuilder = PathList.builder(); projectModule = initProjectModuleAndBuildPaths(projectDep, a, modelBuilder, depBuilder, - javaExtension, pathBuilder, "testFixtures", true); + pathBuilder, "testFixtures", true); paths = pathBuilder.build(); } } @@ -341,7 +341,7 @@ private static String toNonNullClassifier(String resolvedClassifier) { private WorkspaceModule.Mutable initProjectModuleAndBuildPaths(final Project project, ResolvedArtifact resolvedArtifact, ApplicationModelBuilder appModel, final ResolvedDependencyBuilder appDep, - final JavaPluginConvention javaExt, PathList.Builder buildPaths, String sourceName, boolean test) { + PathList.Builder buildPaths, String sourceName, boolean test) { appDep.setWorkspaceModule().setReloadable(); @@ -353,7 +353,8 @@ private WorkspaceModule.Mutable initProjectModuleAndBuildPaths(final Project pro .setBuildFile(project.getBuildFile().toPath()); final String classifier = toNonNullClassifier(resolvedArtifact.getClassifier()); - initProjectModule(project, projectModule, javaExt.getSourceSets().findByName(sourceName), sourceName, classifier); + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); + initProjectModule(project, projectModule, sourceSets.findByName(sourceName), sourceName, classifier); collectDestinationDirs(projectModule.getSources(classifier).getSourceDirs(), buildPaths); collectDestinationDirs(projectModule.getSources(classifier).getResourceDirs(), buildPaths); diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java index c643889fe82cf..5d0f37b1793e3 100644 --- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java +++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java @@ -22,8 +22,8 @@ import org.gradle.api.artifacts.component.ProjectComponentIdentifier; import org.gradle.api.artifacts.dsl.DependencyHandler; import org.gradle.api.capabilities.Capability; -import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.SourceSetContainer; import io.quarkus.bootstrap.BootstrapConstants; import io.quarkus.bootstrap.util.BootstrapUtils; @@ -80,10 +80,10 @@ public static ExtensionDependency getExtensionInfoOrNull(Project project, Resolv if (artifact.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) { final Project projectDep = project.getRootProject().findProject( ((ProjectComponentIdentifier) artifact.getId().getComponentIdentifier()).getProjectPath()); - final JavaPluginConvention javaExtension = projectDep == null ? null - : projectDep.getConvention().findPlugin(JavaPluginConvention.class); - if (javaExtension != null) { - SourceSet mainSourceSet = javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); + SourceSetContainer sourceSets = projectDep == null ? null + : projectDep.getExtensions().findByType(SourceSetContainer.class); + if (sourceSets != null) { + SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); File resourcesDir = mainSourceSet.getOutput().getResourcesDir(); Path descriptorPath = resourcesDir.toPath().resolve(BootstrapConstants.DESCRIPTOR_PATH); if (Files.exists(descriptorPath)) {