我们有很多组件,首先我们只想模块化一些组件。想知道从所有这些组件中创建包的最好方法(在我的构建环境中)是什么?
我的环境: Java 6,Maven 2.2.1,Hudson
技术:Spring3.0.5、WebSphere 7、Hibernate 3.2.x和大部分apache。
要求
发布于 2012-05-03 19:25:12
首先,只更改MANIFEST.MF条目,使您的所有工件都成为包--它们显然不会神奇地工作,但这是一个很好的无损的第一步。
当使用maven-bundle-plugin时,请确保设置extensions和supportedProjectTypes,因为您可能在CI构建中遇到问题,如果打包类型为bundle,则Maven repos和m2e失败(参见end)。
尽早测试您最危险的/核心外部依赖项--例如,如果您使用JPA进行持久性,那么确保提供程序在OSGi环境中使用域包和JDBC驱动程序。
如果您正在从Java /spring迁移,请查看Karaf或Virgo。但是,如果您的组件用于嵌入式系统,或者没有外部依赖项,那么Felix或Equinox就足够了(如果是这样的话,请查看pax-url项目)。
您的问题是否值得编辑,以便对领域/技术有更具体的了解?
eclipse:eclipse只在项目首次配置时生成,M2E的生命周期问题可能有点痛苦,但它比使用旧的eclipse插件要好得多。
以下内容将向您现有的工件添加清单条目,而不以任何其他方式更改它们。它告诉标准的maven jar和war插件使用由maven-bundle-plugin生成的MANIFEST.MF。
将其放在父POM中:
<pluginManagement>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<archive>
<addMavenDescriptor>true</addMavenDescriptor>
</archive>
<supportedProjectTypes>
<supportedProjectType>jar</supportedProjectType>
<supportedProjectType>war</supportedProjectType>
</supportedProjectTypes>
<instructions>
<Built-By>${project.organization.name}</Built-By>
<Bundle-Vendor>${project.organization.name}</Bundle-Vendor>
<Bundle-ContactAddress>${project.organization.url}</Bundle-ContactAddress>
<Bundle-Description>${project.description}</Bundle-Description>
<Bundle-DocURL>${bundle.doc.url}</Bundle-DocURL>
<Bundle-Category>${bundle.category}</Bundle-Category>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Import-Package>*</Import-Package>
<Export-Package>*</Export-Package>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle</id>
<goals>
<goal>manifest</goal>
</goals>
<phase>prepare-package</phase>
<inherited>true</inherited>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>create-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<inherited>true</inherited>
</execution>
</executions>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</pluginManagement>然后在“童子军”中,你可以简单地做:
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<!-- Below is mutually exclusive: Either jar or war plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>发布于 2012-05-04 12:14:32
看看bndtools,它对创建打包包的项目有很好的支持。它提供了很多洞察JAR是如何构造的,以及它们如何依赖于其他事物。
https://stackoverflow.com/questions/10436865
复制相似问题