2013-02-26 175 views
5

我们想编写我们自己的wso2碳自定义扩展(功能)。是否有一些创作功能的文档?编写自定义功能

我们确实设法“破解”我们编写自定义功能的方式。但我们如何托管它?看来Carbon正在寻找一些非常具体的存储库描述符 - artifacts.jar和content.jar

我们如何生成这些描述符而不需要绑定到Carbon构建中。是否有一些文档描述如何设置第三方功能存储库?

回答

1

Creating-your-own-wso2-carbon-components网络研讨会讨论了如何创建碳组件,以及这些组件的功能。它涵盖了相当多的基础知识以及最佳实践。

要托管您编写的创建功能,您需要从这些功能生成p2存储库。 p2-repo概念来自WSO2产品使用的下划线Eclipse equinox项目。

WSO2已经编写了自己的maven插件,名为carbon-p2-plugin,它有助于生成p2-repo。这是你如何做到的。只需创建一个新的maven项目(包装:pom),然后在carbon-p2-plugin插件配置下设置要发布的功能。以下是您可以使用的示例pom.xml。这是从p2-repo generation pom.xml of carbon 4.1.0复制的,我简化了它。

我测试过这个pom文件,它对我有用。有两个示例功能定义。将这些featureArtifactDef替换为您自己的特征定义。格式是$ groupId:$ artifactId:$ version。

当你通过maven构建它时,maven创建target/p2-repo目录。这包含p2-repository,其中包含完整的p2-repo,包括artifacts.jar和content.jar。您可以使用此文件夹来安装功能,或者您可以将其托管在某处。对托管没有特殊要求。

<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/maven-v4_0_0.xsd"> 

    <parent> 
     <groupId>org.wso2.carbon</groupId> 
     <artifactId>carbon-features</artifactId> 
     <version>4.1.0</version> 
    </parent> 

    <modelVersion>4.0.0</modelVersion> 
    <artifactId>mysample-feature-repository</artifactId> 
    <version>4.1.0</version> 
    <packaging>pom</packaging> 
    <name>WSO2 Carbon - Feature Repository</name> 

    <build> 
     <plugins> 
     <plugin> 
      <groupId>org.wso2.maven</groupId> 
      <artifactId>carbon-p2-plugin</artifactId> 
      <version>1.5.2</version> 
      <executions> 
       <execution> 
       <id>2-p2-repo-generation</id> 
       <phase>package</phase> 
       <goals> 
        <goal>p2-repo-gen</goal> 
       </goals> 
       <configuration> 
        <p2AgentLocation>${basedir}/target/p2-agent</p2AgentLocation> 
        <metadataRepository>file:${basedir}/target/p2-repo</metadataRepository> 
        <artifactRepository>file:${basedir}/target/p2-repo</artifactRepository> 
        <publishArtifacts>true</publishArtifacts> 
        <publishArtifactRepository>true</publishArtifactRepository> 
        <featureArtifacts> 

<!-- change the featureArtifactDef to match your needs --> 

         <featureArtifactDef> 
            org.wso2.carbon:org.wso2.carbon.service.mgt.feature:4.1.0 
         </featureArtifactDef> 
         <featureArtifactDef> 
            org.wso2.carbon:org.wso2.carbon.registry.core.feature:4.1.0 
         </featureArtifactDef> 


       </featureArtifacts> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 
</project>