简体   繁体   English

Gradle子项目jar并添加到Eclipse引用的库

[英]Gradle subproject jar and add to Eclipse referenced libraries

I have a repo at http://www.github.com/kourbou/HyperQuest . 我在http://www.github.com/kourbou/HyperQuest上有一个仓库。 I have a git submodule to a project called SpongeAPI. 我有一个名为SpongeAPI的项目的git子模块。 I would like to add the compiled jar of the subproject to the Eclipse project automatically but I have failed at doing so. 我想将子项目的编译jar自动添加到Eclipse项目中,但是这样做失败。 I have added this to my gradle.build : 我已经将此添加到我的gradle.build中:

dependencies 
{
    jar project('SpongeAPI')
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

But the build fails and this happens: 但是构建失败,并且发生了:

A problem occurred evaluating root project 'HyperQuest'.
> Could not find method jar() for arguments [project ':SpongeAPI'] on root project 'HyperQuest'.

Could someone give me an example or write a gist of a build.gradle that works? 有人可以给我一个例子或写一个有用的build.gradle的要旨吗? Thanks. 谢谢。

Either set up multi-project build or publish the output of SpongeAPI into some repository and consume it from that place. 设置多项目构建或将SpongeAPI的输出发布到某个存储库中,然后从该位置使用它。

Multi-project build is described in http://www.gradle.org/docs/current/userguide/tutorial_java_projects.html#sec:examples - you will add settings.gradle that will include SpongeAPI and then the dependency is like compile project(':SpongeAPI') . 多项目打造的是在描述http://www.gradle.org/docs/current/userguide/tutorial_java_projects.html#sec:examples -您将添加settings.gradle ,其中将包括SpongeAPI再依赖就像是compile project(':SpongeAPI')

The publish approach means that you will upload the artifact from SpongeAPI build into a repository and your build will add this repository (like you add mavenCentral() or jcenter() ) and refer to your artifact using common notation. 发布方法意味着您将把SpongeAPI构建中的工件上传到存储库中,并且您的构建将添加该存储库(就像您添加mavenCentral()jcenter() )并使用通用符号引用您的工件。 Again there is a documentation to help you with that - http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html#N10669 再次有一个文档可以帮助您-http: //www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html#N10669

I know you posted this early on in SpongeAPI's development, but I'll add this here for future readers. 我知道您在SpongeAPI的开发早期就发布了此内容,但我将在此处添加此内容,以供将来的读者使用。

By including SpongeAPI as a git-submodule, you are potentially tying your plugin to a specific, in development version of the API. 通过将SpongeAPI作为git-submodule包含在内,您可能会将插件与特定的API开发版本绑定在一起。

Instead, we provide a maven repository that you should use at https://repo.spongepowered.org/maven/ 相反,我们提供了一个Maven存储库,您应该在https://repo.spongepowered.org/maven/上使用

When using a version of SpongeAPI you MUST stick to released API versions, and not snapshots. 使用SpongeAPI版本时,您必须坚持发布的API版本,而不是快照。

Otherwise your plugin has the potential to break on dev releases of the API. 否则,您的插件可能会破坏API的开发版本。

You can read up to date information on how to set up a Sponge Plugin project here: https://docs.spongepowered.org/stable/en/plugin/project/index.html 您可以在此处阅读有关如何设置海绵插件项目的最新信息: https : //docs.spongepowered.org/stable/en/plugin/project/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM