Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native-image] Add -H:ExcludeResources option #2347

Closed
ppalaga opened this issue Apr 15, 2020 · 3 comments
Closed

[native-image] Add -H:ExcludeResources option #2347

ppalaga opened this issue Apr 15, 2020 · 3 comments

Comments

@ppalaga
Copy link

ppalaga commented Apr 15, 2020

Feature request

native-image currently supports the -H:IncludeResources and -H:ResourceConfigurationFiles options documented in RESOURCES.md
These options allow to include resources via one or more regular expressions.

I'd like to propose to add a way to restrict the selected set via excludes.

Excludes is a list of regular expressions. With excludes in place, a resource is selected for inclusion if and only if its path matches some of the include patterns and it does not match any of the exclude patterns.

What problem is this solving:
Say I have many resources in my source tree and I want to include some subdirectories except for some filetypes. With excludes in place, I could pass something like

-H:IncludeResources=foo/.* -H:IncludeResources=bar/.* -H:IncludeResources=baz/.* -H:ExcludeResources=*.\.png -H:ExcludeResources=*.\.jpg -H:ExcludeResources=*.\.gif

Without excludes, I'd have to somehow hack everything into one expression using some negative lookaheads and alternations. I am not sure myself something like that is even possible.

Describe the solution you'd like.

I am primarily interested in getting -H:ExcludeResources. I have not thought of how excludes could be supported by -H:ResourceConfigurationFiles.

Describe who do you think will benefit the most.
GraalVM users, and developers of libraries and frameworks which depend on GraalVM

Describe alternatives you've considered.
Have a tool that scans the source tree, evaluates the includes and excludes and passes the selected paths one by one to native-image. We actually have something like that in Camel Quarkus: https://github.com/apache/camel-quarkus/pull/960/files but I believe a generic option like that belongs to native-image itself.

Express whether you'd like to help contributing this feature
I can try if there is no better candidate.

@ppalaga
Copy link
Author

ppalaga commented May 4, 2020

Is this idea worth pursuing? I'd have a look how to implement this but it feels risky as long as there is no explicit approval.

@pgillet
Copy link
Contributor

pgillet commented Oct 11, 2020

I gave it a shot anyway. Please see #2912 .

@ppalaga
Copy link
Author

ppalaga commented Nov 20, 2020

Thanks @pgillet, -H:ExcludeResources option is now documented in https://www.graalvm.org/reference-manual/native-image/Resources/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants