maven配置bundle工程

本文介绍了如何配置Maven Bundle工程,包括在src/main/resources下创建features.xml文件,详细内容涉及设置repository和feature,引用Camel相关特性。同时,解释了pom.xml中的关键配置,如设置打包类型为bundle,配置构建插件以及添加必要的依赖。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.在src\main\resources路径下配置features.xml文件,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0 http://karaf.apache.org/xmlns/features/v1.0.0"
name="esbconsoleRepository">
<repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>

<feature name="${project.artifactId}" version="${project.version}">
<feature version="${camel.version}">camel-http</feature>
<feature version="${camel.version}">camel-jetty</feature>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
</feature>
</features>

2.pom.xml文件要点

2.1:打包成bundle格式文件

 <packaging>bundle</packaging>

2.2:配置构建所需插件

<build>

<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
<DynamicImport-Package>*</DynamicImport-Package>
<Import-Package>!*</Import-Package>
<!-- <Import-Package>!antlr.*,!gnu.*,!javassist.*,!javax.persistence.*,!javax.xml.rpc*,!junit.*,*</Import-Package> -->
<Export-Package>com.csair.cod.route*;version=${project.version}</Export-Package>
<Embed-Dependency>log4j,svc-sample-fuse-lib,jbossall-client,testejb;scope=compile|runtime|system</Embed-Dependency>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
<!-- add the following args -->
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>256m</maxmem>
<!-- if it doesn't work, try 768M, it seems that UTF-16 consumes more 
memory -->
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>target/features.xml</file>
<type>xml</type>
<classifier>features</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>

</build>

2.3依赖所需包:

具体项目所需包不一样,所以省略

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值