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

Introduce a new CLI command to create JBang Quarkus projects #13209

Closed
ia3andy opened this issue Nov 10, 2020 · 17 comments · Fixed by #13538
Closed

Introduce a new CLI command to create JBang Quarkus projects #13209

ia3andy opened this issue Nov 10, 2020 · 17 comments · Fixed by #13538
Assignees
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
Introduce a new CLI command to create JBang Quarkus projects with a warning saying it's experimental.

@ia3andy ia3andy added kind/enhancement New feature or request 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

@ia3andy ia3andy added the good first issue Good for newcomers label Nov 10, 2020
@geoandri
Copy link
Contributor

I can try tackling this, if no one else hasn't started working on it.

@ia3andy
Copy link
Contributor Author

ia3andy commented Nov 10, 2020

@geoandri create a new command create-jbang

@ia3andy ia3andy changed the title Introduce a new CLI option to use jbang as Quarkus project type Introduce a new CLI command to create JBang Quarkus projects Nov 10, 2020
@ia3andy
Copy link
Contributor Author

ia3andy commented Nov 10, 2020

Here is the code to create a jbang quarkus project:

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

@ia3andy
Copy link
Contributor Author

ia3andy commented Nov 10, 2020

Have a look to QuarkusJBangCodestartProjectInputBuilder to know the available options:

  • extensions
  • no jbang wrapper

Also you will need to create a new command in io.quarkus.devtools.commands, have a look at the existing to get inspiration..

@geoandri
Copy link
Contributor

Thanks @ia3andy !

@geoandri
Copy link
Contributor

Hi @ia3andy ,

While running the generated JBang project I am getting the following error:

[jbang] Building jar...
[jbang] Post build with io.quarkus.launcher.JBangIntegration
Warning: failed to load configurator: java.util.ServiceConfigurationError: org.jboss.logmanager.EmbeddedConfigurator: io.quarkus.bootstrap.logging.InitialConfigurator not a subtype
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1236)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1384)
at org.jboss.logmanager.LogContext.getConfigurator(LogContext.java:219)
at org.jboss.logmanager.LogContext.(LogContext.java:38)
at org.slf4j.impl.Slf4jLoggerFactory.getLogger(Slf4jLoggerFactory.java:34)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
at org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher.(DefaultRepositoryEventDispatcher.java:45)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.newInstance(DefaultServiceLocator.java:164)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstances(DefaultServiceLocator.java:139)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstance(DefaultServiceLocator.java:125)
at org.eclipse.aether.impl.DefaultServiceLocator.getService(DefaultServiceLocator.java:278)
at org.eclipse.aether.internal.impl.DefaultMetadataResolver.initService(DefaultMetadataResolver.java:119)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.newInstance(DefaultServiceLocator.java:169)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstances(DefaultServiceLocator.java:139)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstance(DefaultServiceLocator.java:125)
at org.eclipse.aether.impl.DefaultServiceLocator.getService(DefaultServiceLocator.java:278)
at org.apache.maven.repository.internal.DefaultVersionResolver.initService(DefaultVersionResolver.java:108)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.newInstance(DefaultServiceLocator.java:169)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstances(DefaultServiceLocator.java:139)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstance(DefaultServiceLocator.java:125)
at org.eclipse.aether.impl.DefaultServiceLocator.getService(DefaultServiceLocator.java:278)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.initService(DefaultRepositorySystem.java:143)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.newInstance(DefaultServiceLocator.java:169)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstances(DefaultServiceLocator.java:139)
at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstance(DefaultServiceLocator.java:125)
at org.eclipse.aether.impl.DefaultServiceLocator.getService(DefaultServiceLocator.java:278)
at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.newRepositorySystem(BootstrapMavenContext.java:662)
at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getRepositorySystem(BootstrapMavenContext.java:223)
at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.resolveRemoteRepos(BootstrapMavenContext.java:476)
at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getRemoteRepositories(BootstrapMavenContext.java:231)
at io.quarkus.bootstrap.JBangBuilderImpl.postBuild(JBangBuilderImpl.java:27)
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 io.quarkus.launcher.JBangIntegration.postBuild(JBangIntegration.java:77)
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 dev.jbang.IntegrationManager.runIntegration(IntegrationManager.java:94)
at dev.jbang.cli.BaseBuildCommand.buildJar(BaseBuildCommand.java:206)
at dev.jbang.cli.BaseBuildCommand.build(BaseBuildCommand.java:129)
at dev.jbang.cli.Run.prepareArtifacts(Run.java:70)
at dev.jbang.cli.Run.doCall(Run.java:59)
at dev.jbang.cli.BaseCommand.call(BaseCommand.java:80)
at dev.jbang.cli.BaseCommand.call(BaseCommand.java:12)
at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
at picocli.CommandLine.access$1200(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
at picocli.CommandLine.execute(CommandLine.java:2058)
at dev.jbang.Main.main(Main.java:14)
[jbang] [ERROR] Issue running postBuild()

I was wondering if you have any idea for this error.

@ia3andy
Copy link
Contributor Author

ia3andy commented Nov 26, 2020

@geoandri could you push the generated project to github and share it?

cc @maxandersen

@maxandersen
Copy link
Member

looks like logmanager is not set right or classloader error - please share the actual command used to run and what is in the .java file ?

@geoandri
Copy link
Contributor

@ia3andy you can have a look at the generated project at https://github.com/geoandri/jbangGreetting .

@maxandersen I used the command ./jbang src/GreetingResource.java and the .java file is https://github.com/geoandri/jbangGreetting/blob/master/src/GreetingResource.java .

@maxandersen
Copy link
Member

This is using very first poc repo. It won't work :)

Please see wat jbang init -t qrest test.java generates in comments.

@geoandri
Copy link
Contributor

Hi @maxandersen ,

The generated project in the repo that I posted was generated using the code from #13004 (comment) .

I have created a new command using the latest master that generates the project using

final QuarkusJBangCodestartProjectInput input = QuarkusJBangCodestartProjectInput.builder()
                .putData("quarkus.version", "999-SNAPSHOT")
                .build();
        final Path projectDir = testDirPath.resolve("default");
        getCatalog().createProject(input).generate(projectDir);

How can I switch to the latest one?

@maxandersen
Copy link
Member

Remove the //Repos
Remove the line setting log manager
Remove q:config

@geoandri
Copy link
Contributor

Thanks @maxandersen ,

To my undestanding, there are two separate issues.

  1. The template file (https://github.com/quarkusio/quarkus/blob/master/devtools/platform-descriptor-json/src/main/resources/codestarts/quarkus-jbang/code/jbang-resteasy-code/java/src/%7Bresource.class-name%7D.tpl.qute.java) for generating the quarkus-jbang project needs updating.

  2. Something has changed after 1.9.2.Final that causes the postBuild error. If I run the generated project (I used jbang init -t qrest test.java to generate it) using 1.9.2.Final (or previous versions by updating the version in the DEPS) everything works as expected. If I use 1.10.0.Final or my 999-SNAPSHOT I am getting the postbuild error.

@maxandersen
Copy link
Member

Okey that #2 ain't good.

Can you open separate issue on that ? Seems time we get better test coverage for jbang builds.

@geoandri
Copy link
Contributor

Sure @maxandersen ,

created #13508 .

@geoandri
Copy link
Contributor

@ia3andy I have submitted a PR. Who should I ping for a review?

@ghost ghost added this to the 1.11 - master milestone Dec 3, 2020
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
Development

Successfully merging a pull request may close this issue.

4 participants