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

Command mode support #7681

Merged
merged 3 commits into from
Apr 6, 2020
Merged

Command mode support #7681

merged 3 commits into from
Apr 6, 2020

Conversation

stuartwdouglas
Copy link
Member

This is a draft of command mode support. It adds support for the following:

  • The ability to write QuarkusApplication instances that will run on startup, shutdown Quarkus on completion
  • Exit code support, either by returning an exit code from the QuarkusApplication or by calling Quarkus.exit()
  • Quarkus.waitForExit that allows a QuarkusApplication to act as a long running process

This also contains very basic preview for an IDE launcher.

@boring-cyborg boring-cyborg bot added area/core area/dependencies Pull requests that update a dependency file labels Mar 9, 2020
@maxandersen
Copy link
Member

related to #5656

@stuartwdouglas stuartwdouglas force-pushed the command-mode branch 4 times, most recently from 3415835 to 62e90e0 Compare March 10, 2020 09:10
@stuartwdouglas stuartwdouglas force-pushed the command-mode branch 3 times, most recently from fb75cc5 to 8adf3ea Compare March 13, 2020 03:30
@stuartwdouglas stuartwdouglas marked this pull request as ready for review March 13, 2020 05:37
context.getClassesRoots().add(appClassesFile);

//TODO: huge hacks
File src = new File(appClassesFile, "../../src/main/java");
Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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... ;-)

@geoand geoand mentioned this pull request Mar 17, 2020
@stuartwdouglas stuartwdouglas force-pushed the command-mode branch 2 times, most recently from 1815bbb to f33bead Compare March 24, 2020 01:10
@remkop
Copy link

remkop commented Mar 25, 2020

Trying to play with this now. Ran into this issue while trying to build. Fixed by using Maven 3.6.2 and massaging the pom like this:

Update: never mind, my mistake; I was looking at the master branch instead of the command-mode branch...

@remkop
Copy link

remkop commented Mar 25, 2020

I have trouble building the project from the command-mode branch:

[ERROR] Failed to execute goal on project quarkus-bootstrap-maven-plugin: 
Could not resolve dependencies for project io.quarkus:quarkus-bootstrap-maven-plugin:maven-plugin:999-SNAPSHOT: 
Could not find artifact
io.quarkus:quarkus-bootstrap-core:jar:tests:999-SNAPSHOT -> ...

@geoand
Copy link
Contributor

geoand commented Mar 25, 2020

@remkop Try ./mvnw clean install -DskipTests -DskipITs -DskipDocs.

@geoand
Copy link
Contributor

geoand commented Mar 25, 2020

I love the command mode, I really do!

But I find it awkward that I have to add the @DefaultMain annotation - I could see people easily leaving it out.

For example, if I do:

@DefaultMain
public class Main {

	public static void main(String... args) throws Exception {
		Quarkus.run(HelloWorldNonDefault.class, args);
	}

	public static class HelloWorldNonDefault implements QuarkusApplication {
		@Override
		public int run(String... args) throws Exception {
			System.out.println("Hello World");
			return 0;
		}
	}
}

then I get the desired command line application that runs an exits (whether I run from the IDE or just run the jar).
If however I forget to add @DefaultMain and proceed to create a jar, then when I run the jar I don't get the expected result.
This becomes even more confusing because if I forget @DefaultMain and run the main method from the IDE, everything works as expected.

Perhaps my concern is unfounded and users won't make this mistake..., I don't know :)
Also I haven't really thought of any better alternative - I'll try and come with some ideas.

@remkop
Copy link

remkop commented Mar 25, 2020

Thank you @geoand, that worked.

@stuartwdouglas I did build the docs, and found 3 broken links in index.adoc: instead of linking to docname.adoc, the link should be to docname.html (the generated document):

Index: docs/src/main/asciidoc/index.adoc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- docs/src/main/asciidoc/index.adoc	(revision f33beaddaf49dd4e303a27875e6d5053e03489dc)
+++ docs/src/main/asciidoc/index.adoc	(date 1585112916870)
@@ -58,9 +58,9 @@
 * link:mongodb.html[Using MongoDB]
 * link:mongodb-panache.html[Simplified MongoDB with Panache]
 * link:jms.html[Using Artemis JMS Client]
