Commit Diff


commit - ced37db3167e5a43b6ef7d2b84d92275ea17644f
commit + 5c3daa72fa0c94e4e03bd3e50cd47955704e0146
blob - d1f90ab65887edd20f8b150d9c5a2f9e81476c81
blob + 2b5b9d787fbf21335345f0c4b5816c11888b1a76
--- gradle/karaf.gradle
+++ gradle/karaf.gradle
@@ -28,6 +28,7 @@ static String depToMavenPath(Provider<MinimalExternalM
 }
 
 apply plugin: com.github.lburgazzoli.gradle.plugin.karaf.KarafPlugin
+import groovy.xml.MarkupBuilder
 
 configurations {
   bundles
@@ -79,21 +80,84 @@ karaf {
 }
 
 tasks.register('generateOfflineRepo') {
+  group = 'karaf'
+  description = 'Generate Karaf Repo Directory using karaf maven tooling features-add-to-repository'
   dependsOn generateRepo
   outputs.dir(layout.buildDirectory.dir('karaf/repo-offline'))
   doLast {
+    def mavenDependencyPlugin = libs.maven.dependency.plugin.get()
+    def karafMavenPlugin = libs.apache.karaf.maven.plugin.get()
+    def pomFile = layout.buildDirectory.dir('karaf/maven').get().file('pom.xml').asFile
+    def pomFileParent = pomFile.getParentFile()
+    def writer = new StringWriter()
+    def xml = new MarkupBuilder(writer)
+    xml.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') {
+      modelVersion('4.0.0')
+      groupId(project.group)
+      artifactId(project.name)
+      xml.version(project.version)
+      packaging('pom')
+      xml.repositories {
+        repository {
+          id("local-repo")
+          url("file:${tasks.generateRepo.outputs.files.singleFile.path}")
+        }
+      }
+      xml.build {
+        xml.plugins {
+          plugin {
+            groupId(mavenDependencyPlugin.group)
+            artifactId(mavenDependencyPlugin.name)
+            xml.version(mavenDependencyPlugin.version)
+            executions {
+              execution {
+                phase("clean")
+                goals {
+                  goal("purge-local-repository")
+                }
+                configuration {
+                  resolutionFuzziness("groupId")
+                  manualIncludes {
+                    manualInclude(project.group)
+                  }
+                }
+              }
+            }
+          }
+          plugin {
+            groupId(karafMavenPlugin.group)
+            artifactId(karafMavenPlugin.name)
+            xml.version(karafMavenPlugin.version)
+            executions {
+              execution {
+                goals {
+                  goal("features-add-to-repository")
+                }
+                configuration {
+                  descriptors {
+                    descriptor(depToMavenPath(libs.apache.karaf.feature.standard, "xml/features"))
+                    descriptor(tasks.generateFeatures.outputs.files.singleFile.path)
+                  }
+                  features {
+                    project.extensions.findByName('karaf').features.each {
+                      feature(it.name)
+                    }
+                  }
+                  repository(outputs.files.singleFile)
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+    pomFileParent.mkdirs()
+    pomFile.text = writer.toString()
     mavenexec {
+      workingDir pomFileParent
       goals 'clean', 'install'
-      define([
-        'groupId'            : project.group,
-        'artifactId'         : project.name,
-        'version'            : project.version,
-        'karafVersion'       : libs.versions.apache.karaf.get(),
-        'url'                : tasks.generateRepo.outputs.files.singleFile.path,
-        'descriptor'         : tasks.generateFeatures.outputs.files.singleFile.path,
-        'feature'            : project.name,
-        'repository'         : outputs.files.singleFile.path
-      ])
       quiet true
     }
   }
blob - 7c13544c0a2a0783ed45af1244647d0acec851f5
blob + 6b5f71c2c9d0fb8e2a4a4727595407d0e400d0f5
--- gradle/libs.versions.toml
+++ gradle/libs.versions.toml
@@ -67,6 +67,7 @@ jsr305 = '3.0.2'
 junit-jupiter = '5.11.4'
 keycloak = '18.0.2'
 lombok = '1.18.36'
+maven-dependency-plugin = '3.8.1'
 maven-exec = '4.0.0'
 okhttp3 = '4.12.0'
 osgi-annotation = '2.0.0'
@@ -105,7 +106,9 @@ apache-karaf-feature-camel = { module = 'org.apache.ca
 apache-karaf-feature-cxf = { module = 'org.apache.cxf.karaf:apache-cxf', version.ref = 'cxf' }
 apache-karaf-feature-keycloak = { module = 'org.keycloak:keycloak-osgi-features', version.ref = 'keycloak' }
 apache-karaf-feature-hawtio = { module = 'io.hawt:hawtio-karaf', version.ref = 'hawtio' }
+apache-karaf-feature-standard = { module = 'org.apache.karaf.features:standard', version.ref = 'apache-karaf' }
 apache-karaf-jaas-config = { module = 'org.apache.karaf.jaas:org.apache.karaf.jaas.config', version.ref = 'apache-karaf' }
+apache-karaf-maven-plugin = { module = 'org.apache.karaf.tooling:karaf-maven-plugin', version.ref = 'apache-karaf' }
 apache-karaf-shell-core = { module = 'org.apache.karaf.shell:org.apache.karaf.shell.core', version.ref = 'apache-karaf' }
 apache-karaf-webconsole-console = { module = 'org.apache.karaf.webconsole:org.apache.karaf.webconsole.console', version.ref = 'apache-karaf' }
 camel-core = { module = 'org.apache.camel:camel-core', version.ref = 'camel' }
@@ -152,6 +155,7 @@ jsr305 = { module = 'com.google.code.findbugs:jsr305',
 junit-jupiter-api = { module = 'org.junit.jupiter:junit-jupiter-api', version.ref = 'junit-jupiter' }
 junit-jupiter-engine = { module = 'org.junit.jupiter:junit-jupiter-engine', version.ref = 'junit-jupiter' }
 logging-interceptor = { module = 'com.squareup.okhttp3:logging-interceptor', version.ref = 'okhttp3' }
+maven-dependency-plugin = { module = 'org.apache.maven.plugins:maven-dependency-plugin', version.ref = 'maven-dependency-plugin' }
 maven-exec = { module = 'com.github.dkorotych.gradle-maven-exec:com.github.dkorotych.gradle-maven-exec.gradle.plugin', version.ref = 'maven-exec' }
 pax-exam = { module = 'org.ops4j.pax.exam:pax-exam', version.ref = 'pax-exam' }
 pax-exam-container-karaf = { module = 'org.ops4j.pax.exam:pax-exam-container-karaf', version.ref = 'pax-exam' }
blob - 02b73c8ee0fed4047e132896b058b47ba4383b1b (mode 644)
blob + /dev/null
--- pom.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
-  Copyright (C) 2024 by Chaz Kettleson <chaz@pyr3x.com>
-
-  Permission to use, copy, modify, and/or distribute this software for any
-  purpose with or without fee is hereby granted.
-
-  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
--->
-
-<!-- Karaf Features POM -->
-
-<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">
-
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>${groupId}</groupId>
-  <artifactId>${artifactId}</artifactId>
-  <version>${version}</version>
-  <packaging>pom</packaging>
-
-  <repositories>
-    <repository>
-      <id>local-repo</id>
-      <url>file:${url}</url>
-    </repository>
-  </repositories>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-plugin</artifactId>
-        <version>3.8.1</version>
-        <executions>
-          <execution>
-            <phase>clean</phase>
-            <goals>
-              <goal>purge-local-repository</goal>
-            </goals>
-            <configuration>
-              <resolutionFuzziness>groupId</resolutionFuzziness>
-              <manualIncludes>
-                <manualInclude>${groupId}</manualInclude>
-              </manualIncludes>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.karaf.tooling</groupId>
-        <artifactId>karaf-maven-plugin</artifactId>
-        <version>${karafVersion}</version>
-        <executions>
-          <execution>
-            <goals>
-              <goal>features-add-to-repository</goal>
-            </goals>
-            <configuration>
-              <descriptors>
-                <descriptor>mvn:org.apache.karaf.features/standard/${karafVersion}/xml/features</descriptor>
-                <descriptor>${descriptor}</descriptor>
-              </descriptors>
-              <features>
-                <feature>${feature}</feature>
-              </features>
-              <repository>${repository}</repository>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>