TomDmitriev / gradle-bundle-plugin

Apache License 2.0
47 stars 23 forks source link

Add support for blueprint.xml file #35

Closed eschizoid closed 9 years ago

eschizoid commented 9 years ago

None of the OSGi services defined in blueprint.xml files are discovered by this plugin. This makes almost impossible for most of the Karaf users start using this great plugin since a lot of manual intervention is required.

TomDmitriev commented 9 years ago

Possibly duplicate of #32? Could you please try to apply the solution that worked for @nagaraj-shan

instruction '-plugin', 'aQute.lib.spring.SpringXMLType
eschizoid commented 9 years ago

@TomDmitriev sure thing I'll give it a shot and report back to you.

eschizoid commented 9 years ago

Hi I'm still unable to generate the Import-Service tag in the MANIFEST.MF file with the following configuration:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.dm.gradle:gradle-bundle-plugin:0.6.4'
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'org.dm.bundle'

bundle {
    instruction '-plugin', 'aQute.lib.spring.SpringXMLType'
}

group = 'com.peapod.synergy'
version = '1.4.3.RELEASE'
description = 'Synergy Coupons.com Routes'

dependencies {

    compile project(':coupons-client')
    compile project(':synergy-json-bindings')
    compile project(':synergy-util')
    compile(group: 'org.apache.camel', name: 'camel-core', version: '2.15.2') {
        exclude(module: 'jaxb-impl')
    }
    compile group: 'org.apache.camel', name: 'camel-http4', version: '2.15.2'
    compile group: 'org.apache.camel', name: 'camel-dozer', version: '2.15.2'
    compile group: 'org.apache.camel', name: 'camel-sql', version: '2.15.2'
    compile group: 'org.projectlombok', name: 'lombok', version: '1.14.8'
    compile group: 'org.apache.camel', name: 'camel-stream', version: '2.15.2'
    compile group: 'org.apache.camel', name: 'camel-jackson', version: '2.15.2'
    compile(group: 'org.apache.activemq', name: 'activemq-camel', version: '5.12.0')
    compile group: 'log4j', name: 'log4j', version: '1.2.17'
    testCompile group: 'org.apache.camel', name: 'camel-test', version: '2.15.2'
    testCompile group: 'org.apache.camel', name: 'camel-test-blueprint', version: '2.15.2'
    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
    testCompile group: 'com.oracle', name: 'ojdbc6', version: '11.2.0.3'
    testCompile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.0.1'
    testCompile group: 'org.apache.geronimo.components', name: 'geronimo-transaction', version: '3.1.1'
    compile(group: 'org.jboss.spec.javax.transaction', name: 'jboss-transaction-api_1.1_spec', version: '1.0.1.Final') 
    compile(group: 'org.osgi', name: 'org.osgi.core', version: '5.0.0') 
    compile(group: 'org.osgi', name: 'org.osgi.compendium', version: '5.0.0')
}

Executed command: gradle clean build jar

Manifest file Gradle Plugin

Manifest-Version: 1.0
Bnd-LastModified: 1448233330728
Bundle-ManifestVersion: 2
Bundle-Name: com.peapod.synergy.coupons-dao
Bundle-SymbolicName: com.peapod.synergy.coupons-dao
Bundle-Version: 1.4.3.RELEASE
Created-By: 1.8.0 (Oracle Corporation)
Import-Package: com.peapod.synergy.coupons.model.lists.getall,com.peapod
 .synergy.coupons.model.offers.activate.request,com.peapod.synergy.coupo
 ns.model.offers.recommended.request,com.peapod.synergy.coupons.model.of
 fers.recommended.response,com.peapod.synergy.coupons.model.register.req
 uest,com.peapod.synergy.coupons.model.register.response,com.peapod.syne
 rgy.util,com.peapod.synergy.web.json,com.peapod.synergy.web.json.coupon
 s,javax.crypto,javax.crypto.spec,javax.sql,javax.transaction;version="[
 1.1,2)",org.apache.camel;version="[2.15,3)",org.apache.camel.builder;ve
 rsion="[2.15,3)",org.apache.camel.component.http4;version="[2.15,3)",or
 g.apache.camel.component.sql;version="[2.15,3)",org.apache.camel.model;
 version="[2.15,3)",org.apache.camel.model.dataformat;version="[2.15,3)"
 ,org.apache.camel.spi;version="[2.15,3)",org.apache.camel.spring.spi;ve
 rsion="[2.15,3)",org.apache.commons.codec.binary;version="[1.9,2)",org.
 apache.commons.lang3;version="[3.3,4)",org.apache.http.impl.conn,org.do
 zer,org.slf4j;version="[1.7,2)",org.springframework.transaction.jta
Private-Package: com.peapod.synergy.coupons.config,com.peapod.synergy.co
 upons.processor,com.peapod.synergy.coupons.routes,com.peapod.synergy.co
 upons.util
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-2.4.1.201501161923

Manifest file Maven Plugin

Manifest-Version: 1.0
Bnd-LastModified: 1448230425751
Build-Jdk: 1.8.0
Built-By: magonzal
Bundle-Blueprint: OSGI-INF/blueprint/blueprint.xml
Bundle-Description: Data access objects and routes for using Coupons.com
Bundle-ManifestVersion: 2
Bundle-Name: Synergy Coupons.com Routes
Bundle-SymbolicName: com.peapod.synergy.coupons-dao
Bundle-Version: 1.4.3.RELEASE
Created-By: Apache Maven Bundle Plugin
Export-Package: com.peapod.synergy.coupons.config;uses:="com.peapod.syne
 rgy.coupons.model.offers.recommended.response,com.peapod.synergy.coupon
 s.model.register.request,com.peapod.synergy.web.json,org.apache.camel";
 version="1.4.3",com.peapod.synergy.coupons.processor;uses:="org.apache.
 camel,org.apache.camel.builder";version="1.4.3",com.peapod.synergy.coup
 ons.routes;uses:="org.apache.camel,org.apache.camel.builder";version="1
 .4.3",com.peapod.synergy.coupons.util;version="1.4.3"
Import-Package: com.peapod.synergy.coupons.model.lists.getall;version="[
 1.2,2)",com.peapod.synergy.coupons.model.offers.activate.request;versio
 n="[1.2,2)",com.peapod.synergy.coupons.model.offers.recommended.request
 ;version="[1.2,2)",com.peapod.synergy.coupons.model.offers.recommended.
 response;version="[1.2,2)",com.peapod.synergy.coupons.model.register.re
 quest;version="[1.2,2)",com.peapod.synergy.coupons.model.register.respo
 nse;version="[1.2,2)",com.peapod.synergy.web.json;version="[7.0,8)",com
 .peapod.synergy.web.json.coupons;version="[7.0,8)",com.peapod.synergy.u
 til;version="[1.4,2)",javax.crypto,javax.crypto.spec,javax.sql,javax.tr
 ansaction;version="[1.1,2)",org.apache.camel;version="[2.15,3)",org.apa
 che.camel.builder;version="[2.15,3)",org.apache.camel.component.http4;v
 ersion="[2.15,3)",org.apache.camel.component.sql;version="[2.15,3)",org
 .apache.camel.model;version="[2.15,3)",org.apache.camel.model.dataforma
 t;version="[2.15,3)",org.apache.camel.spi;version="[2.15,3)",org.apache
 .camel.spring.spi;version="[2.15,3)",org.apache.commons.codec.binary;ve
 rsion="[1.9,2)",org.apache.commons.lang3;version="[3.3,4)",org.apache.h
 ttp.impl.conn,org.dozer,org.osgi.service.blueprint;version="[1.0.0,2.0.
 0)",org.slf4j;version="[1.7,2)",org.springframework.transaction.jta,org
 .dozer.util
Import-Service: org.apache.camel.spi.EventNotifier;multiple:=false;filte
 r=(osgi.service.blueprint.compname=synergyLogger),javax.transaction.Use
 rTransaction;multiple:=false,org.apache.camel.spi.UuidGenerator;multipl
 e:=false,org.apache.camel.Component;multiple:=false;filter=(osgi.servic
 e.blueprint.compname=activemq),javax.transaction.TransactionManager;mul
 tiple:=false,javax.sql.DataSource;multiple:=false;filter=(osgi.jndi.ser
 vice.name=jdbc/atg)
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-2.3.0.201405100607
eschizoid commented 9 years ago

@TomDmitriev Would a sample blueprint.xml file help?

TomDmitriev commented 9 years ago

@TomDmitriev https://github.com/TomDmitriev Would a sample blueprint.xml file help?

Yes, please.

On 23 November 2015 at 02:40, Mariano Gonzalez notifications@github.com wrote:

@TomDmitriev https://github.com/TomDmitriev Would a sample blueprint.xml file help?

— Reply to this email directly or view it on GitHub https://github.com/TomDmitriev/gradle-bundle-plugin/issues/35#issuecomment-158818794 .

Yours sincerely, Artyom Dmitriev

eschizoid commented 9 years ago

Sample blueprint.xml

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
    xsi:schemaLocation="
           http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
           http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint-2.14.0.xsd">

    <!-- OSGi service references -->
    <reference id="activemq" component-name="activemq" interface="org.apache.camel.Component" />

    <reference id="uuid" interface="org.apache.camel.spi.UuidGenerator"/>

    <reference id="couponsEventLogger" component-name="synergyLogger" interface="org.apache.camel.spi.EventNotifier"/>

    <reference id="atgdb" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=jdbc/atg)" />

    <!-- Beans and references for database transactions -->
    <reference id="utx" interface="javax.transaction.UserTransaction"/>
    <reference id="tm" interface="javax.transaction.TransactionManager"/>

    <bean id="platformTransactionManager"
          class="org.springframework.transaction.jta.JtaTransactionManager">
        <argument ref="utx"/>
        <argument ref="tm"/>
    </bean>

    <bean id="txRequired" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
        <argument ref="platformTransactionManager"/>
        <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
    </bean>

    <bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
        <property name="dataSource" ref="atgdb"/>
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/blueprint" id="CouponsContext">

        <propertyPlaceholder id="placeholder" location="classpath:META-INF/sql/coupons-named-queries.properties"/>

        <contextScan/>

    </camelContext>
</blueprint>

All the OSGi services are completely ignored.

Thanks for your help.

TomDmitriev commented 9 years ago

As stated here Import-Service is deprecated. I have looked through the sources of the bnd tool and apparently this instruction is never generated so if you do want to use it you have to declare it explicitly.

eschizoid commented 9 years ago

@TomDmitriev thanks for all your help, I just finish testing your plugin with several bundles and I was able to deploy all of them inside karaf 3.x. It seems that the maven-bundle-plugin is generating unnecessary headers in the MANIFEST.MF file.