在Maven编译后包含OSGI-INF到jar包



我正在创建OSGi包,我希望Apache Felix SCR maven插件自动将生成的OSGi-INF文件夹包含到.jar包中。现在它只生成OSGI-INF来生成target/scr插件。这是我的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>

如果使用:

<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(带有manifest目标),maven-scr-plugin生成的所有文件都将隐式包含在构建的捆绑包中。

最新更新