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

Create a Picocli example codestart for Quarkus JBang project type #13208

Closed
ia3andy opened this issue Nov 10, 2020 · 12 comments · Fixed by #13828
Closed

Create a Picocli example codestart for Quarkus JBang project type #13208

ia3andy opened this issue Nov 10, 2020 · 12 comments · Fixed by #13828
Labels
area/codestarts area/jbang Issues related to when using jbang.dev with Quarkus good first issue Good for newcomers kind/enhancement New feature or request
Milestone

Comments

@ia3andy
Copy link
Contributor

ia3andy commented Nov 10, 2020

Description
Create a Picocli example codestart for Quarkus JBang project type.

Implementation ideas
Take inspiration from the RESTEasy example: https://github.com/quarkusio/quarkus/tree/master/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus-jbang/code/jbang-resteasy-code

@ia3andy ia3andy added kind/enhancement New feature or request good first issue Good for newcomers area/codestarts labels Nov 10, 2020
@quarkusbot quarkusbot added the area/jbang Issues related to when using jbang.dev with Quarkus label Nov 10, 2020
@quarkusbot
Copy link

/cc @quarkusio/devtools, @maxandersen
/cc @quarkusio/devtools

@ia3andy
Copy link
Contributor Author

ia3andy commented Nov 12, 2020

@ia3andy
Copy link
Contributor Author

ia3andy commented Nov 12, 2020

to generate:

final QuarkusJBangCodestartProjectInput input = QuarkusJBangCodestartProjectInput.builder()
				.addCodestart("jbang-picocli-code")
                .putData("quarkus.version", "999-SNAPSHOT")
                .build();
        final Path projectDir = ...;
        getCatalog().createProject(input).generate(projectDir);

@ia3andy
Copy link
Contributor Author

ia3andy commented Nov 12, 2020

@SumaiyaSafdar do you want to try that one?

@nicobao
Copy link
Contributor

nicobao commented Dec 7, 2020

Hi,
I am happy to start working on this issue, except if @SumaiyaSafdar already started?

@ia3andy
Copy link
Contributor Author

ia3andy commented Dec 8, 2020

Sure @nicobao.

You can sync with @jtama-op who made the picocli codestart: #13647

And @geoandri who plugged the Codestart JBang project type to the Quarkus Maven Plugin:
#13538

CC @remkop @mgorniew

@jtama
Copy link
Contributor

jtama commented Dec 8, 2020

Sure I'd be happy to help.

@geoandri
Copy link
Contributor

geoandri commented Dec 8, 2020

I can help as well.

@nicobao
Copy link
Contributor

nicobao commented Dec 8, 2020

Thanks folks, I start working on it this evening.

@nicobao
Copy link
Contributor

nicobao commented Dec 8, 2020

So, I started setting up my environment, looking at the code base and coding a little bit.

I normally use neovim & eclipse.jdt.ls but I have a problem while developing Quarkus:

  • on opening Java files I get a warning "Foo.java is a non-project file, only syntax errors are reported". It's strange because I had installed the whole project using ./mvnw -Dquickly as explain here: https://github.com/quarkusio/quarkus/blob/master/CONTRIBUTING.md#build and the files are part of a project...
    I use Maven with modules at work with eclipse.jdt.ls and it works fine.
    Does anybody have experience developing Quarkus with vim/eclipse.jdt.ls?

As of the issue itself, here is my understanding so far:

I am not sure if that's the right direction, I wanted to test that out.

What I am still trying to figure out:

  • how to bootstrap the current jbang resteasy project. I found this: https://quarkus.io/blog/extension-codestarts-a-new-way-to-learn-and-discover-quarkus/#existing-extension-codestarts but jbang cli@quarkusio create generates a my-project with GreetingResource.java different from the template I see in the code. Maybe I ran an older version? How to compile/run it from the source code? Incidentally, it would mean I know how to run my change
    I also tried java -jar quarkus/devtools/cli/target/quarkus-cli-999-SNAPSHOT-runner.jar: it does run the quarkus cli but I am not sure that is what I am supposed to do?
  • where the corresponding unit/integration tests are
  • how everything piece together to generate that nice REAME for instance

@ia3andy
Copy link
Contributor Author

ia3andy commented Dec 9, 2020

@nicobao

So, I started setting up my environment, looking at the code base and coding a little bit.

I normally use neovim & eclipse.jdt.ls but I have a problem while developing Quarkus:

  • on opening Java files I get a warning "Foo.java is a non-project file, only syntax errors are reported". It's strange because I had installed the whole project using ./mvnw -Dquickly as explain here: https://github.com/quarkusio/quarkus/blob/master/CONTRIBUTING.md#build and the files are part of a project...
    I use Maven with modules at work with eclipse.jdt.ls and it works fine.
    Does anybody have experience developing Quarkus with vim/eclipse.jdt.ls?

I am sorry, I am using IntelliJ to work on Quarkus, but I know a lot of us use Eclipse @gsmet any thoughts?

As of the issue itself, here is my understanding so far:

I am not sure if that's the right direction, I wanted to test that out.

