Skip to content

Commit 1cc5224

Browse files
selhaganielkorchi
authored andcommitted
[GR-59670] Backport to 24.1: Graalpy gradle plugin does not build if project does not contain any resource files.
PullRequest: graalpython/3580
2 parents 370f56b + 8aca458 commit 1cc5224

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

graalpython/com.oracle.graal.python.test/src/tests/standalone/test_standalone.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def test_gradle_generated_app_external_resources(self):
288288
os.makedirs(src_dir, exist_ok=True)
289289
# copy hello.py
290290
shutil.copyfile(os.path.join(target_dir, "src", "main", "resources", "org.graalvm.python.vfs", "src", "hello.py"), os.path.join(src_dir, "hello.py"))
291-
shutil.rmtree(os.path.join(target_dir, "src", "main", "resources", "org.graalvm.python.vfs"))
291+
# remove all resources, we also want to check if the gradle plugin can deal with no user resources
292+
shutil.rmtree(os.path.join(target_dir, "src", "main", "resources"))
292293
# patch GraalPy.java
293294
replace_in_file(os.path.join(target_dir, "src", "main", "java", "org", "example", "GraalPy.java"),
294295
"package org.example;",
@@ -307,6 +308,16 @@ def test_gradle_generated_app_external_resources(self):
307308
out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir, gradle = True)
308309
util.check_ouput("BUILD SUCCESS", out)
309310

311+
# check java exec
312+
cmd = gradle_cmd + ["run"]
313+
out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir, gradle = True)
314+
util.check_ouput("hello java", out)
315+
316+
# prepare for native build
317+
meta_inf = os.path.join(target_dir, "src", "main", "resources", "META-INF", "native-image")
318+
os.makedirs(meta_inf, exist_ok=True)
319+
shutil.copyfile(os.path.join(self.test_prj_path, "src", "main", "resources", "META-INF", "native-image", "proxy-config.json"), os.path.join(meta_inf, "proxy-config.json"))
320+
310321
# gradle needs jdk <= 22, but it looks like the 'gradle nativeCompile' cmd does not complain if higher,
311322
# which is fine, because we need to build the native binary with a graalvm build
312323
# and the one we have set in JAVA_HOME is at least jdk24
@@ -320,12 +331,6 @@ def test_gradle_generated_app_external_resources(self):
320331
out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir)
321332
util.check_ouput("hello java", out)
322333

323-
# 2.) check java build and exec
324-
cmd = gradle_cmd + ["run"]
325-
out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir, gradle = True)
326-
util.check_ouput("BUILD SUCCESS", out)
327-
util.check_ouput("hello java", out)
328-
329334
@unittest.skipUnless(is_gradle_enabled, "ENABLE_GRADLE_STANDALONE_UNITTESTS is not true")
330335
def test_gradle_fail_without_graalpy_dep(self):
331336
with tempfile.TemporaryDirectory() as tmpdir:

graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/VFSFilesListTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.gradle.api.DefaultTask;
4545
import org.gradle.api.GradleScriptException;
4646
import org.gradle.api.provider.Property;
47-
import org.gradle.api.tasks.InputDirectory;
47+
import org.gradle.api.tasks.InputFiles;
4848
import org.gradle.api.tasks.TaskAction;
4949

5050
import java.io.File;
@@ -56,7 +56,7 @@
5656

5757
public abstract class VFSFilesListTask extends DefaultTask {
5858

59-
@InputDirectory
59+
@InputFiles
6060
public abstract Property<File> getResourcesDir();
6161

6262
@TaskAction

0 commit comments

Comments
 (0)