-* link:reactive-routes.adoc[Using Reactive Routes]
-* link:camel.adoc[Apache Camel]
-* link:command-mode-reference.adoc[Command Mode Applications]
+* link:reactive-routes.html[Using Reactive Routes]
+* link:camel.html[Apache Camel]
+* link:command-mode-reference.html[Command Mode Applications]
 
 * link:faq.html[FAQs]
 

Still looking...

@emmanuelbernard emmanuelbernard mentioned this pull request Mar 25, 2020
3 tasks
@remkop
Copy link

remkop commented Mar 25, 2020

I cannot get my app to run on Windows... I get the below error.
Unclear why the colon : in C:/Users/remko/IdeaProjects/quarkus-getting-started is causing an issue...

Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/Users/remko/IdeaProjects/quarkus-getting-started/target/classes/
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
	at java.base/java.nio.file.Path.of(Path.java:147)
	at java.base/java.nio.file.Paths.get(Paths.java:69)
	at io.quarkus.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:31)
	at io.quarkus.runtime.Quarkus.launchFromIDE(Quarkus.java:93)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:79)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
	at org.acme.getting.started.ToplevelCommand.main(ToplevelCommand.java:28)

Steps to reproduce:

First, create a project like this:

C:\Users\remko\IdeaProjects>mvn io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:create -DprojectGroupId=org.acme -DprojectA
rtifactId=quarkus-getting-started -DclassName="org.acme.getting.started.GreetingResource" -Dpath="/hello"

Add a dependency on picocli to the pom.xml:

    <dependency>
      <groupId>info.picocli</groupId>
      <artifactId>picocli</artifactId>
      <version>4.2.0</version>
    </dependency>

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:

