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

最后都变了- 提交于 2021-01-27 17:20:01

问题


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": "axp.payments.pci.dss.PaymentsPciDssDispatcher"
  }

  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?

来源:https://stackoverflow.com/questions/58755410/how-to-create-micronauts-fat-jar-without-shadow-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!