无法将Maven Central Repository与bnd一起使用来解决依赖关系 [英] Unable to use Maven Central Repository with bnd to resolve dependencies
问题描述
在Eclipse Oxygen.2版本(4.7.2)中,我试图使用bndtools制作一些OSGi软件包.
With Eclipse Oxygen.2 Release (4.7.2), I'm trying to use bndtools to make some OSGi bundles.
默认情况下(使用JPM存储库),我能够很好地解决依赖关系.但是我无法看到那里有什么库.因此,我想使用Maven Central来处理我的依赖项.我可以浏览该网站,查看其中的版本,然后根据该信息进行选择.
By default (with the JPM repository) I am able to resolve dependencies fine. But I have no way of seeing what libraries are there. Because of this, I'd like to use Maven Central to handle my dependencies. I can browse the website, see what versions are there, and make choices on that information.
cnf
项目中的默认build.bnd
文件的存储库设置类似于
The default build.bnd
file in the cnf
project has the repositories setup like
# Configure Repositories
-plugin.1.Central: \
aQute.bnd.deployer.repository.wrapper.Plugin; \
location = "${build}/cache/wrapper"; \
reindex = true, \
aQute.bnd.jpm.Repository; \
includeStaged = true; \
name = Central; \
location = ~/.bnd/shacache; \
index = ${build}/central.json
-plugin.2.Local: \
aQute.bnd.deployer.repository.LocalIndexedRepo; \
name = Local; \
pretty = true; \
local = ${build}/local
-plugin.3.Templates: \
aQute.bnd.deployer.repository.LocalIndexedRepo; \
name = Templates; \
pretty = true; \
local = ${build}/templates
-plugin.4.Release: \
aQute.bnd.deployer.repository.LocalIndexedRepo; \
name = Release; \
pretty = true; \
local = ${build}/release
按照bnd网站上的说明 ,我在文件中添加了以下内容;因为已经有一个Central
存储库,所以我将其命名为Maven
,但其余的都相同
Following the instructions on the bnd website I added the following to my file; because there was already a Central
repository, I named this one Maven
but the rest is the same
-plugin.5.Maven = \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
releaseUrl=https://repo.maven.apache.org/maven2/; \
index="${.}/central.maven"; \
name="Maven"
当我删除JPM存储库时,突然一切都坏了.这并不让人感到意外,因为我只是删除了一个存储库.但是,我认为在构建和清理工作区之后,它将解决我们可以访问Maven Central的问题,并且可以从那里进行拉动.事实并非如此.
When I remove the JPM repository, suddenly everything is broken. This didn't come as too much of a surprise, because I did just remove a repository. However, I thought that after building and cleaning the workspace, it would resolve that we can access maven central, and it would pull from there. This was not the case.
我注意到Maven存储库中有一个index
属性,所以我认为也许我必须将所有依赖项名称添加到指定的文件中,但是我无法找到有关该文件的任何文档.该文件的外观,创建方式或类似的内容.
I noticed that there was an index
property on the Maven repository, so I thought that perhaps I had to add all of my dependency names to the file specified, but I haven't been able to find any documentation on what the file looks like, or how to create one, or anything of the sort.
我在Eclipse中遇到的错误是
The errors that I get in Eclipse are
找不到/error/org.apache.servicemix.bundles.junit;version=4.12在[bnd-cache [PATH \ TO \ WORKSPACE \ cnf \ cache \ 3.5.0 \ bnd-cache r/w = false],本地,模板,发行版,MavenBndRepository [localRepo = PATH \ TO \ USER \ FOLDER.m2 \ repository,storage = Maven,inited = true]]
Cannot find /error/org.apache.servicemix.bundles.junit;version=4.12 Not found in [bnd-cache [PATH\TO\WORKSPACE\cnf\cache\3.5.0\bnd-cache r/w=false], Local, Templates, Release, MavenBndRepository [localRepo=PATH\TO\USER\FOLDER.m2\repository, storage=Maven, inited=true]]
在整个过程中是否缺少某些内容?有什么明显的我想念的吗?
Is there something I'm missing in this whole process? Is there something obvious I've missed?
推荐答案
I found out (thanks to the OSGi enroute tutorial), what I was missing.
在指定位置需要有一个现有的索引文件,该文件由maven坐标项组成. jpm索引仅需要工件ID和版本,而Maven坐标则需要组,工件和版本.
There needs to be an existing index file at the specified location, and that file is made up of maven coordinate entries. The jpm index only needed the artifact id and version, but the maven coordinates require group, artifact, and version.
我修改了cnf/build.bnd
条目,使其看起来像
I modified my cnf/build.bnd
entry to look like
-plugin.5.Central = \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
releaseUrl=https://repo.maven.apache.org/maven2/; \
name="Central"
我删除了索引文件规范,这样它将只使用默认值(cnf/<name>.mvn
).但是,我不确定文档在谈论哪个名称.我确定这是在存储库设置中指定的名称. name="<ThisValueHere>"
,而不是-plugin.5.<ThisValueHere>
.请注意,此值不区分大小写.
I removed the index file specification, that way it would just use the default (cnf/<name>.mvn
). However, I wasn't sure which name the documentation was talking about. I determined that it was the name specified inside the repository settings. name="<ThisValueHere>"
, not -plugin.5.<ThisValueHere>
. Note that this value is not case-sensitive.
我的central.mvn
文件最终看起来像
org.apache.felix:org.apache.felix.framework:5.4.0
org.apache.felix:org.apache.felix.gogo.command:1.0.2
org.apache.felix:org.apache.felix.gogo.runtime:1.0.10
org.apache.felix:org.apache.felix.gogo.shell:1.0.0
org.apache.felix:org.apache.felix.log:1.0.1
org.apache.felix:org.apache.felix.scr:2.0.14
org.apache.servicemix.bundles:org.apache.servicemix.bundles.junit:4.12_1
org.osgi:osgi.annotation:6.0.1
org.osgi:osgi.cmpn:6.0.0
org.osgi:osgi.core:6.0.0
这篇关于无法将Maven Central Repository与bnd一起使用来解决依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!