Transient feature aggregation on KAR creation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Transient feature aggregation on KAR creation

Maurice Betzel
Windows 10
Karaf 4.2.6 / 4.3.0.RC1
Cellar 4.1.3

Dear community, i am trying to get to grips with the feature functionality
of Karaf. Until now i created my feature files for KAR packaging manually in
a seperate Maven module, and i am looking for a way to do this with the
Karaf Maven plugin.
I have studied the tooling karaf-maven-plugin test cases but i cannot seem
to get it to work, so here i am.

As a example i have a MariaDB base project that on deploy installs all
needed external bundles and my own generic API bundle that gets used by
projects building on the base project. Best explained by example, my current
*feature.xml*:

<?xml version="1.0" encoding="UTF-8"?>
<features
name="platform-eu.abeel.platform.facade.mariadb-features-${project.version}"
xmlns="http://karaf.apache.org/xmlns/features/v1.6.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.6.0
http://karaf.apache.org/xmlns/features/v1.6.0">

    <feature name="platform-facade-mariadb-persistence"
version="${project.version}">
        <feature>aries-blueprint</feature>
        <feature>transaction</feature>
        <feature>jndi</feature>
       
        <bundle>mvn:org.osgi/org.osgi.service.jdbc/1.0.0</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc/${pax.jdbc.version}</bundle>
       
<bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-mariadb/${pax.jdbc.version}</bundle>
       
<bundle>mvn:org.apache.karaf.jdbc/org.apache.karaf.jdbc.core/${karaf.version}</bundle>
        <bundle>mvn:org.apache.aries/org.apache.aries.util/1.1.3</bundle>
       
<bundle>mvn:org.apache.aries.transaction/org.apache.aries.transaction.manager/${aries.transaction.manager.version}</bundle>
       
<bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
       
<bundle>mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.6_spec/1.0</bundle>
       
<bundle>mvn:org.apache.geronimo.specs/geronimo-validation_1.0_spec/1.1</bundle>
       
<bundle>mvn:org.apache.geronimo.components/geronimo-connector/3.1.4</bundle>
       
<bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/${pax.jdbc.version}</bundle>
       
<bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-aries/${pax.jdbc.version}</bundle>
       
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.9.3_1</bundle>
       
<bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-config/${pax.jdbc.version}</bundle>
       
        <bundle>mvn:org.osgi/org.osgi.service.jpa/1.1.0</bundle>
       
<bundle>mvn:javax.interceptor/javax.interceptor-api/${javax.interceptor-api.version}</bundle>
       
<bundle>mvn:javax.persistence/javax.persistence-api/${javax.persistence-api.version}</bundle>
        <capability>
       
osgi.service;effective:=active;objectClass=javax.persistence.spi.PersistenceProvider
        </capability>
        <bundle dependency="true"
start-level="30">mvn:org.apache.felix/org.apache.felix.coordinator/1.0.2</bundle>
        <bundle
start-level="30">mvn:org.apache.aries.jpa.javax.persistence/javax.persistence_2.1/${aries.jpa.version}</bundle>
        <bundle
start-level="30">mvn:org.apache.aries.jpa/org.apache.aries.jpa.api/${aries.jpa.version}</bundle>
        <bundle
start-level="30">mvn:org.apache.aries.jpa/org.apache.aries.jpa.container/${aries.jpa.version}</bundle>
        <bundle
start-level="30">mvn:org.apache.aries.jpa/org.apache.aries.jpa.support/${aries.jpa.version}</bundle>
        <bundle
start-level="30">mvn:org.apache.aries.jpa/org.apache.aries.jpa.blueprint/${aries.jpa.version}</bundle>
       
        <bundle>mvn:org.jboss.logging/jboss-logging/3.3.2.Final</bundle>
       
<bundle>mvn:org.hibernate.javax.persistence/hibernate-jpa-2.1-api/1.0.0.Final</bundle>
       
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/2.7.7_5</bundle>
        <bundle>mvn:org.javassist/javassist/3.24.0-GA</bundle>
        <bundle>mvn:net.bytebuddy/byte-buddy/1.9.5</bundle>
       
<bundle>mvn:org.jboss.spec.javax.transaction/jboss-transaction-api_1.2_spec/1.1.1.Final</bundle>
        <bundle>mvn:org.jboss/jandex/2.0.5.Final</bundle>
        <bundle>mvn:com.fasterxml/classmate/1.3.4</bundle>
       
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/2.1.1_1</bundle>
       
