2015-04-15 38 views
4

我想讓karaf-maven-plugin爲我的應用程序生成一個特性文件。該應用程序取決於cxf功能,但我似乎無法使插件生成功能xml來反映這一點。從我的功能模塊karaf-maven-plugin:將一個依賴項定義爲一個特徵

摳圖:

<dependencies> 
     <dependency> 
      <groupId>com.test.test</groupId> 
      <artifactId>test</artifactId> 
     </dependency> 
    </dependencies> 

    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.karaf.tooling</groupId> 
        <artifactId>karaf-maven-plugin</artifactId> 
        <version>3.0.3</version> 
        <extensions>true</extensions> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.karaf.tooling</groupId> 
     <artifactId>karaf-maven-plugin</artifactId> 
      <configuration> 
      <startLevel>80</startLevel> 
     <includeTransitiveDependency>true</includeTransitiveDependency> 
     <aggregateFeatures>false</aggregateFeatures> 
      </configuration> 
     </plugin> 
     </plugins> 
    </build> 

從我模塊的依賴關係:

  <dependency> 
       <groupId>org.slf4j</groupId> 
       <artifactId>slf4j-api</artifactId> 
       <version>${slf4j.version}</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.slf4j</groupId> 
       <artifactId>slf4j-log4j12</artifactId> 
       <version>${slf4j.version}</version> 
       <scope>provided</scope> 
      </dependency> 

      <dependency> 
       <groupId>log4j</groupId> 
       <artifactId>log4j</artifactId> 
       <version>1.2.17</version> 
       <scope>provided</scope> 
      </dependency> 

      <dependency> 
       <groupId>org.osgi</groupId> 
       <artifactId>org.osgi.core</artifactId> 
       <version>5.0.0</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.osgi</groupId> 
       <artifactId>org.osgi.compendium</artifactId> 
       <version>5.0.0</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.felix</groupId> 
       <artifactId>org.apache.felix.configadmin</artifactId> 
       <version>1.8.0</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.mybatis</groupId> 
       <artifactId>mybatis</artifactId> 
       <version>3.2.8</version> 
       <scope>provided</scope> 
      </dependency> 

      <dependency> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
       <version>4.12</version> 
       <scope>provided</scope> 
      </dependency> 

      <dependency> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-rt-frontend-jaxrs</artifactId> 
       <version>${cxf.version}</version> 
       <scope>provided</scope> 
      </dependency> 
      <!-- use extension providers --> 
      <dependency> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-rt-rs-extension-providers</artifactId> 
       <version>${cxf.version}</version> 
       <scope>provided</scope> 
      </dependency> 
      <!-- use Jackson --> 
      <dependency> 
       <groupId>org.codehaus.jackson</groupId> 
       <artifactId>jackson-jaxrs</artifactId> 
       <version>1.9.13</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.codehaus.jackson</groupId> 
       <artifactId>jackson-xc</artifactId> 
       <version>1.9.13</version> 
       <scope>provided</scope> 
      </dependency> 

      <dependency> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-rt-transports-http</artifactId> 
       <version>${cxf.version}</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-rt-ws-security</artifactId> 
       <version>${cxf.version}</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-rt-ws-policy</artifactId> 
       <version>${cxf.version}</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-rt-ws-addr</artifactId> 
       <version>${cxf.version}</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-rt-frontend-jaxws</artifactId> 
       <version>${cxf.version}</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-rt-rs-client</artifactId> 
       <version>${cxf.version}</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-rt-transports-http-hc</artifactId> 
       <version>${cxf.version}</version> 
       <scope>provided</scope> 
      </dependency> 

      <dependency> 
       <groupId>org.apache.cxf.karaf</groupId> 
       <artifactId>apache-cxf</artifactId> 
       <version>${cxf.version}</version> 
       <classifier>features</classifier> 
       <type>xml</type> 
      </dependency> 


      <dependency> 
       <groupId>org.apache.commons</groupId> 
       <artifactId>commons-lang3</artifactId> 
       <version>3.3.2</version> 
      </dependency> 
     </dependencies> 

正如你所看到的,我曾試圖定義特徵神器作爲編譯範圍依賴,如就像普通人一樣。其他一切都按照規定的範圍。

  <dependency> 
       <groupId>org.apache.cxf.karaf</groupId> 
       <artifactId>apache-cxf</artifactId> 
       <version>${cxf.version}</version> 
       <classifier>features</classifier> 
       <type>xml</type> 
      </dependency> 


      <dependency> 
       <groupId>org.apache.commons</groupId> 
       <artifactId>commons-lang3</artifactId> 
       <version>3.3.2</version> 
      </dependency> 

在結果features.xml文件,公地捆綁註冊,但功能並不:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="feature"> 
    <feature name="feature" version="0.1-SNAPSHOT" description="test-feature"> 
     <details>test</details> 
     <bundle start-level="80">mvn:com.test.test/test/0.1-SNAPSHOT</bundle> 
     <bundle start-level="80">mvn:org.apache.commons/commons-lang3/3.3.2</bundle> 
    </feature> 
</features> 

我想這個落得:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="feature"> 
    <feature name="feature" version="0.1-SNAPSHOT" description="test-feature"> 
     <details>test</details> 
     <feature version="3.0.2">cxf</feature> 
     <bundle start-level="80">mvn:com.test.test/test/0.1-SNAPSHOT</bundle> 
     <bundle start-level="80">mvn:org.apache.commons/commons-lang3/3.3.2</bundle> 
    </feature> 
</features> 

稍作更新: 當我將<aggregateFeatures>true</aggregateFeatures>添加到插件配置中時,整個cxf功能將解壓縮到我的features.xml文件中,但「cxf」等功能依賴關係仍然是d oes不出現在生成的特徵中。

回答

5

恕我直言,這是錯誤的或karaf-maven-plugin中沒有完成。我曾經也有過一樣的問題。 對我來說,我發現的解決方案是在src/main/feature下添加一個feature.xml模板,只需要使用我需要的功能和其他文件(configfiles)。你的情況是這樣的:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="feature"> 
    <feature name="feature" version="${yourprojectversion}" description="test-feature"> 
     <feature version="${cxf.version}">cxf</feature> 
    </feature> 
</features> 

我還使用:<aggregateFeatures>true</aggregateFeatures>

注意,在我的特徵模板,我已經使用在pom.xml定義的版本處理一些自定義的Maven特性。 最後你會得到你期待的功能。

相關問題