如何从 features.xml 和 jars 手动创建 Karaf kar 文件

How to manually create a Karaf kar file from features.xml and jars

我想手动创建一个 Karaf kar 文件。

因为我有一个可以工作的 feature.xml 文件和 feature.xml 文件引用的 jar 文件,我想如果我创建一个 jar 文件,将它重命名为 filename.kar 那么它应该工作。

但是卡拉夫说:

2017-02-09 14:21:50,171 | INFO  | raf-4.0.8/deploy | KarArtifactInstaller             | 27 - org.apache.karaf.deployer.kar - 4.0.8 | Found a .kar file to deploy.
2017-02-09 14:21:50,172 | INFO  | raf-4.0.8/deploy | KarArtifactInstaller             | 27 - org.apache.karaf.deployer.kar - 4.0.8 | Installing KAR file C:\home\software\apache-karaf-4.0.8\apache-karaf-4.0.8\deploy\JMScalaJS.kar

但是 - 它没有做任何其他事情,当我这样做时该功能不可用 feature:list。

我的 JMScalaJS.kar 文件包含:

feature.xml
jmscalajs_2.11-0.1-SNAPSHOT.jar
neo4j-java-driver-1.0.5.jar
neo4j-ogm-osgi_2.11.jar
scaldi_2.11-0.5.8.jar

