2012-08-15 3 views
1

Я написал невероятно простой (без файлов java-файлов) военный файл, который я надеюсь развернуть в servicemix. Он имеет следующую структуру каталогов:Развертывание простой войны как пакета OSGi в ServiceMix

. 
|-src 
    |-main 
    |-webapp 
     |-css 
     |-js 
     |-WEB-INF 
     \-web.xml 
     \-index.html 
\-pom.xml 

Я могу развернуть это к причалу контейнер работающему в ServiceMix, используя следующие команды:

>install war:file:///<Fully qualified war location>?Webapp-Context=<Application name> 
>osgi:start <Bundle id> 
>http://localhost:8181/<Application name>/index.html 

То, что я предпочел бы является для горячего развертывание, как я делать с остальными моими связями. Как выглядит pom.xml? Чем проще, тем лучше.

ответ

1

Это сделал трюк для меня (хотя я должен добавить заполнитель Java файл для обеспечения целевых/классов был сгенерирован):

<plugins> 
    <plugin> 
     <artifactId>maven-war-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> 
     <configuration> 
      <supportedProjectTypes> 
       <supportedProjectType>jar</supportedProjectType> 
       <supportedProjectType>bundle</supportedProjectType> 
       <supportedProjectType>war</supportedProjectType> 
      </supportedProjectTypes> 
      <instructions> 
       <Bundle-Version>${pom.version}</Bundle-Version> 
       <Webapp-Context>webclient</Webapp-Context> 
       <_include>-osgi.bnd</_include> 
      </instructions> 
     </configuration> 
    </plugin> 
</plugins> 
2

У меня было аналогичное требование (только Karaf, а не ServiceMix). Шахта выглядит так:

Редактировать: См. Ответ ben1729 для дополнительной конфигурации плагина. Я забыл эту часть, потому что она была в моем родительском pom.xml для всех моих модулей.

<plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <configuration> 
       <archive> 
        <!-- add the generated manifest to the war --> 
        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> 
       </archive> 
       <overlays> 
        <overlay> 
        <!-- empty groupId/artifactId represents the current build --> 
         <excludes> 
          <exclude>*</exclude> 
         </excludes> 
        </overlay> 
       </overlays> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.felix</groupId> 
      <artifactId>maven-bundle-plugin</artifactId> 
      <configuration> 
       <instructions> 
        <Web-ContextPath>/base/url</Web-ContextPath> 
       </instructions> 
      </configuration> 
     </plugin> 
    </plugins> 
Смежные вопросы