'How to create Micronaut's fat-jar without shadow plugin?

What started as a roadblock to setup a new Micronaut project with corporate repo, is now more about curiosity of how Embedded server is bootstrapped. I have a Micronaut CLI generated project with com.github.johnrengelman.shadow gradle plugin which works fine when I run the jar using-

$ java -Dmicronaut.environments=E1 -jar build/appBundle/app.jar

build.gradle-

plugins {
  id "com.github.johnrengelman.shadow" version "5.0.0"
}

...

shadowJar {
    mergeServiceFiles()
}

When I replace shadow plugin/task with jar task and java plugin, then I am able to create an executable fat-jar , but it fails with following error-

$ java -Dmicronaut.environments=E1 -jar build/appBundle/app.jar
16:12:22.662 [main] INFO  i.m.context.env.DefaultEnvironment - Established active environments: [E1]
16:12:22.863 [main] INFO  io.micronaut.runtime.Micronaut - No embedded container found. Running as CLI application

build.gradle-

plugins {
  id "java"
}

...

jar {
  manifest {
    attributes "Main-Class": "foo.bar.someclass"
  }

  from {
    configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
  }
}
  1. What I would like to understand is how the embedded server bean is getting injected with shadow plugin but not otherwise?
  2. How to create a fat-jar with embedded Netty server and without using com.github.johnrengelman.shadow gradle plugin?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source