-
Notifications
You must be signed in to change notification settings - Fork 28
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
Enable to use java preview while executing built jar file. #893
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one thing I don't understand - if we only enable preview feature with system properties, how are tests going to pass if the feature is not enabled. I suppose your main objective is https://github.com/quarkus-qe/quarkus-jdkspecifics/tree/main ? I wonder if it is really desirable to add preview specific tests, we have enough on our plate with testing of what is actually in JDK. If this is only for your personal testing, can't you instead execute it manually, e.g. package and then run it as any other app?
It's possible I'm missing something, please let me know.
Update: I saw quarkus-qe/quarkus-jdkspecifics#99 (comment), so I'll leave review on someone else.
@@ -25,6 +25,9 @@ protected List<String> prepareCommand(List<String> systemProperties) { | |||
String[] cmdArgs = extractQuarkusArgs(systemProperties); | |||
if (model.getArtifact().getFileName().toString().endsWith(".jar")) { | |||
command.add(JAVA); | |||
if (isEnabledPreview()) { | |||
command.add("--enable-preview"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls make --enable-preview
constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -51,4 +54,14 @@ private String[] extractQuarkusArgs(List<String> systemProperties) { | |||
|
|||
return args; | |||
} | |||
|
|||
private boolean isEnabledPreview() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method can be static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed as I using the PropertyLookup
so this method is no longer needed
@@ -51,4 +54,14 @@ private String[] extractQuarkusArgs(List<String> systemProperties) { | |||
|
|||
return args; | |||
} | |||
|
|||
private boolean isEnabledPreview() { | |||
String enablePreviewString = System.getProperty("--enable-preview"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong opinion here, but if this is something specific for this framework. it should be framework config property. Therefore instead of -D--enable-preview
create property like ts.enable-java-preview-features
(please name it yourself) and use PropertyLookup
and document it when this get merged in Wiki.
Let's here from others though, this is just my preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for something like ts.enable-java-preview-features
instead of -D--enable-preview
Should be documented in https://github.com/quarkus-qe/quarkus-test-framework/wiki/2.-Configuration once merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I play with it little and change it to the framework property.
I can see you two agreed on preview quarkus-qe/quarkus-jdkspecifics#99 (comment), so I take it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature is specific for baremetal use case in prod mode / when application is started using java -jar
.
It's OK-ish, we do not have a need for this in Kube/OpenShift environment or CLI / DEV mode at this moment.
We could consider more generic approach to allow definition of java command arguments, but could be a bit problematic for Kube/OpenShift and dev mode.
@@ -51,4 +54,14 @@ private String[] extractQuarkusArgs(List<String> systemProperties) { | |||
|
|||
return args; | |||
} | |||
|
|||
private boolean isEnabledPreview() { | |||
String enablePreviewString = System.getProperty("--enable-preview"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for something like ts.enable-java-preview-features
instead of -D--enable-preview
Should be documented in https://github.com/quarkus-qe/quarkus-test-framework/wiki/2.-Configuration once merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I agree with points made by @rsvoboda . I don't mind having it here, but maybe a more general approach could be used.
0ecf282
to
7849419
Compare
I play with this a little. At first I was thought that without Generally as this probably only quarkus-qe use case the framework property is better, but as just user who can possibly run it everywhere I would prefer |
I'll leave review to others as said, but if you want something propagated to all usecase/environments, can't you use
|
Basically yes in jdk-specific |
Summary
Hi, this PR adding option run built jar with preview argument. This can be useful when someone trying the JEPs which are marked as preview. What I tried when using framework with quarkus dev mode it pass the property
-D--enable-preview
but when using standard mode the property is not picked so jar failing to execute.Running
mvn -B -fae clean install -Pframework,examples -Dvalidate-format -Dquarkus.platform.version="999-SNAPSHOT" -pl examples/database-mysql -D--enable-preview
Before this PR result in produced command
java -D<some Quarkus properties> -jar quarkus-test-framework/examples/database-mysql/target/quarkus-app/quarkus-run.jar
After this PR result in produced command
java --enable-preview -D<some Quarkus properties> -jar quarkus-test-framework/examples/database-mysql/target/quarkus-app/quarkus-run.jar
Please check the relevant options
run tests
phrase in comment)Checklist: