Java 使用maven的karaf felix自定义分发
我目前正在将Java 使用maven的karaf felix自定义分发,java,maven,apache-felix,apache-karaf,Java,Maven,Apache Felix,Apache Karaf,我目前正在将maven托管捆绑包部署到felix框架中,我希望为部署过程创建一个maven项目,并希望使用maven插件自动化所有过程 使用maven依赖插件我们可以以某种方式自动化部署过程 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <versio
maven
托管捆绑包部署到felix
框架中,我希望为部署过程创建一个maven
项目,并希望使用maven插件自动化所有过程
使用maven依赖插件
我们可以以某种方式自动化部署过程
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack-felix</id>
<phase>compile</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>org.apache.felix.ipojo.distribution.quickstart</includeArtifactIds>
<outputDirectory>${project.build.directory}/tmp</outputDirectory>
</configuration>
</execution>
<execution>
<id>copy-bundles</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>
sample.maven.bundle1,
sample.maven.bundle2,
.
.
sample.maven.bundleN
</includeArtifactIds>
<outputDirectory>${project.build.directory}/bundle</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
maven依赖插件
2.8
打开felix的包
编译
解包依赖项
org.apache.felix.ipojo.distribution.quickstart
${project.build.directory}/tmp
复制包
包裹
复制依赖项
sample.maven.bundle1,
sample.maven.bundle2,
.
.
sample.maven.bundleN
${project.build.directory}/bundle
但是
中提到的所有捆绑包都是静态的,使用bundle:update
或felix:update
更新它们时可能会遇到问题
如何将捆绑包部署到
felix
或karaf
中,与运行felix:deploy
内部felix
相同,但使用maven
调用?我不确定是否完全理解您的需求,但对于karaf,您有功能描述符。基本上是一个xml文件,它告诉功能解析程序哪些捆绑包要一起安装,或者哪些其他功能可能需要作为先决条件
例如,下面的feature.xml:
<?xml version="1.0" encoding="UTF-8"?>
<features name="myfeature" xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
<repository>mvn:org.apache.camel.karaf/apache-camel/2.15.0/xml/features</repository>
<feature name='myfeature' version="1.0">
<bundle>mvn:my.group.id/sample.maven.bundle1/1.0</bundle>
<bundle>mvn:my.group.id/sample.maven.bundle2/1.0</bundle>
<bundle>mvn:my.group.id/sample.maven.bundle3/1.0</bundle>
<bundle>mvn:my.group.id/sample.maven.bundle4/1.0</bundle>
...
<bundle>mvn:my.group.id/sample.maven.bundleN/1.0</bundle>
</feature>
...
</features>
使用正确的mvn坐标安装单个捆绑包同样容易:
bundle:install mvn:my.group.id/sample.maven.bundle1/1.0
如果您只想将其保存在自己的容器中,则需要将pax url以太项目添加到设置中,它会添加require mvn url处理程序。使用此url处理程序,可以从mvn坐标安装捆绑包
编辑:
另一种一次性提供所有这些内容的方法是,使用KarafMaven插件创建自定义发行版
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>Karaf-Service-Runtime</artifactId>
<packaging>karaf-assembly</packaging>
...
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<extensions>true</extensions>
<configuration>
<!-- <startupFeatures/> -->
<bootFeatures>
<feature>standard</feature>
<feature>management</feature>
<feature>war</feature>
<feature>my-feature</feature>
</bootFeatures>
<!-- <installedFeatures/> -->
</configuration>
</plugin>
. 通过使用功能在karaf中安装bundle,您成功了一半,但仍需要通过在karaf中键入feature:install myfeature
进行人机交互,我想要的是消除人机交互,使用maven执行所有命令,只需简单的mvn clean install
或mvn clean deploy
,但您仍然可以编辑您的答案,我希望您能帮助我:)我找到了您关于使用karaf 4.0.0.M2进行自定义分发的电子邮件,我仍然无法让它运行即使答案正确,也要删除标准
并手动添加您喜欢的功能。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>Karaf-Service-Runtime</artifactId>
<packaging>karaf-assembly</packaging>
...
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<extensions>true</extensions>
<configuration>
<!-- <startupFeatures/> -->
<bootFeatures>
<feature>standard</feature>
<feature>management</feature>
<feature>war</feature>
<feature>my-feature</feature>
</bootFeatures>
<!-- <installedFeatures/> -->
</configuration>
</plugin>