C:\apps\graalvm-ce-java11-20.0.0\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3\lib\idea_rt.jar=50048:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\remko\IdeaProjects\quarkus-getting-started\target\classes;C:\Users\remko\.m2\repository\info\picocli\picocli\4.2.0\picocli-4.2.0.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-resteasy\999-SNAPSHOT\quarkus-resteasy-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-vertx-http\999-SNAPSHOT\quarkus-vertx-http-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-development-mode-spi\999-SNAPSHOT\quarkus-development-mode-spi-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\security\quarkus-security\1.0.1.Final\quarkus-security-1.0.1.Final.jar;C:\Users\remko\.m2\repository\jakarta\enterprise\jakarta.enterprise.cdi-api\2.0.2\jakarta.enterprise.cdi-api-2.0.2.jar;C:\Users\remko\.m2\repository\jakarta\el\jakarta.el-api\3.0.3\jakarta.el-api-3.0.3.jar;C:\Users\remko\.m2\repository\jakarta\interceptor\jakarta.interceptor-api\1.2.5\jakarta.interceptor-api-1.2.5.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-vertx-core\999-SNAPSHOT\quarkus-vertx-core-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-netty\999-SNAPSHOT\quarkus-netty-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\netty\netty-codec\4.1.45.Final\netty-codec-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-handler\4.1.45.Final\netty-handler-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\vertx\vertx-core\3.8.5\vertx-core-3.8.5.jar;C:\Users\remko\.m2\repository\io\netty\netty-common\4.1.45.Final\netty-common-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-buffer\4.1.45.Final\netty-buffer-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-transport\4.1.45.Final\netty-transport-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-handler-proxy\4.1.45.Final\netty-handler-proxy-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-codec-socks\4.1.45.Final\netty-codec-socks-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-codec-http\4.1.45.Final\netty-codec-http-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-codec-http2\4.1.45.Final\netty-codec-http2-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-resolver\4.1.45.Final\netty-resolver-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-resolver-dns\4.1.45.Final\netty-resolver-dns-4.1.45.Final.jar;C:\Users\remko\.m2\repository\io\netty\netty-codec-dns\4.1.45.Final\netty-codec-dns-4.1.45.Final.jar;C:\Users\remko\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.10.3\jackson-core-2.10.3.jar;C:\Users\remko\.m2\repository\io\vertx\vertx-web\3.8.5\vertx-web-3.8.5.jar;C:\Users\remko\.m2\repository\io\vertx\vertx-web-common\3.8.5\vertx-web-common-3.8.5.jar;C:\Users\remko\.m2\repository\io\vertx\vertx-auth-common\3.8.5\vertx-auth-common-3.8.5.jar;C:\Users\remko\.m2\repository\io\vertx\vertx-bridge-common\3.8.5\vertx-bridge-common-3.8.5.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-resteasy-server-common\999-SNAPSHOT\quarkus-resteasy-server-common-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-resteasy-common\999-SNAPSHOT\quarkus-resteasy-common-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\org\jboss\resteasy\resteasy-core\4.5.2.Final\resteasy-core-4.5.2.Final.jar;C:\Users\remko\.m2\repository\org\jboss\spec\javax\ws\rs\jboss-jaxrs-api_2.1_spec\2.0.1.Final\jboss-jaxrs-api_2.1_spec-2.0.1.Final.jar;C:\Users\remko\.m2\repository\org\jboss\spec\javax\xml\bind\jboss-jaxb-api_2.3_spec\2.0.0.Final\jboss-jaxb-api_2.3_spec-2.0.0.Final.jar;C:\Users\remko\.m2\repository\org\jboss\resteasy\resteasy-core-spi\4.5.2.Final\resteasy-core-spi-4.5.2.Final.jar;C:\Users\remko\.m2\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;C:\Users\remko\.m2\repository\org\eclipse\microprofile\config\microprofile-config-api\1.4\microprofile-config-api-1.4.jar;C:\Users\remko\.m2\repository\com\sun\activation\jakarta.activation\1.2.1\jakarta.activation-1.2.1.jar;C:\Users\remko\.m2\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-arc\999-SNAPSHOT\quarkus-arc-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\arc\arc\999-SNAPSHOT\arc-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\remko\.m2\repository\jakarta\transaction\jakarta.transaction-api\1.3.3\jakarta.transaction-api-1.3.3.jar;C:\Users\remko\.m2\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-core\999-SNAPSHOT\quarkus-core-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\jakarta\inject\jakarta.inject-api\1.0\jakarta.inject-api-1.0.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-ide-launcher\999-SNAPSHOT\quarkus-ide-launcher-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\smallrye\config\smallrye-config\1.7.0\smallrye-config-1.7.0.jar;C:\Users\remko\.m2\repository\io\smallrye\config\smallrye-config-common\1.7.0\smallrye-config-common-1.7.0.jar;C:\Users\remko\.m2\repository\org\jboss\logmanager\jboss-logmanager-embedded\1.0.4\jboss-logmanager-embedded-1.0.4.jar;C:\Users\remko\.m2\repository\org\jboss\logging\jboss-logging-annotations\2.1.0.Final\jboss-logging-annotations-2.1.0.Final.jar;C:\Users\remko\.m2\repository\org\jboss\threads\jboss-threads\3.0.1.Final\jboss-threads-3.0.1.Final.jar;C:\Users\remko\.m2\repository\org\slf4j\slf4j-api\1.7.29\slf4j-api-1.7.29.jar;C:\Users\remko\.m2\repository\org\jboss\slf4j\slf4j-jboss-logging\1.2.0.Final\slf4j-jboss-logging-1.2.0.Final.jar;C:\Users\remko\.m2\repository\org\graalvm\sdk\graal-sdk\19.3.1\graal-sdk-19.3.1.jar;C:\Users\remko\.m2\repository\org\wildfly\common\wildfly-common\1.5.4.Final-format-001\wildfly-common-1.5.4.Final-format-001.jar;C:\Users\remko\.m2\repository\org\eclipse\microprofile\context-propagation\microprofile-context-propagation-api\1.0.1\microprofile-context-propagation-api-1.0.1.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-junit5\999-SNAPSHOT\quarkus-junit5-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-bootstrap-core\999-SNAPSHOT\quarkus-bootstrap-core-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\org\ow2\asm\asm\7.3.1\asm-7.3.1.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-embedder\3.6.3\maven-embedder-3.6.3.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-settings\3.6.3\maven-settings-3.6.3.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-core\3.6.3\maven-core-3.6.3.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-artifact\3.6.3\maven-artifact-3.6.3.jar;C:\Users\remko\.m2\repository\org\codehaus\plexus\plexus-component-annotations\2.1.0\plexus-component-annotations-2.1.0.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-plugin-api\3.6.3\maven-plugin-api-3.6.3.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-model\3.6.3\maven-model-3.6.3.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-model-builder\3.6.3\maven-model-builder-3.6.3.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-builder-support\3.6.3\maven-builder-support-3.6.3.jar;C:\Users\remko\.m2\repository\org\apache\maven\resolver\maven-resolver-api\1.4.1\maven-resolver-api-1.4.1.jar;C:\Users\remko\.m2\repository\org\apache\maven\resolver\maven-resolver-util\1.4.1\maven-resolver-util-1.4.1.jar;C:\Users\remko\.m2\repository\org\apache\maven\shared\maven-shared-utils\3.2.1\maven-shared-utils-3.2.1.jar;C:\Users\remko\.m2\repository\commons-io\commons-io\2.6\commons-io-2.6.jar;C:\Users\remko\.m2\repository\com\google\inject\guice\4.2.1\guice-4.2.1-no_aop.jar;C:\Users\remko\.m2\repository\com\google\guava\guava\27.0.1-jre\guava-27.0.1-jre.jar;C:\Users\remko\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\remko\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\remko\.m2\repository\org\codehaus\plexus\plexus-utils\3.2.1\plexus-utils-3.2.1.jar;C:\Users\remko\.m2\repository\org\eclipse\sisu\org.eclipse.sisu.plexus\0.3.4\org.eclipse.sisu.plexus-0.3.4.jar;C:\Users\remko\.m2\repository\commons-cli\commons-cli\1.4\commons-cli-1.4.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-settings-builder\3.6.3\maven-settings-builder-3.6.3.jar;C:\Users\remko\.m2\repository\org\codehaus\plexus\plexus-interpolation\1.25\plexus-interpolation-1.25.jar;C:\Users\remko\.m2\repository\org\sonatype\plexus\plexus-sec-dispatcher\1.4\plexus-sec-dispatcher-1.4.jar;C:\Users\remko\.m2\repository\org\sonatype\plexus\plexus-cipher\1.4\plexus-cipher-1.4.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-resolver-provider\3.6.3\maven-resolver-provider-3.6.3.jar;C:\Users\remko\.m2\repository\org\apache\maven\maven-repository-metadata\3.6.3\maven-repository-metadata-3.6.3.jar;C:\Users\remko\.m2\repository\org\apache\maven\resolver\maven-resolver-spi\1.4.1\maven-resolver-spi-1.4.1.jar;C:\Users\remko\.m2\repository\org\apache\maven\resolver\maven-resolver-impl\1.4.1\maven-resolver-impl-1.4.1.jar;C:\Users\remko\.m2\repository\org\apache\maven\resolver\maven-resolver-connector-basic\1.4.1\maven-resolver-connector-basic-1.4.1.jar;C:\Users\remko\.m2\repository\org\apache\maven\resolver\maven-resolver-transport-wagon\1.4.1\maven-resolver-transport-wagon-1.4.1.jar;C:\Users\remko\.m2\repository\org\apache\maven\wagon\wagon-http\3.3.4\wagon-http-3.3.4.jar;C:\Users\remko\.m2\repository\org\apache\maven\wagon\wagon-http-shared\3.3.4\wagon-http-shared-3.3.4.jar;C:\Users\remko\.m2\repository\org\jsoup\jsoup\1.12.1\jsoup-1.12.1.jar;C:\Users\remko\.m2\repository\org\apache\maven\wagon\wagon-provider-api\3.3.4\wagon-provider-api-3.3.4.jar;C:\Users\remko\.m2\repository\org\apache\maven\wagon\wagon-file\3.3.4\wagon-file-3.3.4.jar;C:\Users\remko\.m2\repository\org\jboss\logging\commons-logging-jboss-logging\1.0.0.Final\commons-logging-jboss-logging-1.0.0.Final.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-test-common\999-SNAPSHOT\quarkus-test-common-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-core-deployment\999-SNAPSHOT\quarkus-core-deployment-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\gizmo\gizmo\1.0.2.Final\gizmo-1.0.2.Final.jar;C:\Users\remko\.m2\repository\org\ow2\asm\asm-util\7.3.1\asm-util-7.3.1.jar;C:\Users\remko\.m2\repository\org\ow2\asm\asm-tree\7.3.1\asm-tree-7.3.1.jar;C:\Users\remko\.m2\repository\org\ow2\asm\asm-analysis\7.3.1\asm-analysis-7.3.1.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-builder\999-SNAPSHOT\quarkus-builder-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-jsonp-deployment\999-SNAPSHOT\quarkus-jsonp-deployment-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\io\quarkus\quarkus-jsonp\999-SNAPSHOT\quarkus-jsonp-999-SNAPSHOT.jar;C:\Users\remko\.m2\repository\org\glassfish\jakarta.json\1.1.6\jakarta.json-1.1.6.jar;C:\Users\remko\.m2\repository\org\jboss\jandex\2.1.3.Final\jandex-2.1.3.Final.jar;C:\Users\remko\.m2\repository\org\junit\jupiter\junit-jupiter\5.6.1\junit-jupiter-5.6.1.jar;C:\Users\remko\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.6.1\junit-jupiter-api-5.6.1.jar;C:\Users\remko\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\remko\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\remko\.m2\repository\org\junit\platform\junit-platform-commons\1.6.1\junit-platform-commons-1.6.1.jar;C:\Users\remko\.m2\repository\org\junit\jupiter\junit-jupiter-params\5.6.1\junit-jupiter-params-5.6.1.jar;C:\Users\remko\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.6.1\junit-jupiter-engine-5.6.1.jar;C:\Users\remko\.m2\repository\org\junit\platform\junit-platform-engine\1.6.1\junit-platform-engine-1.6.1.jar;C:\Users\remko\.m2\repository\org\apache\httpcomponents\httpclient\4.5.12\httpclient-4.5.12.jar;C:\Users\remko\.m2\repository\org\apache\httpcomponents\httpcore\4.4.13\httpcore-4.4.13.jar;C:\Users\remko\.m2\repository\commons-codec\commons-codec\1.13\commons-codec-1.13.jar;C:\Users\remko\.m2\repository\org\apache\commons\commons-lang3\3.9\commons-lang3-3.9.jar org.acme.getting.started.ToplevelCommand

