quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.76k stars 2.68k forks source link

jbang w/jib/kubernetes gives "could not find matching project info to read" #11971

Open maxandersen opened 4 years ago

maxandersen commented 4 years ago

Describe the bug similar to #11888 but this time not about class loading issues but about dekorate assuming 'stuff' we'll need to fix/adapt to.

//usr/bin/env jbang "$0" "$@" ; exit $?
/**
 * Run this with `jbang -Dquarkus.container-image.build=true build quarkus.java`
 * and it builds a docker image.
 */
//DEPS io.quarkus:quarkus-resteasy:${q.v:1.8.0.CR1}
//DEPS io.quarkus:quarkus-container-image-jib:${q.v:1.8.0.CR1}
//DEPS io.quarkus:quarkus-kubernetes:${q.v:1.8.0.CR1}
//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager
//Q:CONFIG quarkus.container-image.name=quarkusjbangdemo

import io.quarkus.runtime.Quarkus;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("/hello")
@ApplicationScoped
public class quarkusjib {

    @GET
    public String sayHello() {
        return "hello from Quarkus with jbang.dev";
    }

    public static void main(String[] args) {
        Quarkus.run(args);
    }
}

run that with jbang --verbose -Dq.v=999-SNAPSHOT quarkusjib.java and you get:

dev.jbang.ExitException: Issue running postBuild()
    at dev.jbang.IntegrationManager.runIntegration(IntegrationManager.java:116)
    at dev.jbang.cli.Run.build(Run.java:206)
    at dev.jbang.cli.Run.doCall(Run.java:96)
    at dev.jbang.cli.BaseCommand.call(BaseCommand.java:59)
    at dev.jbang.cli.BaseCommand.call(BaseCommand.java:13)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
    at picocli.CommandLine.access$1100(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)
Caused by: java.lang.reflect.InvocationTargetException
    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:89)
    ... 12 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at io.quarkus.launcher.JBangIntegration.postBuild(JBangIntegration.java:85)
    ... 17 more
Caused by: java.lang.reflect.InvocationTargetException
    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)
    ... 17 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.IllegalStateException: Could not find matching project info read
    at io.dekorate.project.FileProjectFactory.lambda$createInternal$0(FileProjectFactory.java:60)
    at java.base/java.util.Optional.orElseThrow(Optional.java:408)
    at io.dekorate.project.FileProjectFactory.createInternal(FileProjectFactory.java:60)
    at io.dekorate.project.FileProjectFactory.create(FileProjectFactory.java:41)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.createProject(KubernetesProcessor.java:936)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.build(KubernetesProcessor.java:314)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:479)

    at io.quarkus.bootstrap.JBangBuilderImpl.postBuild(JBangBuilderImpl.java:81)
    ... 22 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.IllegalStateException: Could not find matching project info read
    at io.dekorate.project.FileProjectFactory.lambda$createInternal$0(FileProjectFactory.java:60)
    at java.base/java.util.Optional.orElseThrow(Optional.java:408)
    at io.dekorate.project.FileProjectFactory.createInternal(FileProjectFactory.java:60)
    at io.dekorate.project.FileProjectFactory.create(FileProjectFactory.java:41)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.createProject(KubernetesProcessor.java:936)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.build(KubernetesProcessor.java:314)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:479)

    at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:132)
    at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:82)
    at io.quarkus.bootstrap.JBangBuilderImpl.postBuild(JBangBuilderImpl.java:78)
    ... 22 more
Caused by: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.IllegalStateException: Could not find matching project info read
    at io.dekorate.project.FileProjectFactory.lambda$createInternal$0(FileProjectFactory.java:60)
    at java.base/java.util.Optional.orElseThrow(Optional.java:408)
    at io.dekorate.project.FileProjectFactory.createInternal(FileProjectFactory.java:60)
    at io.dekorate.project.FileProjectFactory.create(FileProjectFactory.java:41)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.createProject(KubernetesProcessor.java:936)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.build(KubernetesProcessor.java:314)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:479)

    at io.quarkus.deployment.jbang.JBangAugmentorImpl.accept(JBangAugmentorImpl.java:119)
    at io.quarkus.deployment.jbang.JBangAugmentorImpl.accept(JBangAugmentorImpl.java:36)
    at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:129)
    ... 24 more
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.IllegalStateException: Could not find matching project info read
    at io.dekorate.project.FileProjectFactory.lambda$createInternal$0(FileProjectFactory.java:60)
    at java.base/java.util.Optional.orElseThrow(Optional.java:408)
    at io.dekorate.project.FileProjectFactory.createInternal(FileProjectFactory.java:60)
    at io.dekorate.project.FileProjectFactory.create(FileProjectFactory.java:41)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.createProject(KubernetesProcessor.java:936)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.build(KubernetesProcessor.java:314)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:479)

    at io.quarkus.builder.Execution.run(Execution.java:116)
    at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
    at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:149)
    at io.quarkus.deployment.jbang.JBangAugmentorImpl.accept(JBangAugmentorImpl.java:97)
    ... 26 more
