micronaut-core: Generate CLI app with correct main class name (was: CLI command stopped working when app is assembled)
I am currently playing around with the CLI profile (picocli)
on latest snapshot. The app stopped working when assembled and called via java -jar …
. Running the app as Application
from my IntelliJ IDE still works.
Steps to Reproduce
- create an app with profile
cli
enabled - create a command
- assemble app
- call jar
$ mn create-app my-cli-app --profile cli
Generating Java project...
| Application created at /tmp/my-cli-app
$ cd my-cli-app/
$ mn
| Starting interactive mode...
| Enter a command name to run. Use TAB for completion:
mn> create-command test
| Rendered template Command.java to destination src/main/java/my/cli/app/TestCommand.java
| Rendered template CommandTest.java to destination src/test/java/my/cli/app/TestCommandTest.java
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 4s
11 actionable tasks: 10 executed, 1 up-to-date
$ java -jar build/libs/my-cli-app-0.1-all.jar -v
11:14:05.005 [main] INFO io.micronaut.runtime.Micronaut - No embedded container found. Running as CLI application
Expected Behaviour
CLI command is called and shows Hi!
Actual Behaviour
CLI command is not invoked instead the message:
INFO io.micronaut.runtime.Micronaut - No embedded container found. Running as CLI application
shows up
Environment Information
- Operating System: Linux 4.17.11-200.fc28.x86_64
- Micronaut Version: 1.0.0.BUILD-SNAPSHOT
- JDK Version: 1.8.0_171
Example Application
n/a
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 32 (27 by maintainers)
Commits related to this issue
- Merge pull request #480 from remkop/#474-create-cli-app #474 create cli app — committed to micronaut-projects/micronaut-core by graemerocher 6 years ago
- #474 add create-cli-app command that creates CLI app with the correct main class — committed to micronaut-projects/micronaut-core by remkop 6 years ago
- #474 update completion script for new command and new features — committed to micronaut-projects/micronaut-core by remkop 6 years ago
- #474 update the documentation for the new create-cli-app command — committed to micronaut-projects/micronaut-core by remkop 6 years ago
Fixed by https://github.com/micronaut-projects/micronaut-profiles/commit/2278087944a8747b8845e2fc265289e51200ffc8
I hate to bring up an old issue, but I am seeing the same problem happen with the
--build maven
option. This is my first time using Micronaut or PicoCLI. I can see that your changes were not undone after your PRs were merged, so I’m not sure what’s up with this unless Micronaut 1.0.0 was built on the wrong changeset or something.What I did on macOS High Sierra (10.13.6) with Azul Zulu JDK 8 (Java 8u162):
mn create-cli-app --build maven analyzer
mvn clean install
java -jar target/analyzer-0.1.jar -v
(also used-h
and--verbose
)The output is:
Checking the pom.xml I see:
After changing mainClass to
<exec.mainClass>analyzer.AnalyzerCommand</exec.mainClass>
and rebuilding, I get the expected output when running it.