仅在Gradle项目中编译Storm风格的JAR [英] Making the Storm JARs compile-time only in a Gradle project

查看:124
本文介绍了仅在Gradle项目中编译Storm风格的JAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个包含Storm项目的Gradle项目。为了在Storm上运行这个项目,我必须先创建一个JAR文件,让Storm运行我的拓扑结构,例如 jar myJarFile.jar com.mypackage.MyStormMainClass

我遇到问题了,因为默认情况下,Gradle是包括编译时和运行时的Storm依赖关系。这会导致以下异常:

 线程main中的异常java.lang.RuntimeException:找到多个defaults.yaml资源。您可能会将Storm Jars与拓扑jar捆绑在一起。 

给出的异常实际上是有帮助的,并且提示我们解决问题的根本原因。解决方案是在使用Gradle进行编译时包含Storm依赖项,但在生成最终JAR文件时不包括。



有谁知道如何解决这个问题? StackOverflow上的其他帖子没有解决问题。如果您粘贴代码,请确保它真正运行。



谢谢!

解决方案

下面我引用了我的 暴风雨用户邮件中的类似帖子列表



在我的情况下,我选择使用 fatJar plugin for Gradle for the purpose。

  buildscript {
存储库{
mavenCentral()
mavenRepo url:http://clojars.org/repo
}
依赖关系{
//请参阅https:/ /github.com/musketyr/gradle-fatjar-plugin
classpath'eu.appsatori:gradle-fatjar-plugin:0.2-rc1'
}
}

//当使用这个插件时,你可以建立一个胖的jar / ub erjar with'gradle fatJar'
apply plugin:'fatjar'

dependencies {
compile'storm:storm:0.8.2',{
ext {
fatJarExclude = true
}
}
}

您通过以下方式构建fat jar:

  $ gradle clean fatJar 

Best,
Michael



PS:为什么值得我博客讨论如何解决这个问题如上所述运行多节点风暴群集。这篇文章包含了一些额外的信息和细节,可能会对您有所帮助或者可能不会有帮助。


I am trying to build a Gradle project which contains a Storm project. In order to run this project on Storm, I have to first create a JAR file and let Storm run my topology, e.g.

storm jar myJarFile.jar com.mypackage.MyStormMainClass

I am running into problems because Gradle, by default, is including the Storm dependencies both at compile time and runtime. This causes the following exception:

Exception in thread "main" java.lang.RuntimeException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar.

The Exception given is actually helpful, and tips us off to the root cause of the problem. The solution is to include the Storm dependencies when compiling with Gradle, but not when generating the final JAR file.

Does anyone know how to resolve this? The other posts on StackOverflow did not solve the problem. If you paste code please ensure that it actually runs.

Thanks!

解决方案

Below I am quoting an answer of mine to a similar thread on the storm-user mailing list.

In my case I opted to use the fatJar plugin for Gradle for that purpose.

buildscript {
    repositories {
        mavenCentral()
        mavenRepo url: "http://clojars.org/repo"
    }
    dependencies {
        // see https://github.com/musketyr/gradle-fatjar-plugin
        classpath 'eu.appsatori:gradle-fatjar-plugin:0.2-rc1'
    }
}

// When using this plugin you can build a fat jar / uberjar with 'gradle fatJar'
apply plugin: 'fatjar'

dependencies {
    compile 'storm:storm:0.8.2', {
        ext {
            fatJarExclude = true
        }
    }
}

You build the fat jar via:

$ gradle clean fatJar

Best, Michael

PS: For what it's worth I also blogged about how to solve this problem as described above at Running a Multi-Node Storm Cluster. That post contains additional pieces of information and gotchas that may or may not be helpful to you.

这篇关于仅在Gradle项目中编译Storm风格的JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