Caused by: java.lang.IllegalStateException: Could not find matching project info read
    at io.dekorate.project.FileProjectFactory.lambda$createInternal$0(FileProjectFactory.java:60)
    at java.base/java.util.Optional.orElseThrow(Optional.java:408)
    at io.dekorate.project.FileProjectFactory.createInternal(FileProjectFactory.java:60)
    at io.dekorate.project.FileProjectFactory.create(FileProjectFactory.java:41)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.createProject(KubernetesProcessor.java:936)
    at io.quarkus.kubernetes.deployment.KubernetesProcessor.build(KubernetesProcessor.java:314)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:479)
quarkusbot commented 4 years ago

/cc @geoand /cc @quarkusio/devtools

geoand commented 4 years ago

cc @iocanel

maxandersen commented 4 years ago

remove kubernetes and it does not complain. i think its just a matter of understanding what dekorate are looking for and if its just a question about jbang/quarkus spi makes a builditem available with a directory it can write to to mimic target from maven ?

geoand commented 4 years ago

Yeah, it should be easily fixable :)

I pinged Ioannis since he is the dekorate internals master and would definitely be able to fix this much faster than I could

iocanel commented 4 years ago

Will have a fix probably today or tomorrow

On Tue, Sep 8, 2020, 2:52 PM Georgios Andrianakis notifications@github.com wrote:

Yeah, it should be easily fixable :)

I pinged Ioannis since he is the dekorate internals master and would definitely be able to fix this much faster than I could

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/quarkusio/quarkus/issues/11971#issuecomment-688816764, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADCEWEGYNKK4S7IECRAOLTSEYLGHANCNFSM4Q73VTJA .

iocanel commented 4 years ago

@maxandersen: Do I remember correctly that you mentioned its not a TCCL issue after all?

iocanel commented 4 years ago

Hmmm, with jbang we don't have a pom.xml, build.gradle, etc, so this is why the project can't be properly detected.

We have two options here:

@maxandersen @geoand: Thoughts?

maxandersen commented 4 years ago

@iocanel the TCCL issue was a false alarm - could still occur but latest fix in how quarkus integrates with jbang ensures you shouldn't get affected by classes loaded by jbang itself which turned out was the case earlier.

I can add some jbang.* properties for sure if that is deemed helpful - but I would imagine best isolation/decoupling is that quarkus is the one taking that info together with what it needs and drive dekorate rather than direct coupling between jbang and dekorate (at least in case of via quarkus) ?

What is the module root you are after exactly ? what corresponds to /target or the source / project or /target/classes ? what is dekorate specifically looking for ?

geoand commented 4 years ago

Is there any way dekorate could operate without that information?

iocanel commented 4 years ago

When used outside of quarkus, dekorate tries to detect things like the module root (the dir that contains src the pom.xml etc). It needs those so that it gets to the application.properties, detect things like project name, version, build tool etc and in some cases to use the directory from which builds will be triggered, etc.

When used with Quarkus, most of the information is provided by quarkus, but only to enrich what dekorate didn't figure on its own. I think that the module root is one of them. Let me try and see if we can work around it and I'll get back to you.

iocanel commented 4 years ago

Is there any way dekorate could operate without that information?

Technically, it should be possible. But it might need some touches to the upstream project.

aloubyansky commented 4 years ago

There are: 1) CurateOutcomeBuildItem.getEffectiveModel() that returns AppModel which contains the root plus all its deps (from the workspace or the repo) 2) ApplicationArchivesBuildItem.getRootArchive(). Is that insufficient?

geoand commented 3 years ago

I recently added io.quarkus.kubernetes.spi.CustomProjectRootBuildItem for the purpose of supporting the @QuarkusProdModeTest, but it might be useful in this case as well. Basically, we just need to customize the build chain to add this build item when augmentation from JBang takes place