I am using Micronaut framework for a project and Micronaut CLI generates 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()
}
The issue is that com.github.johnrengelman.shadow
plugin is not working with Jenkins for some reason and I am suspecting that it's not available in our corporate repo(and can't be added). While I am able to create an executable fat-jar using jar
task of java
plugin, 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) }
}
}
Primary ask is why wouldn't com.github.johnrengelman.shadow
plugin work with a corporate repository?
Solved
The issue was that plugin{...} block doesn't access private/corporate repo.
Solved it by reverting plugin definition from plugins{...}
to older way of definition which is apply plugin...
Added older way of applying plugin (which is the only way to make it work with private repo)-
apply plugin: "com.github.johnrengelman.shadow"
Removed (doesn't access private/corporate repo)-
plugins {
id "com.github.johnrengelman.shadow"
}
For more info, checkout first comment in this SO question.