<bundle>mvn:org.hibernate.common/hibernate-commons-annotations/5.1.0.Final</bundle>
       
<bundle>mvn:org.hibernate/hibernate-core/${hibernate.orm.version}</bundle>
       
<bundle>mvn:org.hibernate/hibernate-osgi/${hibernate.orm.version}</bundle>
        <capability>
           
osgi.service;objectClass=javax.persistence.spi.PersistenceProvider;effective:=active;javax.persistence.provider=org.hibernate.jpa.HibernatePersistenceProvider
        </capability>
       
       
<bundle>mvn:org.mariadb.jdbc/mariadb-java-client/${mariadb.client.version}</bundle>
       
<bundle>mvn:eu.abeel.platform/dosgi/${abeel.platform.version}</bundle>
       
<bundle>mvn:eu.abeel.platform.facade.mariadb/api/${project.version}</bundle>
    </feature>
</features>

*POM*

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>parent</artifactId>
        <groupId>eu.abeel.platform.facade.mariadb</groupId>
        <version>3.1.2</version>
        <relativePath>../parent/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>platform-facade-mariadb-service</artifactId>
    <packaging>kar</packaging>

    <name>Abeel :: Enterprise Platform :: Facade :: MariaDB :: KAR</name>

    <description>Karaf archive creation</description>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Keeping this up to date by hand gets rather time consuming, so i am trying
something like this *feature*:

    <?xml version="1.0" encoding="UTF-8"?>
<features
name="platform-eu.abeel.platform.facade.mariadb-features-${project.version}"
xmlns="http://karaf.apache.org/xmlns/features/v1.6.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.6.0
http://karaf.apache.org/xmlns/features/v1.6.0">

   
<repository>mvn:org.ops4j.pax.jdbc/pax-jdbc-features/${pax.jdbc.version}/xml/features</repository>

    <feature name="platform-facade-mariadb-persistence"
version="${project.version}">
        <feature>pax-jdbc-spec</feature>
    </feature>

</features>

*POM*

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>parent</artifactId>
        <groupId>eu.abeel.platform.facade.mariadb</groupId>
        <version>3.1.3</version>
        <relativePath>../parent/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>platform-facade-mariadb-service</artifactId>
    <packaging>pom</packaging>

    <name>Abeel :: Enterprise Platform :: Facade :: MariaDB :: KAR</name>

    <description>Karaf archive creation</description>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-features</id>
                        <goals>
                            <goal>features-generate-descriptor</goal>
                        </goals>
                        <configuration>
                            <aggregateFeatures>true</aggregateFeatures>
                            <enableGeneration>true</enableGeneration>
                        </configuration>
                    </execution>
                    <execution>
                        <id>kar</id>
                        <goals>
                            <goal>kar</goal>
                        </goals>
                        <configuration>
                            <classifier>kar</classifier>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.ops4j.pax.jdbc</groupId>
            <artifactId>pax-jdbc-features</artifactId>
            <version>${pax.jdbc.version}</version>
            <classifier>features</classifier>
            <type>xml</type>
            <scope>compile</scope>
        </dependency>
    </dependencies>

</project>

But this results in getting all of Pax JDBC *features* in the KAR:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.6.0"
name="platform-eu.abeel.platform.facade.mariadb-features-3.1.3">
   
<repository>mvn:org.ops4j.pax.jdbc/pax-jdbc-features/1.4.4/xml/features</repository>
    <feature name="platform-facade-mariadb-persistence" version="3.1.3">
        <feature>pax-jdbc-spec</feature>
    </feature>
    <feature name="pax-jdbc-spec" description="Provides OSGi JDBC Service
spec" version="1.4.4">
        <bundle>mvn:org.osgi/org.osgi.service.jdbc/1.0.0</bundle>
    </feature>
    <feature name="pax-jdbc" description="Provides JDBC Service support"
version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-config" description="Provides JDBC Config
support" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
        <bundle
dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.9.3_1</bundle>
        <bundle
