之前写了一个篇如何使用Spring提供的Maven Archetype来自动化创建一个Spring Osgi Bundle项目。而在实际的开发过程中,发现自己并不是很喜欢这中方式,总是觉得有些地方会失去控制。
举个很简单的例子,如果使用手动编辑MANIFEST.MF文件来维护Import-Package和Import-Bundle,那么需要注意一定要将Import-Bundle放在Import-Package之前,否则在使用mvn
org.apache.felix:maven-bundle-plugin:manifest时,无法正确的生成MANIFEST.MF文件。生成的
MANIFEST.MF文件中没有Import-Bundle项。
为了更加好的掌控项目,因此在实际开发过程中,我采用了手工创建和维护项目的方法。下面简单的说明一下创建项目的过程:
- 通过maven-archetype-quickstart创建一个Maven管理的项目。
$mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart
- 创建必需的文件与目录
$cd /path/to/your/project
$mkdir src/main/resources
$mkdir src/main/resources/META-INF
$mkdir src/main/resources/META-INF/spring
$touch src/main/resources/META-INF/MANIFEST.MF
- 编辑${your.project.path}/pom.xml文件
- 添加springsource的repository,参见How do I configure a Maven build to work with the repository?
<!-- ================================================ -->
<!-- Repository Configuration -->
<!-- ================================================ -->
<repositories>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/release</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.external</id>
<name>SpringSource Enterprise Bundle Repository - External Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/external</url>
</repository>
</repositories>
- 指定打包时需要使用的MANIFEST.MF,参见Adding OSGi metadata to existing projects without changing the packaging type
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
- 完成
分享到:
相关推荐
spring osgi相关资源
《Eclipse RCP与Spring OSGi:技术详解与最佳实践》由资源的Eclipse专家亲自执笔,并得到了Eclipse官方技术社区的强烈推荐,权威性毋庸置疑!内容全面,系统讲解了利用Eclipse RCP和Spring OSGi开发大规模Java应用的...
OSGI bundle 在线用户管理 邮件发送
spring osgi 中文文档0.7
Spring OSGi 入门.pdf Spring OSGi 入门.pdf
Spring OSGi规范 中文版 Spring框架是一个领先的full-stack Java/JEE应用框架。它提供一个轻量级的容器,依赖注入、aop、可插接的服务抽取,这些使得非侵入式的编程模型成为可能。OSGi提供了一个动态应用程序的执行...
SpringOSGi.jar
Spring OSGi 入门.rar Spring OSGi 入门.rar
OSGISpringOSGISpring OSGISpring
Spring OSGI 快速入门中文教程
基于VirgoServer进行Spring Osgi Web开发 带示例
基于 equinox 的 OSGI 运行BUNDLE例子,已包含 ECLIPSE 下的OSGI平台包,按步骤运行即可。 当然,设置JAVA_HOME,及BIN环境变量运行JAVAC 就不用说了 ^-^
spring osgi所需的所有lib以及示例程序。
NULL 博文链接:https://bill-xing.iteye.com/blog/1175993
spring-osgi-1.2.1-with-dependencies.zip spring-osgi-1.2.1-with-dependencies.zip spring-osgi-1.2.1-with-dependencies.zip
spring-osgi-1.2.0-with-dependencies.zip spring-osgi-1.2.0-with-dependencies.zip spring-osgi-1.2.0-with-dependencies.zip
spring dm osgi 中的服务提供和模块化编程
基于VirgoServer进行Spring Osgi Web开发(示例代码)
osgi发布http服务的各种bundle,各种jar包,全全全~非常好用的技术包 包括:org.eclipse.equinox.http_1.0.0.v20060601a.jar org.eclipse.equinox.ds_1.0.0.v20060601a.jar org.eclipse.equinox.servlet.api_1.0.0...