然后我的feature.xml包含

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features name="JMScalaJS" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
    <repository>mvn:org.apache.camel.karaf/apache-camel/2.18.2/xml/features</repository>
    <feature description="JMScalaJS" version="0.1.0" name="JMScalaJS">
        <feature prerequisite="true" dependency="false">wrap</feature>
        <feature>camel-scala</feature>
        <feature>camel-core</feature>
        <feature>camel-ftp</feature>
        <feature>camel-exec</feature>
        <feature>camel-stream</feature>
        <feature>camel</feature>
        <bundle>wrap:mvn:com.jcraft/jzlib/1.1.3</bundle>
        <bundle>wrap:mvn:com.github.kxbmap/configs_2.11/0.4.4</bundle>
        <bundle>mvn:com.chuusai/shapeless_2.11/2.3.2</bundle>
        <bundle>mvn:commons-lang/commons-lang/2.6</bundle>
        <bundle>mvn:org.apache.commons/commons-exec/1.3</bundle>
        <bundle>mvn:commons-net/commons-net/3.3</bundle>
        <bundle>wrap:mvn:com.jcraft/jsch/0.1.54</bundle>
        <bundle>mvn:com.typesafe/config/1.3.1</bundle>
        <bundle>mvn:com.typesafe.scala-logging/scala-logging_2.11/3.5.0</bundle>
        <bundle>mvn:org.apache.commons/commons-collections4/4.1</bundle>
        <bundle>mvn:commons-codec/commons-codec/1.10</bundle>
        <bundle>mvn:ch.qos.logback/logback-classic/1.1.7</bundle>
        <bundle>mvn:ch.qos.logback/logback-core/1.1.7</bundle>
        <bundle>mvn:commons-logging/commons-logging/1.2</bundle>
        <bundle>wrap:mvn:commons-httpclient/commons-httpclient/3.1</bundle>
        <bundle>wrap:mvn:org.apache.lucene/lucene-sandbox/6.2.0</bundle>
        <bundle>wrap:mvn:org.apache.lucene/lucene-queries/6.2.0</bundle>
        <bundle>wrap:mvn:org.apache.lucene/lucene-core/6.2.0</bundle>
        <bundle>wrap:mvn:com.typesafe.akka/akka-http_2.11/10.0.3</bundle>
        <bundle>wrap:mvn:com.typesafe.akka/akka-http-core_2.11/10.0.3</bundle>
        <bundle>mvn:com.typesafe.akka/akka-stream_2.11/2.4.16</bundle>
        <bundle>mvn:com.typesafe/ssl-config-core_2.11/0.2.1</bundle>
        <bundle>mvn:org.reactivestreams/reactive-streams/1.0.0</bundle>
        <bundle>wrap:mvn:com.typesafe.akka/akka-parsing_2.11/10.0.3</bundle>
        <bundle>mvn:com.typesafe.akka/akka-osgi_2.11/2.4.16</bundle>
        <bundle>mvn:com.typesafe.akka/akka-camel_2.11/2.4.16</bundle>
        <bundle>mvn:com.typesafe.akka/akka-slf4j_2.11/2.4.16</bundle>
        <bundle>mvn:com.typesafe.akka/akka-actor_2.11/2.4.16</bundle>
        <bundle>mvn:org.scala-lang.modules/scala-java8-compat_2.11/0.7.0</bundle>
        <bundle>mvn:org.apache.commons/commons-lang3/3.4</bundle>
        <bundle>mvn:commons-io/commons-io/2.4</bundle>
        <bundle>wrap:mvn:io.monix/monix-cats_2.11/2.2.1</bundle>
        <bundle>wrap:mvn:org.typelevel/cats-core_2.11/0.9.0</bundle>
        <bundle>wrap:mvn:org.typelevel/cats-kernel_2.11/0.9.0</bundle>
        <bundle>wrap:mvn:org.typelevel/cats-macros_2.11/0.9.0</bundle>
        <bundle>wrap:mvn:org.typelevel/machinist_2.11/0.6.1</bundle>
        <bundle>wrap:mvn:com.github.mpilquist/simulacrum_2.11/0.10.0</bundle>
        <bundle>wrap:mvn:io.monix/monix-types_2.11/2.2.1</bundle>
        <bundle>wrap:mvn:org.typelevel/macro-compat_2.11/1.1.1</bundle>
        <bundle>mvn:org.apache.camel/camel-core-osgi/2.18.2</bundle>
        <bundle>mvn:com.sun.xml.bind/jaxb-impl/2.2.11</bundle>
        <bundle>mvn:com.sun.xml.bind/jaxb-core/2.2.11</bundle>
        <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/2.8.3</bundle>
        <bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.8.3</bundle>
        <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/2.8.0</bundle>
        <bundle>mvn:com.github.domino-osgi/domino_2.11/1.1.1</bundle>
        <bundle>mvn:org.apache.felix/org.apache.felix.scr/2.0.6</bundle>
        <bundle>wrap:mvn:org.codehaus.mojo/animal-sniffer-annotations/1.9</bundle>
        <bundle>mvn:org.osgi/osgi.core/6.0.0</bundle>
        <bundle>mvn:org.slf4j/log4j-over-slf4j/1.7.22</bundle>
        <bundle>mvn:org.slf4j/jcl-over-slf4j/1.7.22</bundle>
        <bundle>mvn:org.slf4j/slf4j-simple/1.7.22</bundle>
        <bundle>mvn:org.slf4j/slf4j-api/1.7.22</bundle>
        <bundle>wrap:mvn:com.lihaoyi/scalatags_2.11/0.6.1</bundle>
        <bundle>wrap:mvn:com.lihaoyi/sourcecode_2.11/0.1.1</bundle>
        <bundle>mvn:org.scala-lang/scala-compiler/2.11.8</bundle>
        <bundle>mvn:org.scala-lang.modules/scala-parser-combinators_2.11/1.0.4</bundle>
        <bundle>mvn:org.scala-lang.modules/scala-xml_2.11/1.0.4</bundle>
        <bundle>mvn:org.scala-lang/scala-reflect/2.11.8</bundle>
        <bundle>file:scaldi_2.11-0.5.8.jar</bundle>
        <bundle>file:neo4j-ogm-osgi_2.11.jar</bundle>
        <bundle>file:neo4j-java-driver-1.0.5.jar</bundle>
        <bundle>file:jmscalajs_2.11-0.1-SNAPSHOT.jar</bundle>
    </feature>