dependency="true">mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.4</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-db2" description="Provides JDBC DB2
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-db2/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-teradata" description="Provides JDBC Teradata
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-teradata/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-derby" description="Provides JDBC Derby Embedded
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.derby/derby/10.14.2.0</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-derby/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-derbyclient" description="Provides JDBC Derby
Client DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.derby/derbyclient/10.14.2.0</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-derbyclient/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-h2" description="Provides JDBC H2
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle>mvn:com.h2database/h2/1.4.199</bundle>
    </feature>
    <feature name="pax-jdbc-hsqldb" description="Provides JDBC HSQLDB
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle dependency="true">mvn:org.hsqldb/hsqldb/2.5.0</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-hsqldb/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-mariadb" description="Provides JDBC Mariadb
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.mariadb.jdbc/mariadb-java-client/2.4.4</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-mariadb/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-oracle" description="Provides JDBC Oracle
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-oracle/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-postgresql" description="Provides JDBC
PostgreSQL DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
        <bundle>mvn:org.postgresql/postgresql/42.2.8</bundle>
    </feature>
    <feature name="pax-jdbc-sqlite" description="Provides JDBC SQLite
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle dependency="true">mvn:org.xerial/sqlite-jdbc/3.28.0</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-sqlite/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-mssql" description="Provides JDBC MSSQL
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
        <bundle
dependency="true">mvn:com.microsoft.sqlserver/mssql-jdbc/7.4.1.jre8</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-mssql/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-jtds" description="Provides JDBC jTDS
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle>wrap:mvn:net.sourceforge.jtds/jtds/1.3.1</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-jtds/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-pool-dbcp2" description="Provides JDBC Pooling
DataSourceFactory" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.commons/commons-dbcp2/2.1.1</bundle>
        <bundle
dependency="true">mvn:org.apache.commons/commons-pool2/2.6.2</bundle>
        <bundle
dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.cglib/3.3.0_1</bundle>
        <bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.4</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-dbcp2/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-pool-c3p0" description="Provides JDBC Pooling
using C3P0" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.c3p0/0.9.5.4_1</bundle>
        <bundle
dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.cglib/3.3.0_1</bundle>
        <bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.4</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-c3p0/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-pool-hikaricp" description="Provides JDBC
Pooling DataSourceFactory using HikariCP" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.cglib/3.3.0_1</bundle>
        <bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.4</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-hikaricp/1.4.4</bundle>
        <bundle>mvn:com.zaxxer/HikariCP/3.4.1</bundle>
    </feature>
    <feature name="pax-jdbc-pool-aries" description="Provides JDBC Pooling
DataSourceFactory using Aries Transaction JDBC" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
        <bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.6_spec/1.0</bundle>
        <bundle
dependency="true">mvn:org.apache.geronimo.specs/geronimo-validation_1.0_spec/1.1</bundle>
        <bundle
dependency="true">mvn:org.apache.geronimo.components/geronimo-connector/3.1.4</bundle>
        <bundle
dependency="true">mvn:org.apache.aries/org.apache.aries.util/1.1.3</bundle>
        <bundle
dependency="true">mvn:org.apache.aries.transaction/org.apache.aries.transaction.manager/1.3.3</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.4</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-aries/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-pool-narayana" description="Provides JDBC
Pooling DataSourceFactory using Narayana Transaction Manager"
version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <bundle
dependency="true">mvn:org.apache.commons/commons-dbcp2/2.1.1</bundle>
        <bundle
dependency="true">mvn:org.apache.commons/commons-pool2/2.6.2</bundle>
        <bundle
dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.cglib/3.3.0_1</bundle>
        <bundle
dependency="true">mvn:org.jboss.narayana.osgi/narayana-osgi-jta/5.9.8.Final</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.4</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-narayana/1.4.4</bundle>
    </feature>
    <feature name="pax-jdbc-pool-transx" description="Provides JDBC Pooling
DataSourceFactory using Pax TransX JDBC" version="1.4.4">
        <feature>pax-jdbc-spec</feature>
        <feature>pax-transx-jdbc</feature>
        <feature>pax-transx-tm</feature>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.4</bundle>
        <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-transx/1.4.4</bundle>
    </feature>
    <feature name="platform-facade-mariadb-service" description="Abeel ::
Enterprise Platform :: Facade :: MariaDB :: KAR" version="3.1.3">
        <details>Karaf archive creation</details>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-spec</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-config</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-db2</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-teradata</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-derby</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-derbyclient</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-h2</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-hsqldb</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-mariadb</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-oracle</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-postgresql</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-sqlite</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-mssql</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-jtds</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-pool-dbcp2</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-pool-c3p0</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-pool-hikaricp</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-pool-aries</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-pool-narayana</feature>
        <feature version="1.4.4" prerequisite="false"
dependency="false">pax-jdbc-pool-transx</feature>
    </feature>
</features>

I was expecting only pax-jdbc-spec to be packaged, so i am assuming i am on
the wrong track. How do i accomplish only packaging the nessecary external
bundles with my own including configuration so the depending projects find
everyting installed on deploy?

 



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
if ( you want ) { you can } else { you can't }