2013-10-09 27 views
1

什么是创建一个简单的OSGi (部署到处女服务器)使用行家,创建具有pom.xml中的Maven描述战争结构项目的最佳方法是什么?Maven的Web项目与Apache菲利克斯插件

一个结构目标是

*.jsp 
*.html 
META-INF 
MANIFEST (OSGI-CONFIG) 
WEB-INF 
    classes 
    lib 
    web.xml 

后来,当我创建一个项目

这是我的pom.xml

项目属性

<groupId>com.aaaa</groupId> 
<artifactId>first-maven-virgo-project</artifactId> 
<version>1.0.0</version> 
<packaging>war</packaging> 

菲利克斯插件

<plugin> 
    <groupId>org.apache.felix</groupId> 
    <artifactId>maven-bundle-plugin</artifactId> 
    <extensions>true</extensions> 
    <configuration> 
     <supportedProjectTypes> 
      <supportedProjectType>war</supportedProjectType> 
     </supportedProjectTypes> 
     <instructions> 
      <Export-Package>com.roshka.servlet</Export-Package> 
      <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
      <Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</Bundle-ClassPath> 
      <Embed-Directory>WEB-INF/lib</Embed-Directory> 
      <Embed-Dependency>*;scope=compile|runtime;</Embed-Dependency> 
      <Embed-Transitive>true</Embed-Transitive> 
      <Web-ContextPath>/hello</Web-ContextPath> 
      <Webapp-Context>hello</Webapp-Context> 
     </instructions> 
    </configuration> 
</plugin> 

但是,当我执行mvn install时,程序包不会创建MANIFEST文件,要打包到METAINF文件夹中。

我的felix项目有什么问题?什么是典型的pom.xml模板来创建OSGI BUNDLE和WAR OSGI BUNDLE?

p.s.如果我将WAR TO BUNDLE转换成Packaging Maven描述符,则JAR生成工作正常,用MANIFEST生成OK。但它不是WEB结构。

+0

谢谢布拉德的帮助 – jrey

回答

1

我的问题已经解决与未来的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>com.aaaa</groupId> 
<artifactId>first-maven-virgo-project</artifactId> 
<version>1.0.0</version> 
<packaging>war</packaging> 

<description>http://localhost:8090/system/console/bundles</description> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<dependencies> 

    <dependency> 
     <groupId>commons-lang</groupId> 
     <artifactId>commons-lang</artifactId> 
     <version>2.6</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.tomcat</groupId> 
     <artifactId>tomcat-servlet-api</artifactId> 
     <version>7.0.42</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.osgi</groupId> 
     <artifactId>org.osgi.core</artifactId> 
     <version>4.2.0</version> 
     <scope>provided</scope> 
    </dependency> 

</dependencies> 
<build> 
    <plugins> 

     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <configuration> 
       <archive> 
        <manifestFile>./src/main/webapp/META-INF/MANIFEST.MF</manifestFile> 
       </archive> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.felix</groupId> 
      <artifactId>maven-bundle-plugin</artifactId> 
      <extensions>true</extensions> 
      <executions> 
       <execution> 
        <id>bundle-manifest</id> 
        <phase>process-classes</phase> 
        <goals> 
         <goal>manifest</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <supportedProjectTypes> 
        <supportedProjectType>war</supportedProjectType> 
       </supportedProjectTypes> 
       <manifestLocation>./src/main/webapp/META-INF</manifestLocation> 
       <instructions> 
        <Export-Package>com.roshka.servlet</Export-Package> 
        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
        <Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</Bundle-ClassPath> 
        <Embed-Directory>WEB-INF/lib</Embed-Directory> 
        <Embed-Dependency>*;scope=compile|runtime;</Embed-Dependency> 
        <Embed-Transitive>true</Embed-Transitive> 
        <Web-ContextPath>/hello</Web-ContextPath> 
        <Webapp-Context>hello</Webapp-Context> 
       </instructions> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <executions> 
       <execution> 

        <id>copy-dependencies</id> 
        <phase>package</phase> 
        <goals> 
         <goal>copy-dependencies</goal> 
        </goals> 
        <configuration> 
         <Import-Package>javax.servlet,javax.servlet.http,javax.servlet.*,javax.servlet.jsp.*,javax.servlet.jsp.jstl.*,*</Import-Package> 
         <outputDirectory>./src/main/resources/WEB-INF/lib</outputDirectory> 
         <overWriteReleases>false</overWriteReleases> 
         <overWriteSnapshots>false</overWriteSnapshots> 
         <overWriteIfNewer>true</overWriteIfNewer> 
         <actTransitively>true</actTransitively> 
         <excludeScope>provided</excludeScope> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <!-- Enable this plugin for all modules --> 
      <groupId>org.apache.felix</groupId> 
      <artifactId>maven-bundle-plugin</artifactId> 
     </plugin> 
    </plugins> 
</build> 

0

有来自IBM的答案被发现here描述一步的工艺步骤。可以开发一个脚本来创建一个给予战争的捆绑包,我已经用java编写了一个脚本,作为构建步骤进行调用。

一个至关重要的区别是,IBM的步骤将成品留作罐子,而jrey将其留作战争文件。这可能是因为IBM的步骤可能会导致进一步的CICS捆绑,至少在使用RAD环境时至少需要知道罐子。

相关问题