@mkouba
Copy link
Contributor

mkouba commented Mar 25, 2020

@stuartwdouglas @geoand We could probably leave out the @DefaultMain if there is only one QuarkusApplication impl found. We could also try to find a better name for the annotation. @QuarkusMain or even @Main?

@maxandersen
Copy link
Member

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)

Copy link
Contributor

@gastaldi gastaldi left a 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

Copy link
Member

@gsmet gsmet left a 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>
Copy link
Member

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.

Copy link
Member Author

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.
Copy link
Member

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();
Copy link
Member

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?


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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@DefaultMain
@QuarkusMain


import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.DefaultMain;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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)

@stuartwdouglas stuartwdouglas force-pushed the command-mode branch 4 times, most recently from afeebe0 to f941994 Compare March 31, 2020 05:53
@gsmet
Copy link
Member

gsmet commented Mar 31, 2020

@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:

[ERROR] DevMojoIT.testThatApplicationRecoversStartupIssue:477 >RunAndCheckMojoTestBase.runAndExpectError:84->MojoTestBase.getHttpErrorResponse:156 » ConditionTimeout
[ERROR] Tests run: 50, Failures: 0, Errors: 1, Skipped: 1

@stuartwdouglas
Copy link
Member Author

I think I have addressed everything, lets see what CI says.

@stuartwdouglas
Copy link
Member Author

@gsmet should be good to go now

@stuartwdouglas
Copy link
Member Author

@gsmet do you have any more concerns with this one?

@gastaldi gastaldi requested a review from gsmet April 2, 2020 14:01
@38leinaD
Copy link
Contributor

38leinaD commented Apr 4, 2020

@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?
I am working with a gradle-build and the quarkusDev task does not seem to offer any way to pass arguments to your application (only JVM args) which would be very helpful when developing a commandline application.

@remkop
Copy link

remkop commented Apr 4, 2020

@38leinaD I had the same problem. I only got it to work in my IDE. (Didn’t try very hard though.)

@maxandersen
Copy link
Member

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?
I am working with a gradle-build and the quarkusDev task does not seem to offer any way to pass arguments to your application (only JVM args) which would be very helpful when developing a commandline application.

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.

@gsmet gsmet merged commit 83885cf into quarkusio:master Apr 6, 2020
@PhilAndrew
Copy link

How to get this to run? I made an attempt here but failed. It doesn't work.
https://github.com/PhilAndrew/quarkus-main-demo

@gsmet
Copy link
Member

gsmet commented Apr 6, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core area/dependencies Pull requests that update a dependency file release/noteworthy-feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.