Skip to content

Commit c897eb0

Browse files
committed
Deprecate the nativeBuild task
1 parent 895922b commit c897eb0

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/DeprecatedExtensionFunctionalTest.groovy

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import org.graalvm.buildtools.gradle.fixtures.AbstractFunctionalTest
4646
class DeprecatedExtensionFunctionalTest extends AbstractFunctionalTest {
4747
def "using a deprecated extension issues a warning"() {
4848
given:
49-
debug = true
5049
buildFile << """
5150
plugins {
5251
id 'application'
@@ -73,4 +72,26 @@ class DeprecatedExtensionFunctionalTest extends AbstractFunctionalTest {
7372
'nativeBuild' | 'main'
7473
'nativeTest' | 'test'
7574
}
75+
76+
def "calling the deprecated nativeBuild task triggers a warning and execution of the native image task"() {
77+
gradleVersion = version
78+
79+
given:
80+
withSample("java-application")
81+
82+
when:
83+
run 'nativeBuild'
84+
85+
then:
86+
tasks {
87+
succeeded ':nativeAssemble'
88+
succeeded ':nativeBuild'
89+
}
90+
91+
and:
92+
outputContains 'Task nativeBuild is deprecated. Use nativeAssemble instead.'
93+
94+
where:
95+
version << TESTED_GRADLE_VERSIONS
96+
}
7697
}

native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/NativeImagePlugin.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ public class NativeImagePlugin implements Plugin<Project> {
118118

119119
public static final String DEPRECATED_NATIVE_BUILD_EXTENSION = "nativeBuild";
120120
public static final String DEPRECATED_NATIVE_TEST_EXTENSION = "nativeTest";
121+
public static final String DEPRECATED_NATIVE_BUILD_TASK = "nativeBuild";
122+
public static final String DEPRECATED_NATIVE_TEST_BUILD_TASK = "nativeTestBuild";
121123

122124
/**
123125
* This looks strange, but it is used to force the configuration of a dependent
@@ -174,6 +176,10 @@ private void configureJavaProject(Project project, Provider<NativeImageService>
174176
builder.getOptions().convention(mainOptions);
175177
builder.getAgentEnabled().set(agent);
176178
});
179+
TaskProvider<Task> deprecatedTask = tasks.register(DEPRECATED_NATIVE_BUILD_TASK, t -> {
180+
t.dependsOn(imageBuilder);
181+
t.doFirst("Warn about deprecation", task -> task.getLogger().warn("Task " + DEPRECATED_NATIVE_BUILD_TASK + " is deprecated. Use " + NATIVE_ASSEMBLE_TASK_NAME + " instead."));
182+
});
177183
tasks.register(NativeRunTask.TASK_NAME, NativeRunTask.class, task -> {
178184
task.getImage().convention(imageBuilder.map(t -> t.getOutputFile().get()));
179185
task.getRuntimeArgs().convention(mainOptions.getRuntimeArgs());
@@ -249,6 +255,10 @@ private void configureJavaProject(Project project, Provider<NativeImageService>
249255
testOptions.getClasspath().from(testList);
250256
task.getAgentEnabled().set(testAgent);
251257
});
258+
tasks.register(DEPRECATED_NATIVE_TEST_BUILD_TASK, t -> {
259+
t.dependsOn(imageBuilder);
260+
t.doFirst("Warn about deprecation", task -> task.getLogger().warn("Task " + DEPRECATED_NATIVE_TEST_BUILD_TASK + " is deprecated. Use " + NATIVE_TEST_ASSEMBLE_TASK_NAME + " instead."));
261+
});
252262
configureClasspathJarFor(tasks, testOptions, testImageBuilder);
253263

254264
tasks.register(NATIVE_TEST_TASK_NAME, NativeRunTask.class, task -> {

0 commit comments

Comments
 (0)