Java Micronaut-shadow fat jar插件不适用于公司回购协议
我正在为一个项目使用框架,Micronaut CLI使用Java Micronaut-shadow fat jar插件不适用于公司回购协议,java,gradle,netty,gradle-plugin,micronaut,Java,Gradle,Netty,Gradle Plugin,Micronaut,我正在为一个项目使用框架,Micronaut CLI使用com.github.johnrengelman.shadowgradle插件生成项目,当我使用- $ java -Dmicronaut.environments=E1 -jar build/appBundle/app.jar build.gradle- plugins { id "com.github.johnrengelman.shadow" version "5.0.0" } ... shadowJar { merg
com.github.johnrengelman.shadow
gradle插件生成项目,当我使用-
$ java -Dmicronaut.environments=E1 -jar build/appBundle/app.jar
build.gradle-
plugins {
id "com.github.johnrengelman.shadow" version "5.0.0"
}
...
shadowJar {
mergeServiceFiles()
}
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) }
}
}
apply plugin: "com.github.johnrengelman.shadow"
plugins {
id "com.github.johnrengelman.shadow"
}
问题是由于某种原因,com.github.johnrengelman.shadow
插件无法与Jenkins一起使用,我怀疑它在我们的公司回购协议中不可用(并且无法添加)。虽然我能够使用java
插件的jar
任务创建一个可执行的胖jar,但它失败了,出现以下错误-
$ 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 "com.github.johnrengelman.shadow" version "5.0.0"
}
...
shadowJar {
mergeServiceFiles()
}
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) }
}
}
apply plugin: "com.github.johnrengelman.shadow"
plugins {
id "com.github.johnrengelman.shadow"
}
主要问题是为什么
com.github.johnrengelman.shadow
插件不能与公司存储库一起工作?有一种方法可以解决这种令人恼火的情况
您可以从GitHub下载源代码,并将其添加到/buildSrc
目录下的Micronaut应用程序存储库中
您可以按照本指南创建自定义插件
使用这种方法,影子插件就在你的代码库中,你可以不用下载就可以使用它
最后一个想法。一家公司不允许你在公司存储库中代理像这个插件这样的开源软件,这会妨碍你的工作。你可能想和你的经理谈谈
我所描述的解决方法是可怕的,因为
- 你必须根据源代码升级插件
- 它很可能很快就会过时
- 这根本不是解决问题的办法
祝你好运。希望这有帮助。解决了 问题是插件{…}块不能访问私有/公司回购协议 通过将插件定义从
plugins{…}
恢复为较旧的定义方式,即apply plugin…
添加了应用插件的旧方法(这是使其与私有回购一起工作的唯一方法)-
plugins {
id "com.github.johnrengelman.shadow" version "5.0.0"
}
...
shadowJar {
mergeServiceFiles()
}
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) }
}
}
apply plugin: "com.github.johnrengelman.shadow"
plugins {
id "com.github.johnrengelman.shadow"
}
已删除(不访问私人/公司回购协议)-
plugins {
id "com.github.johnrengelman.shadow" version "5.0.0"
}
...
shadowJar {
mergeServiceFiles()
}
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) }
}
}
apply plugin: "com.github.johnrengelman.shadow"
plugins {
id "com.github.johnrengelman.shadow"
}
欲了解更多信息,请查看此处的第一条评论。我不确定这是我想要的方式。有一个样本项目,似乎是与影子插件和公司回购工作。让我来探讨一下,我想了解的是嵌入式服务器bean是如何被注入shadowplugin的,而不是其他方面吗?
/gradlew assembly
是否创建了您想要的?