</features>

如果你能告诉我我需要做的最少更改集才能使这项工作那么这将满足这个问题,因为它会解释如何从功能文件和 jars 手动创建 Karaf 文件。

标准 ZIP 文件可用于此(JAR 与 MANIFEST.MF 文件作为 ZIP 中的第一个文件)。

必须使用以下布局 - 这与 Maven 存储库布局相同。原因是 Karaf 使用 Aether 来解析包,这是较新版本的 maven 的引擎。 (我记得是3.3以后的):

/repository - 这是标准的 Maven 布局。因此 bundle 必须作为 g​​roupId 部分存储为目录/版本/artifactId-version.jar.

在存储库中,您还必须存储功能存储库 xml 文件,以便能够解析功能。必须与本地 Maven 存储库中的存储相同。

kar 结构示例(它是一个片段):

.
|____repository
| |____com
| | |____carrotsearch
| | | |____java-sizeof
| | | | |____0.0.4
| | | | | |____java-sizeof-0.0.4.jar
| | |____fasterxml
| | | |____classmate
| | | | |____1.2.0
| | | | | |____classmate-1.2.0.jar
| | | |____jackson
| | | | |____core
| | | | | |____jackson-annotations
| | | | | | |____2.6.6
| | | | | | | |____jackson-annotations-2.6.6.jar
| | | | | |____jackson-core
| | | | | | |____2.6.6
| | | | | | | |____jackson-core-2.6.6.jar
| | | | | |____jackson-databind
| | | | | | |____2.6.6
| | | | | | | |____jackson-databind-2.6.6.jar
| | | | |____dataformat
| | | | | |____jackson-dataformat-yaml
| | | | | | |____2.6.6
| | | | | | | |____jackson-dataformat-yaml-2.6.6.jar
| | | | |____jaxrs
| | | | | |____jackson-jaxrs-base
| | | | | | |____2.6.6
| | | | | | | |____jackson-jaxrs-base-2.6.6.jar
| | | | | |____jackson-jaxrs-json-provider
| | | | | | |____2.6.6
| | | | | | | |____jackson-jaxrs-json-provider-2.6.6.jar
| | | | |____module
| | | | | |____jackson-module-jaxb-annotations
| | | | | | |____2.6.6
| | | | | | | |____jackson-module-jaxb-annotations-2.6.6.jar
| | |____google
| | | |____guava
| | | | |____guava
| | | | | |____18.0
| | | | | | |____guava-18.0.jar
| | | | |____example
| | | | | |____car
| | | | | | |____car-bo
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-bo-1.1.0-SNAPSHOT.jar
| | | | | | |____car-dao
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-dao-1.1.0-SNAPSHOT.jar
| | | | | | |____car-dao-minimal
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-dao-minimal-1.1.0-SNAPSHOT.jar
| | | | | | |____car-dao-minimal-querydsl
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-dao-minimal-querydsl-1.1.0-SNAPSHOT.jar
| | | | | | |____car-dao-querydsl
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-dao-querydsl-1.1.0-SNAPSHOT.jar
| | | | | | |____car-doc
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-doc-1.1.0-SNAPSHOT.jar
| | | | | | |____car-dto
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-dto-1.1.0-SNAPSHOT.jar
| | | | | | |____car-features
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-features-1.1.0-SNAPSHOT-default.cfg
| | | | | | |____car-kar
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-kar-1.1.0-SNAPSHOT-features.xml
| | | | | | |____car-operation
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-operation-1.1.0-SNAPSHOT.jar
| | | | | | |____car-operation-regular
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-operation-regular-1.1.0-SNAPSHOT.jar
| | | | | | |____car-po
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-po-1.1.0-SNAPSHOT.jar
| | | | | | |____car-rest
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-rest-1.1.0-SNAPSHOT.jar
| | | | | | |____car-rest-regular
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-rest-regular-1.1.0-SNAPSHOT.jar
| | | | | | |____car-service
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-service-1.1.0-SNAPSHOT.jar
| | | | | | |____car-service-regular
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-service-regular-1.1.0-SNAPSHOT.jar
| | | | | | |____car-service-regular-minimal
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-service-regular-minimal-1.1.0-SNAPSHOT.jar
| | | | | | |____car-ui-model
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-ui-model-1.1.0-SNAPSHOT.jar
| | | | | | |____car-ui-resource
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-ui-resource-1.1.0-SNAPSHOT.jar
| | | | |____external
| | | | | |____external-apache-poi
| | | | | | |____3.13.1
| | | | | | | |____external-apache-poi-3.13.1.jar
| | | | |____integration

