maven配置bundle工程

来源:互联网 发布:儿歌大全软件 编辑:程序博客网 时间:2024/06/05 22:40

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依赖所需包:

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

原创粉丝点击