如何使用Quarkus-Gradle-Plugin

时间:2019-03-29 15:54:48

标签: java gradle-plugin quarkus

我正在尝试使用Quarkus Gradle插件构建具有所有依赖项(可运行)的uberJar。 使用maven,您可以通过向插件添加配置来构建它。

这就是maven的样子:

<plugin>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-maven-plugin</artifactId>
    <version>${quarkus.version}</version>
    <configuration>
        <uberJar>true</uberJar>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>build</goal>
            </goals>
        </execution>
    </executions>
</plugin>

是否可以在gradle插件中设置此属性? id'io.quarkus.gradle.plugin'版本'0.12.0'

3 个答案:

答案 0 :(得分:1)

该选项的名称为“ uber-jar”。 要设置此属性,您必须从命令行像这样开始构建:

>gradle quarkusBuild --uber-jar

在构建过程中我遇到了一些错误,例如

Caused by: java.nio.file.NoSuchFileException: /Users/sven/Idea/getting-started/build/getting-started.jar

但最终构建成功

答案 1 :(得分:0)

quarkusBuild任务包含一个名为uberJar的属性,可用于控制uberJar行为(请参见this)。

答案 2 :(得分:0)

您可以使用以下类似的方法直接在build.gradle中配置任务:

task buildUberJar(type: io.quarkus.gradle.tasks.QuarkusBuild, dependsOn: build) {
    uberJar = true
}

但是,通过这种方法,我发现许多问题存在于罐子之间重叠的资源上。这是我的输出的子集:

> Task :service-asset-management:buildUberJar
building quarkus runner

Duplicate entry META-INF/quarkus-extension.json entry from io.quarkus:quarkus-jackson::jar:0.26.1(runtime) will be ignored. Existing file was provided by io.quarkus:quarkus-kubernetes-client::jar:0.26.1(runtime)
Duplicate entry NOTICE entry from org.apache.kafka:kafka-clients::jar:2.2.1(runtime) will be ignored. Existing file was provided by org.ehcache:ehcache::jar:3.6.1(runtime)
Duplicate entry META-INF/quarkus-extension.json entry from io.quarkus:quarkus-arc::jar:0.26.1(runtime) will be ignored. Existing file was provided by io.quarkus:quarkus-kubernetes-client::jar:0.26.1(runtime)
Duplicate entry META-INF/quarkus-extension.json entry from io.quarkus:quarkus-core::jar:0.26.1(runtime) will be ignored. Existing file was provided by io.quarkus:quarkus-kubernetes-client::jar:0.26.1(runtime)
Dependencies with duplicate files detected. The dependencies [org.apache.kafka:kafka-clients::jar:2.2.1(runtime), org.ehcache:ehcache::jar:3.6.1(runtime)] contain duplicate files, e.g. NOTICE
Dependencies with duplicate files detected. The dependencies [io.quarkus:quarkus-core::jar:0.26.1(runtime), io.quarkus:quarkus-jackson::jar:0.26.1(runtime), io.quarkus:quarkus-kubernetes-client::jar:0.26.1(runtime), io.quarkus:quarkus-arc::jar:0.26.1(runtime)] contain duplicate files, e.g. META-INF/quarkus-extension.json
Dependencies with duplicate files detected. The dependencies [commons-logging:commons-logging::jar:1.2(runtime), org.slf4j:jcl-over-slf4j::jar:1.7.25(runtime)] contain duplicate files, e.g. org/apache/commons/logging/impl/SimpleLog$1.class