eclipse - 如何设置 bundle 开发环境(Eclipse Equinox Maven)

标签 eclipse maven-2 bundle equinox

我正在尝试设置Eclipse环境以开发 bundle 包(使用maven-bundle-plugin-bnd)
并运行和调试从Eclipse bundle 春分

我使用org.apache.felix maven-bundle-plugin创建了示例 bundle 包,可以从Eclipse春分点安装和启动该 bundle 包,
但是每次我需要运行“安装文件:C:\ path \ bundle1.jar”,“安装文件:C:\ path \ bundle2.jar”时,都会引起痛苦。我搜索了运行配置,但它仅安装并启动工作区中的项目(插件),而不是Maven项目。

我所做的是创建maven项目并添加依赖项(bundle1,bundle2等),并添加了maven-dependency-plugin来将所有依赖的包复制到一个文件夹中(另一个问题是春分使用“_”定界符确定包的版本,但是maven使用“-”作为分隔符)如果我不剥离独立的春分应用程序中的版本,我需要在config.ini文件中提供 bundle 软件的版本,但是我不想要,这是解决此问题的正确方法吗?

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>${bundleDirectory}</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
              <stripVersion>true</stripVersion>
            </configuration>
          </execution>
        </executions>
      </plugin>  

总结一下,我在org.apache.felix maven-bundle-plugin创建的文件夹中有 bundle 包,如何从Eclipse中运行和调试它们?

最佳答案

我不会说这是一个“适当的”解决方案,但它可能对您有用。

antrun plugin可用于修改依赖项,以使用下划线替换最终的连字符,因此,依赖项插件无需剥离版本。

我的正则表达式很使用rust ,但是经过一点测试,下面的配置似乎可以将所需的名称更改应用于bundleDependency目录中的文件。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>copy-dependencies</id>
      <phase>package</phase>
      <goals>
        <goal>copy-dependencies</goal>
      </goals>
      <configuration>
        <outputDirectory>${bundleDirectory}</outputDirectory>
        <overWriteReleases>false</overWriteReleases>
        <overWriteSnapshots>true</overWriteSnapshots>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.3</version>
  <executions>
    <execution>
      <phase>package</phase>
      <configuration>
        <tasks>
          <!-- move within same directory is preferred method for a rename-->
          <move todir="${bundleDirectory}">
            <fileset dir="${bundleDirectory}"/>
            <mapper type="regexp" from="([a-zA-Z0-9\.-]+)(-)([0-9\.]+.jar)" 
              to="\1_\3"/>
          </move>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
  <dependencies>
   <dependency>
     <groupId>ant</groupId>
     <artifactId>ant-nodeps</artifactId>
     <version>1.6.5</version>
   </dependency>
  </dependencies>
</plugin>

关于eclipse - 如何设置 bundle 开发环境(Eclipse Equinox Maven),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1415189/

相关文章:

java - Eclipse 错误, "The selection cannot be launched, and there are no recent launches"

java - 更改两个java项目之间的公共(public)变量值在运行时没有反射(reflect)

java - 使用 Maven 2 构建可运行的 jar

maven-2 - Maven忽略提供的范围

maven-2 - Maven 根据配置文件更改文件中的值

xcode - 如何使用 Xcode 构建 Apple Mail 包?

java - Eclipse 中的 "java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy"

java - 在eclipse中将库导入到现有项目会造成很多麻烦

android - Bundle.getString(String key) 上的默认值

java - OSGi 包和普通 .JAR 文件用法之间的区别