{"id":28239194,"url":"https://github.com/lburgazzoli/gradle-karaf-plugin","last_synced_at":"2025-10-05T03:05:23.742Z","repository":{"id":4213294,"uuid":"48477937","full_name":"lburgazzoli/gradle-karaf-plugin","owner":"lburgazzoli","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-06T08:00:47.000Z","size":512,"stargazers_count":21,"open_issues_count":15,"forks_count":14,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-06-10T03:49:02.540Z","etag":null,"topics":["gradle","karaf"],"latest_commit_sha":null,"homepage":null,"language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lburgazzoli.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-12-23T08:02:56.000Z","updated_at":"2023-12-10T22:26:36.000Z","dependencies_parsed_at":"2023-07-05T20:16:27.128Z","dependency_job_id":null,"html_url":"https://github.com/lburgazzoli/gradle-karaf-plugin","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lburgazzoli%2Fgradle-karaf-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lburgazzoli%2Fgradle-karaf-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lburgazzoli%2Fgradle-karaf-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lburgazzoli%2Fgradle-karaf-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lburgazzoli","download_url":"https://codeload.github.com/lburgazzoli/gradle-karaf-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lburgazzoli%2Fgradle-karaf-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259221950,"owners_count":22823989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gradle","karaf"],"created_at":"2025-05-19T02:11:52.510Z","updated_at":"2025-10-05T03:05:18.692Z","avatar_url":"https://github.com/lburgazzoli.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"gradle-karaf-plugin\n===================\n\nimage:https://github.com/lburgazzoli/gradle-karaf-plugin/workflows/Build/badge.svg?branch=master[title=\"Build Status\", link=\"https://github.com/lburgazzoli/gradle-karaf-plugin/actions\"] image:https://maven-badges.herokuapp.com/maven-central/com.github.lburgazzoli/gradle-karaf-plugin/badge.svg[title=\"Maven Central\", link=\"https://maven-badges.herokuapp.com/maven-central/com.github.lburgazzoli/gradle-karaf-plugin\"] image:http://img.shields.io/:license-apache-brightgreen.svg[title=\"License\", link=\"http://www.apache.org/licenses/LICENSE-2.0.html\"]image:https://badges.gitter.im/lburgazzoli/gradle-karaf-plugin.svg[link=\"https://gitter.im/lburgazzoli/gradle-karaf-plugin?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge\"]\n\n== Features\n\n- [x] Karaf features\n- [x] Karaf KAR\n- [ ] Karaf custom distribution\n- [ ] Nice documentation\n\n== Tasks\nAutomatically generate Karaf feature file in /build/karaf/features\n[source,groovy]\n----\ngradle generateFeatures\n----\n\nAutomatically generate Karaf repo (system directory) in /build/karaf/repo\n[source,groovy]\n----\ngradle generateRepo\n----\n\nAutomatically generate Karaf kar file in /build/karaf/kar\n[source,groovy]\n----\ngradle generateKar\n----\n\n\n== Description\n\nThe *gradle-karaf-plugin* is designed to automate the process of creating Apache Karaf *feature*, *repo*, and *kar* files.\n\nThis plugin generates the desired karaf files by utilizing the native gradle configurations mechanism. As gradle automatically determines all direct and transitive dependencies, a complete list of dependencies is provided to the plugin for a given set of configurations.\n\nAs OSGi can only install bundles, standard jars must be wrapped to add necessary manifest information specifying the jar's import and export packages. To simply this process Karaf provides a native wrap tool that can be run during jar/bundle installation. This plugin determines if each dependency is already a bundle and adds the _wrap_ tag if it is not (see example below).\n\n== Notes\n - Considering that gradle automatically \"promotes\" dependency version conflicts, only a single version of a dependency is avalible per each gradle configuration. As OSGi bundles can mandate certain versions of dependencies, it is likely that multiple versions of a jar/bundle are needed. In this case, it is recommended to add another gradle configuration, perhaps \"karaf\", and specify the other dependency version under this new configuration. Include both configurations to the karaf-\u003efeatures-\u003efeature-\u003econfigurations statement (see example below). This will result in both versions of the dependency being added to the feature/kar file.\n\n - Karaf 4 support requires the xsd version be at least '1.3.0'.\n\n - This plugin is an extension of the previous https://github.com/lburgazzoli/gradle-karaf-features-plugin[gradle-karaf-feature-plugin^]\n\n== Requirements\n - Gradle 3.0+\n\n== Usage\n[source,groovy]\n----\nplugins {\n    id 'com.github.lburgazzoli.karaf' version '0.0.49'\n}\n\nrepositories {\n    mavenCentral()\n}\n----\nOr for compatibility with old versions of Gradle:\n[source,groovy]\n----\napply plugin: 'com.github.lburgazzoli.karaf'\n\nbuildscript {\n    dependencies {\n        classpath \"gradle.plugin.com.github.lburgazzoli:gradle-karaf-plugin:0.0.49\"\n    }\n}\n\nrepositories {\n    mavenCentral()\n}\n----\n\n== Example\n\n=== build.gradle\n\n[source,groovy]\n----\nplugins {\n    id 'java' //required only for runtime configuration\n    id 'com.github.lburgazzoli.karaf' version '0.0.49'\n}\n\nrepositories {\n    mavenCentral()\n}\n\ngroup   = 'com.github.lburgazzoli'\nversion = '0.0.1'\n\nconfigurations {\n    foo\n    bar\n    // This will avoid adding transitive dependencies\n    baz {\n        transitive = false\n    }\n}\n\ndependencies {\n    runtime 'com.google.guava:guava:19.0'\n\n    foo 'commons-io:commons-io:2.4'\n\n    bar (\n      'com.fasterxml.jackson.core:jackson-core:2.7.0',\n      'com.fasterxml.jackson.core:jackson-databind:2.7.0',\n      'com.fasterxml.jackson.core:jackson-annotations:2.7.0'\n    )\n\n    baz 'com.squareup.retrofit2:retrofit:2.0.0'\n}\n\nkaraf {\n    features {\n        // See section below for karaf 4 support if using 1.3.0\n        xsdVersion  = '1.2.0'\n        name = \"${project.name}-${version}\"\n        outputFile = file(\"${project.buildDir}/karaf/features/${project.name}-${project.version}-feature.xml\")\n        version     = '4.0.0' // Your project version\n        description = 'Karaf features'\n\n        // Include the current project, false by default\n        includeProject = false\n\n        // Add in extra repositories to the features xml file\n        repository \"mvn:org.apache.karaf.features/standard/4.0.0/xml/features\"\n\n        // Define a feature named 'my-feature1' with dependencies from runtime configuration (default if java plugin is enabled) and 'foo'\n        feature {\n            name        = 'my-feature1'\n            description = 'Includes runtime and foo dependencies'\n\n            // Include one or more additional configuration\n            configuration 'foo'\n        }\n\n        // Define a feature named 'my-feature2' with dependencies from 'bar' and 'baz' configurations\n        feature {\n            name        = 'my-feature2'\n            description = 'Includes runtime, bar and baz dependencies'\n\n            // Override configurations\n            configurations 'bar', 'baz'\n        }\n\n        feature {\n            name        = 'my-feature3'\n            description = 'Feature with capabilities'\n\n            // Override configurations\n            configurations 'foo', 'bar'\n\n            // Add feature dependency (newest)\n            feature 'aries-proxy'\n\n            // Customize artifacts with group 'com.fasterxml.jackson.core'\n            bundle ('com.fasterxml.jackson.core') {\n                attribute 'start-level', '20'\n            }\n\n            conditional('bundle') {\n                bundle 'commons-io:commons-io'\n            }\n            capability('osgi.service') {\n                effective = 'active'\n                extra     = 'objectClass=org.apache.aries.blueprint.services.ParserService'\n            }\n\n            capability('osgi.extender') {\n                extra     = 'osgi.extender=\"osgi.blueprint\";uses:=\"org.osgi.service.blueprint.container,org.osgi.service.blueprint.reflect\";version:Version=\"1.0\"'\n            }\n        }\n\n        // Define a feature named 'my-feature4'\n        feature {\n            name        = 'my-feature4'\n            description = 'Feature with config file'\n\n            configurations 'foo'\n\n            // Add configFile entry\n            configFile {\n                filename = \"/etc/my-file.xml\"\n                uri      = \"mvn:com.my.company/my.artifact/${project.version}/xml/my-file\"\n            }\n\n            // Add configFile entry and copy a local file to the kar repository\n            configFile {\n                filename = '${karaf.etc}/my.Config.cfg'\n                file     = file(\"resources/my.Config.cfg\")\n                uri      = \"mvn:com.my.company/my.artifact/${project.version}/cfg/features\"\n                override = true // (optional) Override existing configuration files within karaf. False by default\n            }\n        }\n    }\n\n    // Enable generation of an OSGi bundles repository, laid out as a Maven 2 repository based on\n    // the features defined above. This can be used to provision the 'system' directory of a\n    // custom Karaf distribution.\n    // To generate repo use generateRepo, assemble or install\n    repo {\n    }\n\n    // Enable generation of Karaf Archive KAR based on features defined above.\n    // To generate kar either use generateKar, assemble or install\n    kar {\n        // Optionally set the kar name, default is:\n        //\n        //     ${features.name}-${features.version}.kar\n        //\n        // Extension is automatically set to .kar\n        archiveName = 'foo'\n    }\n}\n----\n\n=== Generated Result from \"gradle generateFeatures\"\n\n[source,xml]\n----\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n\u003cfeatures xmlns=\"http://karaf.apache.org/xmlns/features/v1.2.0\" name=\"my.project-0.0.1\"\u003e\n  \u003crepository\u003emvn:org.apache.karaf.features/standard/4.0.0/xml/features\u003c/repository\u003e\n  \u003cfeature name=\"my-feature1\" version=\"0.0.1\" description=\"Includes runtime and foo dependencies\"\u003e\n    \u003cbundle\u003emvn:com.google.guava/guava/19.0\u003c/bundle\u003e\n    \u003cbundle\u003emvn:commons-io/commons-io/2.4\u003c/bundle\u003e\n  \u003c/feature\u003e\n  \u003cfeature name=\"my-feature2\" version=\"0.0.1\" description=\"Includes runtime, bar and baz dependencies\"\u003e\n    \u003cbundle\u003emvn:com.fasterxml.jackson.core/jackson-core/2.7.0\u003c/bundle\u003e\n    \u003cbundle\u003emvn:com.fasterxml.jackson.core/jackson-annotations/2.7.0\u003c/bundle\u003e\n    \u003cbundle\u003emvn:com.fasterxml.jackson.core/jackson-databind/2.7.0\u003c/bundle\u003e\n    \u003c!--\n        as squareup's jars a re not OSGi ready, the plugin automatically adds wrap instruction\n    --\u003e\n    \u003cbundle\u003ewrap:mvn:com.squareup.retrofit2/retrofit/2.0.0\u003c/bundle\u003e\n  \u003c/feature\u003e\n  \u003cfeature name=\"my-feature3\" version=\"0.0.1\" description=\"Feature with capabilities\"\u003e\n    \u003cfeature\u003earies-proxy\u003c/feature\u003e\n    \u003cbundle start-level=\"20\"\u003emvn:com.fasterxml.jackson.core/jackson-core/2.7.0\u003c/bundle\u003e\n    \u003cbundle start-level=\"20\"\u003emvn:com.fasterxml.jackson.core/jackson-annotations/2.7.0\u003c/bundle\u003e\n    \u003cbundle start-level=\"20\"\u003emvn:com.fasterxml.jackson.core/jackson-databind/2.7.0\u003c/bundle\u003e\n    \u003cconditional\u003e\n      \u003ccondition\u003ebundle\u003c/condition\u003e\n      \u003cbundle\u003emvn:commons-io/commons-io/2.4\u003c/bundle\u003e\n    \u003c/conditional\u003e\n    \u003ccapability\u003eosgi.service;effective:='active';resolution:='mandatory';objectClass=org.apache.aries.blueprint.services.ParserService\u003c/capability\u003e\n    \u003ccapability\u003eosgi.extender;effective:='resolve';resolution:='mandatory';osgi.extender=\"osgi.blueprint\";uses:=\"org.osgi.service.blueprint.container,org.osgi.service.blueprint.reflect\";version:Version=\"1.0\"\u003c/capability\u003e\n  \u003c/feature\u003e\n  \u003cfeature name=\"my-feature4\" version=\"0.0.1\" description=\"Feature with config file\"\u003e\n    \u003cconfigfile finalname=\"/etc/my-file.xml\"\u003emvn:com.my.company/my.artifact/0.0.1/xml/my-file\u003c/configfile\u003e\n    \u003cconfigfile finalname=\"${karaf.etc}/my.Config.cfg\" override=\"true\"\u003emvn:com.my.company/my.artifact/0.0.1/cfg/features\u003c/configfile\u003e\n    \u003cbundle\u003emvn:commons-io/commons-io/2.4\u003c/bundle\u003e\n  \u003c/feature\u003e\n\u003c/features\u003e\n----\n\n=== Karaf 4 Support\n\n\nKaraf 4 features xsd v1.3.0 partially supported\n[source,groovy]\n----\n\u003cfeature version=\"1.2.3\" dependency=\"true\"\u003edependent-feature\u003c/feature\u003e\n----\n\nTo generate this stuff\n\n1. Set xsdVersion to 1.3.0\n2. Use dependency with configuration closure\n\n[source,groovy]\n----\nkaraf {\n  features {\n    xsdVersion = '1.3.0'\n    name = \"${project.name}-${version}\"\n    outputFile = file(\"${project.buildDir}/karaf/features/${project.name}-feature.xml\")\n    mainFeature {\n      name = 'main-feature-name'\n      feature('dependent-feature') {\n        dependency = true              //false by default\n        version = \"1.2.3\"              //empty by default\n      }\n    }\n  }\n}\n----\n\ngenerated file `build/karaf/features/project1-feature.xml` will look like below\n\n[source,groovy]\n----\n\n\u003cfeatures xmlns='http://karaf.apache.org/xmlns/features/v1.3.0' name='featuresName'\u003e\n  \u003cfeature name='main-feature-name' version='1.0.0'\u003e\n    \u003cfeature version=\"1.2.3\" dependency=\"true\"\u003edependent-feature\u003c/feature\u003e\n  \u003c/feature\u003e\n\u003c/features\u003e\n\n----\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flburgazzoli%2Fgradle-karaf-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flburgazzoli%2Fgradle-karaf-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flburgazzoli%2Fgradle-karaf-plugin/lists"}