Как я могу объединить ВОЕННУЮ упаковку и создание пакета OSGi в Знатоке?

Я главным образом использую, ПОЗВОЛЯЮТ, если я specifgically не должен ПОЗВОЛИТЬ*, но иногда я пишу код, которому явно потребности ПОЗВОЛЯЮТ, обычно при выполнении различный (обычно сложный) установка по умолчанию. К сожалению, у меня нет удобного примера кода под рукой.

8
задан Hanno Fietz 20 October 2009 в 07:58
поделиться

1 ответ

One way to (more or less) achieve this is described on OPS4J Wiki page -- "Getting the benefits of maven-bundle-plugin in other project types".

You can configure dependency embedding and Bundle-ClassPath directive in your pom.xml to match the locations used by WAR plugin. The maven-bundle-plugin will then generate correct manifest headers.

The instructions for maven-bundle-plugin might look like this:

<instructions>
    <Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</Bundle-ClassPath>

    <Embed-Directory>WEB-INF/lib</Embed-Directory>
    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
    <Embed-Transitive>true</Embed-Transitive>
    <!-- ... -->
</instructions>

ETA: When using this approach, I found out two noteworthy things:

  • the bundle plugin will complain about missing WEB-INF directories, because when the manifest goal is executed, the war plugin has not yet created them (it only runs at a later phase)
  • although it doesn't make sense for the actual webapp, the Bundle-ClassPath directive must contain ".", or the bundle plugin will mess up the Import-Packages header. I found this in some JIRA issue via Google, but I can't find the URL anymore.

Other than that it works fine.

19
ответ дан 5 December 2019 в 08:53
поделиться
Другие вопросы по тегам:

Похожие вопросы: