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

Allow setting environment variables for task execution #215

Closed
lazar-mitrovic opened this issue Feb 22, 2022 · 0 comments · Fixed by #217
Closed

Allow setting environment variables for task execution #215

lazar-mitrovic opened this issue Feb 22, 2022 · 0 comments · Fixed by #217
Assignees
Labels
enhancement New feature or request gradle-plugin Related to Gradle plugin maven-plugin Related to Maven plugin

Comments

@lazar-mitrovic
Copy link
Collaborator

Standard Gradle tasks support injecting environment variables into standard execution tasks like:

test {
    useJUnitPlatform()
    environment "NAME", "VALUE"
}

It would be nice if we supported this (both in Gradle and Maven). IMO one should be able to inject variables for each native binary (e.g. both run and test).

While fixing this we could also tackle #196 as it is relatively similar in scope.

@lazar-mitrovic lazar-mitrovic added enhancement New feature or request gradle-plugin Related to Gradle plugin maven-plugin Related to Maven plugin labels Feb 22, 2022
@melix melix self-assigned this Feb 22, 2022
melix added a commit that referenced this issue Feb 22, 2022
Prior to this commit, it wasn't possible to expose environment variables
(both Maven and Gradle) or system properties (Maven) to the native test
execution. This commit makes it possible to use both.

For Gradle, tests can be configured to use environment variables by
using `tasks.named("nativeTest") { environment.put(...) }`.
For Maven, environment variables and system properties are inherted
from the surefire mojo.

It's worth noting that the executable generated by native-image does
not support @arg files itself. This means that if there are too many
system properties, Windows users could have difficulties running
native tests (because of long CLI issues).

Fixes #215
Fixes #196
melix added a commit that referenced this issue Feb 22, 2022
Prior to this commit, it wasn't possible to expose environment variables
(both Maven and Gradle) or system properties (Maven) to the native test
execution. This commit makes it possible to use both.

For Gradle, tests can be configured to use environment variables by
using `tasks.named("nativeTest") { environment.put(...) }`.
For Maven, environment variables and system properties are inherted
from the surefire mojo.

It's worth noting that the executable generated by native-image does
not support @arg files itself. This means that if there are too many
system properties, Windows users could have difficulties running
native tests (because of long CLI issues).

Fixes #215
Fixes #196
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gradle-plugin Related to Gradle plugin maven-plugin Related to Maven plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants