Skip to content

Commit

Permalink
Remove deprecated use of getConvention (#522)
Browse files Browse the repository at this point in the history
* Remove deprecated use of `getConvention`

* Fix compile error
  • Loading branch information
melix authored Oct 11, 2023
1 parent de9ffd9 commit 9a05c6d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ If you are using alternative build systems, see <<alternative-build-systems.adoc
* Update JUnit configuration for native testing on GraalVM for JDK 21 with `--strict-image-heap` mode.
* Fix path escaping problem for Windows users

==== Gradle plugin

- Remove use of deprecated `getConvention` APIs

=== Release 0.9.26

* Relax GraalVM version check for dev versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
import org.gradle.api.plugins.JavaApplication;
import org.gradle.api.plugins.JavaLibraryPlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
Expand Down Expand Up @@ -259,7 +259,7 @@ private void configureJavaProject(Project project, Provider<NativeImageService>

// Register Native Image tasks
TaskContainer tasks = project.getTasks();
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
JavaPluginExtension javaConvention = project.getExtensions().getByType(JavaPluginExtension.class);
configureAutomaticTaskCreation(project, graalExtension, tasks, javaConvention.getSourceSets());

TaskProvider<BuildNativeImageTask> imageBuilder = tasks.named(NATIVE_COMPILE_TASK_NAME, BuildNativeImageTask.class);
Expand Down Expand Up @@ -624,16 +624,15 @@ public void registerTestBinary(Project project,

// Testing part begins here. -------------------------------------------

// In future Gradle releases this becomes a proper DirectoryProperty
File testResultsDir = GradleUtils.getJavaPluginConvention(project).getTestResultsDir();
DirectoryProperty testResultsDir = GradleUtils.getJavaPluginConvention(project).getTestResultsDir();
DirectoryProperty testListDirectory = project.getObjects().directoryProperty();

// Add DSL extension for testing
NativeImageOptions testOptions = createTestOptions(graalExtension, name, project, mainOptions, config.getSourceSet());

TaskProvider<Test> testTask = config.validate().getTestTask();
testTask.configure(test -> {
File testList = new File(testResultsDir, test.getName() + "/testlist");
var testList = testResultsDir.dir(test.getName() + "/testlist");
testListDirectory.set(testList);
test.getOutputs().dir(testList);
// Set system property read by the UniqueIdTrackingListener.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileCollection;
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.SourceSetContainer;
import org.gradle.util.GradleVersion;
Expand All @@ -64,8 +64,8 @@ public static SourceSet findSourceSet(Project project, String sourceSetName) {
return sourceSetContainer.findByName(sourceSetName);
}

public static JavaPluginConvention getJavaPluginConvention(Project project) {
return project.getConvention().getPlugin(JavaPluginConvention.class);
public static JavaPluginExtension getJavaPluginConvention(Project project) {
return project.getExtensions().getByType(JavaPluginExtension.class);
}


Expand Down

0 comments on commit 9a05c6d

Please sign in to comment.