That's right :) You need to create a new directory for the picocli example next to the resteasy one.

What I am still trying to figure out:

jbang cli@quarkusio create is used to genereate maven/gradle Quarkus app (and not the jbang ones), this could be a bit confusing, jbang doesn't mean you are generating a jbang project, but you are using jbang to start the Quarkus CLI :)

Yesterday @geoandri introduced a new command in the Quarkus CLI create-jbang (#13746), it will be available in the next Quarkus release (1.11). Until then you can use it in the project by compiling https://github.com/quarkusio/quarkus/blob/master/devtools/cli/ and then use the jar in the target dir:

java -jar quarkus-cli-999-SNAPSHOT-runner.jar create-jbang

How to compile/run it from the source code? Incidentally, it would mean I know how to run my change

I also tried java -jar quarkus/devtools/cli/target/quarkus-cli-999-SNAPSHOT-runner.jar: it does run the quarkus cli but I am not sure that is what I am supposed to do?

  • where the corresponding unit/integration tests are

You have integration tests here:
https://github.com/quarkusio/quarkus/blob/master/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/jbang/QuarkusJBangCodestartGenerationTest.java

  • how everything piece together to generate that nice REAME for instance

I guess you are talking about the "normal" quarkus app here, which are located here:
https://github.com/quarkusio/quarkus/tree/master/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus

But this is the same system, we have an instruction in the project file:
https://github.com/quarkusio/quarkus/blob/master/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus-jbang/project/quarkus-jbang/codestart.yml#L5
Saying that README.md files will be appended together, so if you add a https://github.com/quarkusio/quarkus/tree/master/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus-jbang/code/jbang-resteasy-code/base/README.tpl.qute.md file, its content is going to be appended to the ouput when resteasy is selected..

@nicobao
Copy link
Contributor

nicobao commented Dec 9, 2020

Hi,
Thanks for the quick answer.

As of neovim+coc.nvim and eclipse.jdt.ls, I managed this evening to make it work well by doing the following:

  • uninstall coc-metals (Scala LSP: it was interfering with Java project)
  • upgrade eclipse.jdt.ls using coc-java dedicated command
  • fix wrong path for my Java runtime JDK dependencies
  • re-open the project and wait until the indexing finishes

I use modular vim configuration plugin (like this https://github.com/embear/vim-localvimrc), which help me have specific tabulation/space config for Quarkus, and I need to create editor-specific files potentially named as follows:

  • .lvimrc
  • .vimrc
    Would it be possible to edit .gitignore to ignore those files?

As for the project itself, your answers helped me a lot.
I have an issue when running ./mvnw install -f devtools/:

$ quarkus --manual-output --verbose -e create
-----------

applying codestarts...
🔠 java
🧰 maven
🗃 quarkus
📜 config-properties
🛠 dockerfiles
🛠 maven-wrapper
🐒 resteasy-example

-----------
👍 quarkus project has been successfully generated in:
--> /home/nicolas/nicobao/quarkus/devtools/cli/target/cli-workspace/my-project
-----------
Project my-project created.

[ERROR] Tests run: 8, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 126.657 s <<< FAILURE! - in io.quarkus.cli.CliTest
[ERROR] io.quarkus.cli.CliTest.testCreateJBang  Time elapsed: 0.036 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <0> but was: <1>
	at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
	at org.junit.jupiter.api.AssertionUtils.failNotEqual(AssertionUtils.java:62)
	at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
	at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:145)
	at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:510)
	at io.quarkus.cli.CliTest.testCreateJBang(CliTest.java:312)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:188)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   CliTest.testCreateJBang:312 expected: <0> but was: <1>
[INFO] 
[ERROR] Tests run: 8, Failures: 1, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Quarkus - Dev tools 999-SNAPSHOT:
[INFO] 
[INFO] Quarkus - Dev tools - Platform Descriptor - JSON Maven Plugin SUCCESS [  9.011 s]
[INFO] Quarkus - Dev tools ................................ SUCCESS [  0.057 s]
[INFO] Quarkus - Platform Properties ...................... SUCCESS [  0.297 s]
[INFO] Quarkus - BOM - Descriptor JSON .................... SUCCESS [  1.942 s]
[INFO] Quarkus - Dev tools - Platform Descriptor - JSON ... SUCCESS [ 10.069 s]
[INFO] Quarkus - Maven Plugin ............................. SUCCESS [ 12.654 s]
[INFO] Quarkus - Gradle Plugin ............................ SUCCESS [ 33.393 s]
[INFO] Quarkus - Command Line Interface ................... FAILURE [02:11 min]
[INFO] Quarkus - Dev tools - Reflection Agent ............. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

See my own fork if ever you have time to help: nicobao@62ccc72

Didn't have time to work on:

  • how to run the GitHub Actions Workflow on a named branch in my fork (I watched the video)
  • how to make the README.md append different instructions depending on the extension (picocli or resteasy) - I suppose I'll have to move the README to each code sub-directories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codestarts area/jbang Issues related to when using jbang.dev with Quarkus good first issue Good for newcomers kind/enhancement New feature or request
Projects
None yet
5 participants