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

时间:2017-02-09 06:32:54

标签: apache-karaf karaf

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

由于我有一个feature.xml文件,该文件可以工作,而且feature.xml文件引用了jar文件,我想如果我创建了一个这样的jar,请将它重命名为filename.kar然后它应该可以工作。

然而卡拉夫说:

part_number

但是 - 它没有做任何其他事情,当我做功能时,该功能无法使用:list。

我的JMScalaJS.kar文件包含:

#include<stdio.h>
#include<string.h>
int main(){
char new_string[100];
char string[100];
scanf("%s",string);
printf("original_number = %s\n",string);
int i;
int l = strlen(string)-1;

for(i = 0; i<=l; i++){
 new_string[i] = string[l-i];
 printf("%c\n",new_string[i]);
    }
 printf("rev_number = %s\n",new_string);
}

然后我的feature.xml包含

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

如果你能告诉我为完成这项工作需要做出的最小改变,那么这将解决这个问题,因为它将解释如何从特征文件和罐子中手动创建一个Karaf文件。

1 个答案:

答案 0 :(得分:2)

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

必须使用以下布局 - 这与Maven repositor布局相同。 reasin是Karaf使用Aether解决捆绑,这是maven的新版本的引擎。 (我记得晚于3.3):

/ repository - 这是标准的maven布局。所以bunldes必须作为目录/ version / artifactId-version.jar存储为groupId部分。

在存储库中,您还必须存储功能库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项目。 (在你的情况下可以是任何名字)