Skip to content

Commit

Permalink
Fix gradle project convention deprecation
Browse files Browse the repository at this point in the history
* this is deprecated since gradle 7.1 and will be removed with gradle 9
  • Loading branch information
patrick-dedication committed Nov 29, 2024
1 parent 4aff4f6 commit cf1697f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/org/sonarqube/gradle/SonarPropertyComputer.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.reporting.Report;
Expand Down Expand Up @@ -430,15 +431,15 @@ private static void configureTestReports(Test testTask, Map<String, Object> prop
}

private static void configureSourceDirsAndJavaClasspath(Project project, Map<String, Object> properties, boolean addForGroovy) {
JavaPluginConvention javaPluginConvention = new DslObject(project).getConvention().getPlugin(JavaPluginConvention.class);
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);

SourceSet main = javaPluginConvention.getSourceSets().getAt("main");
SourceSet main = javaPluginExtension.getSourceSets().getAt("main");
Collection<File> sourceDirectories = getJavaSourceFiles(main);
if (sourceDirectories != null) {
SonarUtils.appendSourcesProp(properties, sourceDirectories, false);
}

SourceSet test = javaPluginConvention.getSourceSets().getAt("test");
SourceSet test = javaPluginExtension.getSourceSets().getAt("test");
Collection<File> testDirectories = getJavaSourceFiles(test);
if (testDirectories != null) {
SonarUtils.appendSourcesProp(properties, testDirectories, true);
Expand All @@ -453,14 +454,14 @@ private static void configureSourceDirsAndJavaClasspath(Project project, Map<Str
}

private static void configureJavaClasspath(Project project, Map<String, Object> properties, boolean addForGroovy) {
JavaPluginConvention javaPluginConvention = new DslObject(project).getConvention().getPlugin(JavaPluginConvention.class);
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);

SourceSet main = javaPluginConvention.getSourceSets().getAt("main");
SourceSet main = javaPluginExtension.getSourceSets().getAt("main");
Collection<File> mainClassDirs = getJavaOutputDirs(main);
Collection<File> mainLibraries = getJavaLibraries(main);
setMainClasspathProps(properties, mainClassDirs, mainLibraries, addForGroovy);

SourceSet test = javaPluginConvention.getSourceSets().getAt("test");
SourceSet test = javaPluginExtension.getSourceSets().getAt("test");
Collection<File> testClassDirs = getJavaOutputDirs(test);
Collection<File> testLibraries = getJavaLibraries(test);
setTestClasspathProps(properties, testClassDirs, testLibraries);
Expand Down

0 comments on commit cf1697f

Please sign in to comment.