Pax Construct及Maven Pax Plugin插件使用
0. Pax-Construct安装
??? 下载:http://repo1.maven.org/maven2/org/ops4j/pax/construct/scripts/1.4/scripts-1.4.zip
??? 设置环境变量:Path:C:\Pax-Construct-1.4\bin
??? 使用参考:http://www.ops4j.org/projects/pax/construct/
1. 命令行创建工程目录:
??? mvn org.ops4j:maven-pax-plugin:create-project -DgroupId=org.sonatype.mcookbook
??? -DartifactId=OSGi-Project -Dversion=1.0.0
??? 生成目录结构:
??? OSGi-Project/pom.xml:Parent POM
??? OSGi-Project/poms/compile/pom.xml:将添加至该工程的所有已经编译的OSGi Component
??? OSGi-Project/poms/wrappers/pom.xml:配置所有包装的OSGi Bundle
??? OSGi-Project/provision/pom.xml:配置Felix运行环境,以便执行pax:provision目标Build并Deploy并启动Felix,
??? 执行该目标将在该工程下生成runner文件夹,
2. 验证是否可构建成功命令
??? mvn clean install
3. Import OSGi Bundel With Maven
??? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.webconsole
??? -Dversion=1.2.10
??? 用该命令安装VMC需同时安装:
??? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=javax.servlet -Dversion=1.0.0
??? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix
??? .scr? -Dversion=1.0.8
??? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.http
??? .jetty -Dversion=2.2.0
??? 启动运行环境,加载Import的Bundle:
??? mvn install pax:provision,执行该命令后在provision/pom.xml将自动增
加该bundle的信息。
4. Import Bundle同时自动Import该Bundle依赖的Bundle:
??? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.http
??? .webconsole -Dversion=1.2.10 -DimportTransitive=true -DimportOptional=true -DwidenScope=true
5. 总结
?? mvn org.ops4j:maven-pax-plugin:create-project -DgroupId=org.sonatype.mcookbook -DartifactId
?? =OSGi-Project-New -Dversion=1.0.0
??
?? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.webconsole
?? -Dversion=3.1.8
?? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.http.webconsole
?? -Dversion=3.1.8 -DimportTransitive=true -DimportOptional=true -DwidenScope=true
?? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.scr??
?? -Dversion=1.6.0
?? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.scr?
?? -Dversion=1.6.0 -DimportTransitive=true -DimportOptional=true -DwidenScope=true
?? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.http.jetty
?? -Dversion=2.2.0
?? mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.http.jetty
?? -Dversion=2.2.0 -DimportTransitive=true -DimportOptional=true -DwidenScope=true
?? mvn install pax:provision
6. 方便获取Bundle POM文件的Repository
??? http://mvnrepository.com/
?
?