<;出口包装>;对于使用maven bundle插件的所有资源
作为能够快速过渡到OSGi的临时措施,我需要创建一个包含所有库的jar。我所做的是将所有jar库都放在src/main/resources中,这样它们最终会位于所创建jar的根目录中。我遇到的问题是告诉maven bundle插件导出jar中的所有包。因此,基本上,我想将我的所有库公开给其他OSGi包 这是我在POM中尝试的第一件事<;出口包装>;对于使用maven bundle插件的所有资源,maven,osgi,maven-bundle-plugin,Maven,Osgi,Maven Bundle Plugin,作为能够快速过渡到OSGi的临时措施,我需要创建一个包含所有库的jar。我所做的是将所有jar库都放在src/main/resources中,这样它们最终会位于所创建jar的根目录中。我遇到的问题是告诉maven bundle插件导出jar中的所有包。因此,基本上,我想将我的所有库公开给其他OSGi包 这是我在POM中尝试的第一件事 <build> <plugins> <plugin> <groupId&g
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>*</Export-Package>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
</instructions>
</configuration>
</plugin>
</plugins>
</build>`
org.apache.felix
maven捆绑插件
真的
*
${project.artifactId}
${project.version}
`
我试图出口那里的一切。但是,看起来唯一像这样导出的是两个osgi依赖项,而不是资源中的JAR
我有100多个库,所以我试图找到一种自动填充
指令的方法,而不是手动添加每个库的包。eclipse是在插件开发环境中实现的,但我需要使用maven实现这一点。这在bundle插件中是可能的吗?如果根据bundle插件的设置将JAR添加到
,您可以使用{local packages}
,这将扩展到项目中的所有包
然而,这是一个非常糟糕的主意想一想,您是说包中的所有内容都应该是公开可见的API。这意味着您必须维护所有这些软件包,确保您仔细地开发它们,并使用正确的版本等等。基本上,您不是模块化的
任何OSGi捆绑包的理想做法应该是导出尽可能少的包,我认为这是不可能的。JAR需要单独存在于maven repo中,以便能够通过将其作为依赖项添加到库项目中来创建“库项目”;否则jar将不在类路径中。执行此操作的一个很好的参考是您必须在pom.xml中添加JAR作为依赖项,然后在标签中为您的maven bundle插件使用以下公式:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>*</Export-Package>
<Bundle-Activator>your.activator.package.Activator</Bundle-Activator>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>target/dependency</Embed-Directory>
<Embed-StripGroup>true</Embed-StripGroup>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
org.apache.felix
org.eclipse.m2e
):
m2e.version
合格者
org.apache.felix
maven捆绑插件
META-INF
是的,我知道这是个坏主意。这些库最终将导入maven repo并单独管理,但在过渡期间,我需要将所有内容打包到单个库包中。将所有这些库导入maven需要时间链接不起作用。如果可以的话,请换一下。
<pluginManagement>
<plugins>
<!-- Ignore/Execute plugin execution -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<!-- copy-dependency plugin -->
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<profiles>
<profile>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<osgi-version-qualifier>qualifier</osgi-version-qualifier>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<!-- PDE does not honour custom manifest location -->
<manifestLocation>META-INF</manifestLocation>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>