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

Most upvoted comments

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

  1. Installed SDKMan
  2. Installed Micronaut 1.0.0
  3. mn create-cli-app --build maven analyzer
  4. mvn clean install
  5. java -jar target/analyzer-0.1.jar -v (also used -h and --verbose)

The output is:

13:51:15.915 [main] INFO  io.micronaut.runtime.Micronaut - No embedded container found. Running as CLI application

Checking the pom.xml I see:

  <properties>
    <exec.mainClass>analyzer.Application</exec.mainClass>
    <micronaut.version>1.0.0</micronaut.version>
    <jdk.version>1.8</jdk.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

After changing mainClass to <exec.mainClass>analyzer.AnalyzerCommand</exec.mainClass> and rebuilding, I get the expected output when running it.