-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Command mode support #7681
Command mode support #7681
Conversation
5d98d3d
to
980a43c
Compare
related to #5656 |
3415835
to
62e90e0
Compare
fb75cc5
to
8adf3ea
Compare
8adf3ea
to
cb6a77e
Compare
context.getClassesRoots().add(appClassesFile); | ||
|
||
//TODO: huge hacks | ||
File src = new File(appClassesFile, "../../src/main/java"); |
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.
good enough to start, but I reckon just doing a recursive search for nearest pom.xml/build.gradle and resolve source paths from there (still just via filesystem not parsing the build files) could make this a bit less hacky.
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.
Also this would fail on windows because of the delimiters, or?
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.
Forward slash is also a delimiter on windows.
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.
That's good to know, I always thought it's only \
on windows... ;-)
1815bbb
to
f33bead
Compare
Update: never mind, my mistake; I was looking at the master branch instead of the command-mode branch... |
I have trouble building the project from the command-mode branch:
|
@remkop Try |
I love the command mode, I really do! But I find it awkward that I have to add the For example, if I do:
then I get the desired command line application that runs an exits (whether I run from the IDE or just run the jar). Perhaps my concern is unfounded and users won't make this mistake..., I don't know :) |
Thank you @geoand, that worked. @stuartwdouglas I did build the docs, and found 3 broken links in index.adoc: instead of linking to
Still looking... |
I cannot get my app to run on Windows... I get the below error.
Steps to reproduce: First, create a project like this:
Add a dependency on picocli to the pom.xml:
Create a command class: package org.acme.getting.started;
import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.DefaultMain;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import java.util.concurrent.Callable;
@DefaultMain
@Command(name = "topcmd", mixinStandardHelpOptions = true, version = "@|green 1.0.0|@",
description = "this is the description")
public class ToplevelCommand implements Callable<Integer>, QuarkusApplication {
@Override
public Integer call() throws Exception {
System.out.println("Hi from ToplevelCmd...");
return 123;
}
@Override
public int run(String... args) throws Exception {
return new CommandLine(this).execute(args);
}
public static void main(String[] args) {
Quarkus.run(ToplevelCommand.class, args);
}
} Running this class in my IntelliJ IDEA fails with the above error. For completeness, this is the full command:
|
@stuartwdouglas @geoand We could probably leave out the |
shouldn't there be a way to resolve a case where there could be multiple @DefaultMain's....like could we combine it with CDI classifiers or add some other kind of uniqueness to them (other than full class/package name) |
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.
Works for me. I'll leave the decision of when to merge to @gsmet
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 added some comments, most of them related to the documentation but there are 2 that should be handled more carefully and might be real issues.
<exclusion> | ||
<!-- This has shaded dependencies --> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> |
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.
Have you checked it works properly? We had a couple of bad surprises with wildcard exclusions.
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.
It appears to, none of the bootstrap deps ended up in the final application.
/** | ||
* A build item that represents the raw command line arguments as they were passed to the application. | ||
* | ||
* No filtering is done on these parameters. |
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.
Maybe you could add a comment about this proxy magic? It's not the typical build item.
runtimeUpdatesProcessor.checkForChangedClasses(); | ||
restartApp(runtimeUpdatesProcessor.checkForFileChange()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); |
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.
Shouldn't we have a proper logger? Or it's too low level?
core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java
Show resolved
Hide resolved
|
||
context.getModules().add(new DevModeContext.ModuleInfo("main", new File("").getAbsolutePath(), | ||
Collections.singleton(src.getAbsolutePath()), appClassesFile.getAbsolutePath(), res.getAbsolutePath())); | ||
//the loading of this is super wierd, and does its own class loader delegation for some reason |
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.
//the loading of this is super wierd, and does its own class loader delegation for some reason | |
//the loading of this is super weird, and does its own class loader delegation for some reason |
import io.quarkus.runtime.annotations.DefaultMain; | ||
import io.quarkus.runtime.Quarkus; | ||
|
||
@DefaultMain <1> |
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.
@DefaultMain <1> | |
@QuarkusMain <1> |
generated main class, but has the advantage that you can just launch it directly from the IDE without needing | ||
to run a Maven or Gradle command. | ||
|
||
WARNING: It is not recommenced to do any business logic in this main method, as Quarkus has not been setup yet, |
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.
WARNING: It is not recommenced to do any business logic in this main method, as Quarkus has not been setup yet, | |
WARNING: It is not recommenced to do any business logic in this main method, as Quarkus has not been set up yet, |
import io.quarkus.runtime.QuarkusApplication; | ||
import io.quarkus.runtime.annotations.DefaultMain; | ||
|
||
@DefaultMain |
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.
@DefaultMain | |
@QuarkusMain |
|
||
import io.quarkus.runtime.Quarkus; | ||
import io.quarkus.runtime.QuarkusApplication; | ||
import io.quarkus.runtime.annotations.DefaultMain; |
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.
import io.quarkus.runtime.annotations.DefaultMain; | |
import io.quarkus.runtime.annotations.QuarkusMain; |
@@ -173,6 +176,29 @@ public QuarkusProdModeTest setForcedDependencies(List<AppArtifact> forcedDepende | |||
return this; | |||
} | |||
|
|||
/** | |||
* If this is true then the quarkus application is expected to exit immediately (i.e. is a command mode app) |
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.
* If this is true then the quarkus application is expected to exit immediately (i.e. is a command mode app) | |
* If this is true then the Quarkus application is expected to exit immediately (i.e. is a command mode app) |
core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java
Outdated
Show resolved
Hide resolved
afeebe0
to
f941994
Compare
@stuartwdouglas AFAICS, you missed some of my comments? Maybe because they were hidden by GitHub because there were too many of them? Could you have a look? There are typos but also this "DO NOT MERGE" thing, which I would like to be sure we want to merge it anyway. Also, all the JVM jobs are failing. I had a look to one and the failure might be related:
|
f941994
to
07de013
Compare
I think I have addressed everything, lets see what CI says. |
@gsmet should be good to go now |
07de013
to
49e01a8
Compare
@gsmet do you have any more concerns with this one? |
@remkop I assume you have been working with the maven goal quarkus:dev while experimenting with picocli? Does the maven plugin offer a way to pass command-line-args in some way? |
@38leinaD I had the same problem. I only got it to work in my IDE. (Didn’t try very hard though.) |
command mode is very new/fresh so not everything is tuned for it yet - do open issues for ideas/issues you find. Having a way to pass arguments in to "resend/reevaluate" on restart would be a good thing to have. |
49e01a8
to
2f35d43
Compare
How to get this to run? I made an attempt here but failed. It doesn't work. |
@PhilAndrew if you are using current master and followed the documentation added in this PR, please report a GH issue pointing to the reproducer. That will be easier to track. |
This is a draft of command mode support. It adds support for the following:
This also contains very basic preview for an IDE launcher.