我的特征定义是:

| | | | | | |____car-kar
| | | | | | | |____1.1.0-SNAPSHOT
| | | | | | | | |____car-kar-1.1.0-SNAPSHOT-features.xml

即:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="car-kar">
    <feature name="blackbelt-car" description="Car application" version="1.1.0.SNAPSHOT">
        <configfile finalname="/deploy/hu.blackbelt.judo-car.cfg">mvn:hu.blackbelt.judo.example.car/car-features/1.1.0-SNAPSHOT/cfg/default</configfile>
        <configfile finalname="/sample-configurations/hu.blackbelt.judo-car.cfg" override="true">mvn:hu.blackbelt.judo.example.car/car-features/1.1.0-SNAPSHOT/cfg/default</configfile>
        <feature prerequisite="false" dependency="false">blackbelt-judo-repo</feature>
        <feature prerequisite="false" dependency="false">blackbelt-judo-common</feature>
        <feature prerequisite="false" dependency="false">blackbelt-judo-business</feature>
        <feature prerequisite="false" dependency="false">blackbelt-judo-rdbms</feature>
        <feature prerequisite="false" dependency="false">blackbelt-judo-integration</feature>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-bo/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-po/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-dao/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-dao-querydsl/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-dao-minimal/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-dao-minimal-querydsl/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-doc/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-dto/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-operation/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-operation-regular/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-rest/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-rest-regular/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-service/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-service-regular/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-service-regular-minimal/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-ui-model/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt.judo.example.car/car-ui-resource/1.1.0-SNAPSHOT</bundle>
        <bundle start-level="95">mvn:hu.blackbelt/judo-web/1.0-SNAPSHOT</bundle>
    </feature>
    <feature name="blackbelt-judo-repo" description="BlackBelt Judo: Repo" version="1.1.0.SNAPSHOT">
        <feature prerequisite="false" dependency="false">wrap</feature>
        <feature version="1.0.0" prerequisite="false" dependency="false">repo-spifly</feature>
        <feature prerequisite="false" dependency="false">pax-cdi</feature>
        <feature prerequisite="false" dependency="false">jndi</feature>
        <feature prerequisite="false" dependency="false">transaction</feature>
        <feature prerequisite="false" dependency="false">jasypt-encryption</feature>
        <feature prerequisite="false" dependency="false">eventadmin</feature>
        <feature prerequisite="false" dependency="false">scr</feature>
        <feature prerequisite="false" dependency="false">http</feature>
        <feature prerequisite="false" dependency="false">http-whiteboard</feature>
        <feature prerequisite="false" dependency="false">repo-cxf-jaxrs</feature>
        <feature prerequisite="false" dependency="false">repo-cxf-jaxws</feature>
        <feature prerequisite="false" dependency="false">repo-cxf-rs-security-cors</feature>
        <feature prerequisite="false" dependency="false">repo-cxf-rs-description-swagger2</feature>
        <feature prerequisite="false" dependency="false">repo-javassist</feature>
        <feature prerequisite="false" dependency="false">repo-jackson</feature>
        <feature prerequisite="false" dependency="false">repo-functionaljava</feature>
        <feature prerequisite="false" dependency="false">repo-commons-osgi</feature>
        <feature prerequisite="false" dependency="false">repo-commons-mime</feature>
        <feature prerequisite="false" dependency="false">repo-paranamer</feature>
        <feature prerequisite="false" dependency="false">repo-querydsl</feature>
        <feature prerequisite="false" dependency="false">repo-h2</feature>
        <feature prerequisite="false" dependency="false">repo-hsqldb</feature>
        <feature prerequisite="false" dependency="false">repo-postgresql</feature>
        <feature prerequisite="false" dependency="false">repo-oracle</feature>
        <feature prerequisite="false" dependency="false">repo-guava</feature>
        <feature prerequisite="false" dependency="false">repo-joda-time</feature>
        <feature prerequisite="false" dependency="false">repo-markup</feature>
        <feature prerequisite="false" dependency="false">repo-reflections</feature>
        <feature prerequisite="false" dependency="false">repo-javax-validation</feature>
        <feature prerequisite="false" dependency="false">repo-hibernate-validator</feature>
        <feature prerequisite="false" dependency="false">repo-concurrentlinkedhashmap-lru</feature>
        <feature prerequisite="false" dependency="false">repo-java-sizeof</feature>
        <feature prerequisite="false" dependency="false">repo-orika-core</feature>
        <feature prerequisite="false" dependency="false">repo-management</feature>
        <feature prerequisite="false" dependency="false">repo-paxjdbc</feature>
        <feature prerequisite="false" dependency="false">repo-apache-poi</feature>
        <feature prerequisite="false" dependency="false">repo-antlr4</feature>
        <feature prerequisite="false" dependency="false">repo-sling-healthcheck</feature>
        <feature prerequisite="false" dependency="false">repo-dom4j</feature>
        <feature prerequisite="false" dependency="false">repo-pdfbox</feature>
        <feature prerequisite="false" dependency="false">repo-freemarker</feature>
        <feature prerequisite="false" dependency="false">shiro-web</feature>
        <feature prerequisite="false" dependency="false">nimbus-jose-jwt</feature>
        <feature prerequisite="false" dependency="false">groovy-all</feature>
        <feature prerequisite="false" dependency="false">javax-el</feature>
        <feature prerequisite="false" dependency="false">unboundid-ldapsdk</feature>
        <feature prerequisite="false" dependency="false">javax.mail</feature>
        <feature prerequisite="false" dependency="false">org.passay</feature>
    </feature>
    <feature name="repo-apache-poi" version="3.13.0">
        <feature prerequisite="false" dependency="false">repo-bouncycastle</feature>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlbeans/2.6.0_2</bundle>
        <bundle>mvn:hu.blackbelt.judo.external/external-apache-poi/3.13.1</bundle>
    </feature>
    <feature name="repo-bouncycastle" version="1.55.0">
        <bundle>mvn:org.bouncycastle/bcprov-jdk15on/1.55</bundle>
        <bundle>mvn:org.bouncycastle/bcmail-jdk15on/1.55</bundle>
        <bundle>mvn:org.bouncycastle/bcpkix-jdk15on/1.55</bundle>
    </feature>
    <feature name="repo-javassist" version="3.19.0.GA">
        <bundle>mvn:org.javassist/javassist/3.19.0-GA</bundle>
    </feature>
    <feature name="repo-spifly" version="1.0.0">
        <bundle>mvn:org.ow2.asm/asm-all/4.2</bundle>
        <bundle>mvn:org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/1.0.0</bundle>
    </feature>
</features>

这个特征文件是一个有效的特征文件,它包含在 KAR 文件中显示的所有特征存储库,这意味着如果 maven-karaf-plugin 上有更多特征作为特征依赖定义,所有这些都聚集在这里。 KAR 功能包 groupId 和 artifactId 是程序集的 maven 项目。 (在你的情况下可以是任何名字)