在OSGi中运行时,如何将groovy-all从2.4升级到2.5? [英] How to upgrade groovy-all from 2.4 to 2.5 when running in OSGi?

查看:252
本文介绍了在OSGi中运行时,如何将groovy-all从2.4升级到2.5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在维护一个部分基于Groovy的开源库,名为 Rest Assured .在下一个版本中,我想将Groovy依赖项从2.4.x升级到2.5.x.但是,这样做时,在运行OSGi测试时会遇到问题.测试使用的是 Pax考试,它们通常看起来像:

I'm maintaining an open source library based partly on Groovy called Rest Assured. In the next version I'd like to upgrade the Groovy dependency from 2.4.x to 2.5.x. However when doing this I run into issues when running the OSGi tests. The tests are using Pax Exam they typically look something like this:

@RunWith(PaxExam.class)
public class XmlPathOSGiITest {

    @Configuration
    public static Option[] configure() {
        return new Option[]
                {
                        mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.hamcrest", "1.3_1"),
                        junitBundles(),
                        systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
                        systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),

                        /* Transitive dependencies needed in the Pax Exam container.
                        Some of these need to be wrapped because they are not available as OSGi bundles */
                        mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
                        wrappedBundle(mavenBundle().groupId("org.ccil.cowan.tagsoup").artifactId("tagsoup").versionAsInProject()),
                        wrappedBundle(mavenBundle("javax.xml.bind", "jaxb-api").versionAsInProject()),
                        wrappedBundle(mavenBundle("javax.activation", "activation").version("1.1.1")),
                        wrappedBundle(mavenBundle().groupId("org.codehaus.groovy").artifactId("groovy-all").version("2.5.6")),
                        wrappedBundle(mavenBundle("org.apache.httpcomponents", "httpclient").versionAsInProject()),
                        wrappedBundle(mavenBundle("org.apache.httpcomponents", "httpmime").versionAsInProject()),
                        wrappedBundle(mavenBundle("org.apache.httpcomponents", "httpcore").versionAsInProject()),

                        /* Rest Assured dependencies needed in the Pax Exam container to be able to execute the tests below */
                        mavenBundle("io.rest-assured", "json-path").versionAsInProject(),
                        mavenBundle("io.rest-assured", "xml-path").versionAsInProject(),
                        mavenBundle("io.rest-assured", "rest-assured").versionAsInProject(),
                        mavenBundle("io.rest-assured", "rest-assured-common").versionAsInProject()
                };
    }

    @Test
    public void getUUIDParsesAStringResultToUUID() {
        final String UUID_XML = "<some>\n" +
                "  <thing id=\"1\">db24eeeb-7fe5-41d3-8f06-986b793ecc91</thing>\n" +
                "  <thing id=\"2\">d69ded28-d75c-460f-9cbe-1412c60ed4cc</thing>\n" +
                "</some>";

        final UUID uuid = from(UUID_XML).getUUID("some.thing[0]");

        assertThat(uuid, Matchers.equalTo(UUID.fromString("db24eeeb-7fe5-41d3-8f06-986b793ecc91")));
    }
}

运行此测试将导致错误:

Running this test will cause an error:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.86 sec <<< FAILURE! - in io.restassured.test.osgi.XmlPathOSGiITest
getUUIDParsesAStringResultToUUID(io.restassured.test.osgi.XmlPathOSGiITest)  Time elapsed: 1.85 sec  <<< ERROR!
java.io.IOException: Error resolving artifact org.codehaus.groovy:groovy-all:jar:2.5.6: Could not find artifact org.codehaus.groovy:groovy-all:jar:2.5.6 in central (http://repo1.maven.org/maven2/)
        at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:626)

兴趣点可能是这条线:

wrappedBundle(mavenBundle().groupId("org.codehaus.groovy").artifactId("groovy-all").version("2.5.6")),

当指定Groovy使用version 2.4.15时,一切工作正常.所以我的问题是:

Everything was working fine when the Groovy was specified to use version 2.4.15. So my questions is:

在过去依赖2.4的groovy-all jar时,如何在OSGi上下文中将Groovy从2.4升级到2.5?我如何在测试中体现这一点?

How do I upgrade Groovy from 2.4 to 2.5 in an OSGi context when having depended on the groovy-all jar from 2.4 in past? And how do I reflect this in the test?

推荐答案

事实证明,在选择了正确的工件(在这种情况下为groovy和groovy-json)之后,您需要

It turns out that after choosing the correct artifacts, in this case groovy and groovy-json, you need Apache Aries SPI Fy as well.

mavenBundle().groupId("org.apache.aries.spifly").artifactId("org.apache.aries.spifly.dynamic.bundle").version("1.2.1")

如果您不添加该捆绑包,那么groovy-json OSGi Fragment捆绑包将无法得到解决,而在日志记录中没有任何有关原因的提示.

If you don't add that bundle, the groovy-json OSGi Fragment bundle does not get RESOLVED, without any hints about the cause in the logging.

这篇关于在OSGi中运行时,如何将groovy-all从2.4升级到2.5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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