Skip to content

protenhan/gradle-karaf-plugin

 
 

Repository files navigation

gradle-karaf-plugin

  • ✓ Karaf features

  • ✓ Karaf KAR

  • ❏ Karaf custom distribution

Example

plugins {
    id 'maven'
    id 'java'
    id 'com.github.lburgazzoli.karaf' version '0.0.32'
}

repositories {
    mavenCentral()
}

group   = 'com.github.lburgazzoli'
version = '0.0.1'

configurations {
    commons
    json
    rest
    square
    hazelcast

    // Avoid adding transitive dependencies
    ariesBlueprint {
        transitive = false
    }
}

dependencies {
    runtime 'com.google.guava:guava:19.0'
    commons 'commons-io:commons-io:2.4'

    json 'com.fasterxml.jackson.core:jackson-core:2.7.0'
    json 'com.fasterxml.jackson.core:jackson-databind:2.7.0'
    json 'com.fasterxml.jackson.core:jackson-annotations:2.7.0'

    square 'com.squareup.retrofit2:retrofit:2.0.0'

    ariesBlueprint 'org.apache.aries.blueprint:org.apache.aries.blueprint.api:1.0.1'
    ariesBlueprint 'org.apache.aries.blueprint:org.apache.aries.blueprint.cm:1.0.8'
    ariesBlueprint 'org.apache.aries.blueprint:org.apache.aries.blueprint.core.compatibility:1.0.0'
    ariesBlueprint 'org.apache.aries.blueprint:org.apache.aries.blueprint.core:1.6.0'
    ariesBlueprint 'org.apache.karaf.bundle:org.apache.karaf.bundle.blueprintstate:4.0.4'

    hazelcast 'org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1'
    hazelcast 'com.eclipsesource.minimal-json:minimal-json:0.9.2'
    hazelcast 'com.hazelcast:hazelcast-all:3.6.1'
}

karaf {
    features {
        xsdVersion  = '1.2.0'
        version     = '4.0.0'
        description = 'Karaf features'

        // Include the current project, false by default
        includeProject = false

        // Define a feature named 'common' with dependencies from runtime
        // configuration (default) and commons
        feature {
            name        = 'common'
            description = 'Common dependencies'

            // Include one or more additional configuration
            configuration 'commons'
        }

        // Define a feature named 'rest' with dependencies from json and square
        // configurations
        feature {
            name        = 'rest'
            description = 'REST dependencies'

            // Override configurations
            configurations 'json', 'square'
        }

        feature {
            name        = 'aries-blueprint'
            description = 'Aries Blueprint'

            // Override configurations
            configurations 'ariesBlueprint'

            // Add feature dependency
            feature 'aries-proxy'

            // Customize artifacts with group 'org.apache.aries.blueprint'
            bundle ('org.apache.aries.blueprint') {
                attribute 'start-level', '20'
            }

            // Customize artifacts with group 'org.apache.karaf.bundle'
            bundle ('org.apache.karaf.bundle') {
                attribute 'start-level', '30'
            }

            conditional('bundle') {
                bundle 'org.apache.karaf.bundle:org.apache.karaf.bundle.blueprintstate'
            }

            capability('osgi.service') {
                effective = 'active'
                extra     = 'objectClass=org.apache.aries.blueprint.services.ParserService'
            }

            capability('osgi.extender') {
                extra     = 'osgi.extender="osgi.blueprint";uses:="org.osgi.service.blueprint.container,org.osgi.service.blueprint.reflect";version:Version="1.0"'
            }
        }

        // Define a feature named 'hazelcast'
        feature {
            name        = 'hazelcast'
            description = 'In memory data grid'

            configurations 'hazelcast'

            // Add configFile entry
            configFile {
                filename = "/etc/hazelcast.xml"
                uri      = "mvn:org.apache.karaf.cellar/apache-karaf-cellar/${project.version}/xml/hazelcast"
            }

            // Add configFile entry and copy a local file to the kar repository
            configFile {
                filename = "/etc/hazelcast-clustered.xml"
                file     = file("etc/hazelcast-clustered-defaults.xml")
                uri      = "mvn:org.apache.karaf.cellar/apache-karaf-cellar/${project.version}/xml/hazelcast-clustered"
            }
        }
    }

    // Enable generation of Karaf Archive KAR based on features defined above.
    // To generate kar either use generateKar, assemble or install
    kar {
        // Optionally set the kar name, default is:
        //
        //     ${features.name}-${features.version}.kar
        //
        // Extension is automatically set to .kar
        archiveName = 'foo'
    }
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="gradle-karaf-features-plugin-examples">
  <feature name="common" version="0.0.1" description="Common dependencies">
    <bundle>mvn:com.google.guava/guava/19.0</bundle>
    <bundle>mvn:commons-io/commons-io/2.4</bundle>
    <capability></capability>
  </feature>
  <feature name="rest" version="0.0.1" description="REST dependencies">
    <bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.7.0</bundle>
    <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/2.7.0</bundle>
    <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/2.7.0</bundle>
    <!--
        as squareup's jars a re not OSGi ready, the plugin automatically adds wrap instruction
    -->
    <bundle>wrap:mvn:com.squareup.okio/okio/1.6.0</bundle>
    <bundle>wrap:mvn:com.squareup.okhttp3/okhttp/3.2.0</bundle>
    <bundle>wrap:mvn:com.squareup.retrofit2/retrofit/2.0.0</bundle>
    <capability></capability>
  </feature>
  <feature name="aries-blueprint" version="0.0.1" description="Aries Blueprint">
    <feature>aries-proxy</feature>
    <bundle start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.api/1.0.1</bundle>
    <bundle start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.cm/1.0.8</bundle>
    <bundle start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0</bundle>
    <bundle start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core/1.6.0</bundle>
    <conditional>
      <condition>bundle</condition>
      <bundle start-level="30">mvn:org.apache.karaf.bundle/org.apache.karaf.bundle.blueprintstate/4.0.4</bundle>
    </conditional>
    <capability>osgi.service;effective:='active';resolution:='mandatory';objectClass=org.apache.aries.blueprint.services.ParserService,osgi.extender;effective:='resolve';resolution:='mandatory';osgi.extender="osgi.blueprint";uses:="org.osgi.service.blueprint.container,org.osgi.service.blueprint.reflect";version:Version="1.0"</capability>
  </feature>
  <feature name="hazelcast" version="1.2.3" description="In memory data grid">
    <configfile filename="/etc/hazelcast.xml">mvn:org.apache.karaf.cellar/apache-karaf-cellar/1.2.3/xml/hazelcast</configfile>
    <configfile filename="/etc/hazelcast.xml">mvn:org.apache.karaf.cellar/apache-karaf-cellar/1.2.3/xml/hazelcast-clustered</configfile>
    <bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
    <bundle>mvn:com.eclipsesource.minimal-json/minimal-json/0.9.2</bundle>
    <bundle>mvn:com.hazelcast/hazelcast-all/3.6.1</bundle>
  </feature>
</features>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Groovy 100.0%