0

我正在创建 OSGi 包,我希望 Apache Felix SCR maven 插件自动将生成的 OSGI-INF 文件夹包含到 .jar 包中。现在它只是生成 OSGI-INF 到 target/scr-plugin-generated。这是我的 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>maven.test</groupId>
  <artifactId>test-dfs</artifactId>
  <version>0.0.4-SNAPSHOT</version>
  <name>DFS test</name>

  <build>
      <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-scr-plugin</artifactId>
            <version>1.9.0</version>
            <executions>
              <execution>
                <id>generate-scr-scrdescriptor</id>
                <goals>
                  <goal>scr</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
            <plugin>
              <artifactId>maven-jar-plugin</artifactId>
              <configuration>
                <archive>  
                  <manifestFile>${project.build.outputDirectory}/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>

  <dependencies>
    <dependency>
        ...
    </dependency>
    <dependency>
      <!-- scr annotations - for generating component descriptors only -->
      <groupId>org.apache.felix</groupId>
      <artifactId>org.apache.felix.scr.annotations</artifactId>
      <version>1.7.0</version>
      <scope>provided</scope>
    </dependency>



  </dependencies>

  <properties>
    <depl.user>user</depl.user>
    <depl.password>password</depl.password>
    <depl.host>localhost</depl.host>
    <depl.port>4502</depl.port>
  </properties>

</project>
4

1 回答 1

0

如果您使用:

<plugin>   
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.4.0</version>
    <extensions>true</extensions>
</plugin>

取而代之的是 maven-jar-plugin + maven-bundle-plugin(具有清单目标),所有由maven-scr-plugin生成的文件都将被隐式包含在构建的包中。

于 2013-07-04T14:15:09.367 回答