This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch karaf-4.4.x
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.4.x by this push:
new 62d6662db5 [karaf-4.4.x] Download test artifacts instead of copy in
the source (source distribution) (#2270)
62d6662db5 is described below
commit 62d6662db52edc7db899240a5edc8edd0fc71b23
Author: JB Onofré <[email protected]>
AuthorDate: Mon Feb 9 10:48:09 2026 +0100
[karaf-4.4.x] Download test artifacts instead of copy in the source (source
distribution) (#2270)
* Download test artifacts instead of copy in the source (source
distribution)
* Generate the kar deployer test artifacts
* Remove tanukisoft wrapper jar and resolve by Maven
---
.../deployer/kar/KarArtifactInstallerTest.java | 101 ++++++++++++++++++++-
deployer/kar/src/test/resources/badZipFile.zip | 1 -
deployer/kar/src/test/resources/goodKarFile.kar | Bin 1057 -> 0 bytes
.../test/resources/goodKarFile/org/bar/hello.txt | 16 ++++
deployer/kar/src/test/resources/karFileAsZip.zip | Bin 1037 -> 0 bytes
.../test/resources/karFileAsZip/META-INF/KARAF.MF | 16 ++++
.../test/resources/karFileAsZip/org/bar/hello.txt | 16 ++++
.../src/test/resources/karFileAsZipNoManifest.zip | Bin 777 -> 0 bytes
.../karFileAsZipNoManifest/org/bar/hello.txt | 16 ++++
main/pom.xml | 63 +++++++++++--
main/src/test/resources/foo | 16 ++++
.../1.0.0/org.apache.aries.blueprint.api-1.0.0.jar | Bin 33272 -> 0 bytes
.../5.6.10/org.apache.felix.framework-5.6.10.jar | Bin 692174 -> 0 bytes
.../test-karaf-home/system/pax-url-mvn.jar | Bin 112281 -> 0 bytes
wrapper/pom.xml | 25 +++++
.../karaf/wrapper/internal/all/karaf-wrapper.jar | Bin 83820 -> 0 bytes
16 files changed, 261 insertions(+), 9 deletions(-)
diff --git
a/deployer/kar/src/test/java/org/apache/karaf/deployer/kar/KarArtifactInstallerTest.java
b/deployer/kar/src/test/java/org/apache/karaf/deployer/kar/KarArtifactInstallerTest.java
index 1ef4190946..8c3a2a6b3e 100644
---
a/deployer/kar/src/test/java/org/apache/karaf/deployer/kar/KarArtifactInstallerTest.java
+++
b/deployer/kar/src/test/java/org/apache/karaf/deployer/kar/KarArtifactInstallerTest.java
@@ -23,9 +23,22 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
+import java.net.URL;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collections;
import java.util.List;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
import org.apache.karaf.kar.KarService;
import org.junit.Before;
@@ -39,16 +52,100 @@ public class KarArtifactInstallerTest {
private URI zipFileWithKarafManifest;
private URI zipFileWithoutKarafManifest;
private URI badZipFile;
-
+
+ private void createTestFiles() throws Exception {
+ // create goodKarFile.kar
+ File karFile = new File("target/test-classes/goodKarFile.kar");
+ karFile.getParentFile().mkdirs();
+
+ URL karFileResource =
getClass().getClassLoader().getResource("goodKarFile");
+ File karFileSourceDir = new File(karFileResource.toURI());
+ createJarFromFolder(karFileSourceDir.toPath(), karFile);
+
+ goodKarFile = karFile.toURI();
+
+ // create karFileAsZip.zip
+ File zipFile = new File("target/test-classes/karFileAsZip.zip");
+ zipFile.getParentFile().mkdirs();
+
+ URL karFileAsZipResource =
getClass().getClassLoader().getResource("karFileAsZip");
+ File karFileAsZipSourceDir = new
File(karFileAsZipResource.toURI());
+ createZipFromFolder(karFileAsZipSourceDir.toPath(), zipFile);
+
+ zipFileWithKarafManifest = zipFile.toURI();
+
+ // create karFileAsZipNoManifest.zip
+ File zipFileWithoutKarafManifestFile = new
File("target/test-classes/karFileAsZipNoManifest.zip");
+ zipFileWithoutKarafManifestFile.getParentFile().mkdirs();
+
+ URL karFileAsZipNoManifestResource =
getClass().getClassLoader().getResource("karFileAsZipNoManifest");
+ File karFileAsZipNoManifestSourceDir = new
File(karFileAsZipNoManifestResource.toURI());
+ createZipFromFolder(karFileAsZipNoManifestSourceDir.toPath(),
zipFileWithoutKarafManifestFile);
+
+ zipFileWithoutKarafManifest =
zipFileWithoutKarafManifestFile.toURI();
+
+ // create badZipFile.zip
+ File badZipFileFile = new
File("target/test-classes/badZipFile.zip");
+
+ try (FileOutputStream fos = new
FileOutputStream(badZipFileFile)) {
+ fos.write("Not a valid zip file".getBytes());
+ }
+
+ badZipFile = badZipFileFile.toURI();
+ }
+
+ private void createJarFromFolder(Path sourceDir, File jarFile) throws
Exception {
+ try (JarOutputStream jos = new JarOutputStream(new
FileOutputStream(jarFile))) {
+ Files.walkFileTree(sourceDir, new
SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile(Path file,
BasicFileAttributes attrs) throws IOException {
+ String entryName =
sourceDir.relativize(file).toString().replace(File.separator, "/");
+ jos.putNextEntry(new
ZipEntry(entryName));
+ try (InputStream in = new
FileInputStream(file.toFile())) {
+ byte[] buf = new byte[4096];
+ int len;
+ while ((len = in.read(buf)) >
0) {
+ jos.write(buf, 0, len);
+ }
+ }
+ jos.closeEntry();
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ }
+ }
+
+ private void createZipFromFolder(Path sourceDir, File zipFile) throws
Exception {
+ try (ZipOutputStream zos = new ZipOutputStream(new
FileOutputStream(zipFile))) {
+ Files.walkFileTree(sourceDir, new
SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile(Path file,
BasicFileAttributes attrs) throws IOException {
+ String entryName =
sourceDir.relativize(file).toString().replace(File.separator, "/");
+ zos.putNextEntry(new
ZipEntry(entryName));
+ try (InputStream in = new
FileInputStream(file.toFile())) {
+ byte[] buf = new byte[4096];
+ int len;
+ while ((len = in.read(buf)) >
0) {
+ zos.write(buf, 0, len);
+ }
+ }
+ zos.closeEntry();
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ }
+ }
+
@Before
public void setUp() throws Exception {
+ createTestFiles();
+
karService = createMock(KarService.class);
karArtifactInstaller = new KarArtifactInstaller();
karArtifactInstaller.setKarService(karService);
- goodKarFile =
getClass().getClassLoader().getResource("goodKarFile.kar").toURI();
zipFileWithKarafManifest =
getClass().getClassLoader().getResource("karFileAsZip.zip").toURI();
zipFileWithoutKarafManifest =
getClass().getClassLoader().getResource("karFileAsZipNoManifest.zip").toURI();
badZipFile =
getClass().getClassLoader().getResource("badZipFile.zip").toURI();
diff --git a/deployer/kar/src/test/resources/badZipFile.zip
b/deployer/kar/src/test/resources/badZipFile.zip
deleted file mode 100644
index b158994d41..0000000000
--- a/deployer/kar/src/test/resources/badZipFile.zip
+++ /dev/null
@@ -1 +0,0 @@
-This is *not* a well formed .kar file :(
\ No newline at end of file
diff --git a/deployer/kar/src/test/resources/goodKarFile.kar
b/deployer/kar/src/test/resources/goodKarFile.kar
deleted file mode 100644
index 18abf7db60..0000000000
Binary files a/deployer/kar/src/test/resources/goodKarFile.kar and /dev/null
differ
diff --git a/deployer/kar/src/test/resources/goodKarFile/org/bar/hello.txt
b/deployer/kar/src/test/resources/goodKarFile/org/bar/hello.txt
new file mode 100644
index 0000000000..52db93c6cd
--- /dev/null
+++ b/deployer/kar/src/test/resources/goodKarFile/org/bar/hello.txt
@@ -0,0 +1,16 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
\ No newline at end of file
diff --git a/deployer/kar/src/test/resources/karFileAsZip.zip
b/deployer/kar/src/test/resources/karFileAsZip.zip
deleted file mode 100644
index af29c3be13..0000000000
Binary files a/deployer/kar/src/test/resources/karFileAsZip.zip and /dev/null
differ
diff --git a/deployer/kar/src/test/resources/karFileAsZip/META-INF/KARAF.MF
b/deployer/kar/src/test/resources/karFileAsZip/META-INF/KARAF.MF
new file mode 100644
index 0000000000..52db93c6cd
--- /dev/null
+++ b/deployer/kar/src/test/resources/karFileAsZip/META-INF/KARAF.MF
@@ -0,0 +1,16 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
\ No newline at end of file
diff --git a/deployer/kar/src/test/resources/karFileAsZip/org/bar/hello.txt
b/deployer/kar/src/test/resources/karFileAsZip/org/bar/hello.txt
new file mode 100644
index 0000000000..52db93c6cd
--- /dev/null
+++ b/deployer/kar/src/test/resources/karFileAsZip/org/bar/hello.txt
@@ -0,0 +1,16 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
\ No newline at end of file
diff --git a/deployer/kar/src/test/resources/karFileAsZipNoManifest.zip
b/deployer/kar/src/test/resources/karFileAsZipNoManifest.zip
deleted file mode 100644
index d4ced05438..0000000000
Binary files a/deployer/kar/src/test/resources/karFileAsZipNoManifest.zip and
/dev/null differ
diff --git
a/deployer/kar/src/test/resources/karFileAsZipNoManifest/org/bar/hello.txt
b/deployer/kar/src/test/resources/karFileAsZipNoManifest/org/bar/hello.txt
new file mode 100644
index 0000000000..52db93c6cd
--- /dev/null
+++ b/deployer/kar/src/test/resources/karFileAsZipNoManifest/org/bar/hello.txt
@@ -0,0 +1,16 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
\ No newline at end of file
diff --git a/main/pom.xml b/main/pom.xml
index 8ef04f2554..62840e014c 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -57,12 +57,6 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.framework</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.ops4j.pax.tinybundles</groupId>
- <artifactId>tinybundles</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.karaf</groupId>
<artifactId>org.apache.karaf.util</artifactId>
@@ -75,6 +69,26 @@
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.tinybundles</groupId>
+ <artifactId>tinybundles</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>5.6.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.api</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- karaf framework 1.0.0 features xml -->
+ <!-- pax-url-mvn.jar -->
</dependencies>
<build>
@@ -88,6 +102,43 @@
</resource>
</resources>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.aries.blueprint</groupId>
+
<artifactId>org.apache.aries.blueprint.api</artifactId>
+ <version>1.0.0</version>
+
<outputDirectory>${project.build.testOutputDirectory}/test-karaf-home/system/org/apache/aries/blueprint/org.apache.aries.blueprint.api/1.0.0</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-mvn</artifactId>
+ <version>1.3.7</version>
+
<outputDirectory>${project.build.testOutputDirectory}/test-karaf-home/system/</outputDirectory>
+ <destFileName>pax-url-mvn.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>5.6.10</version>
+
<outputDirectory>${project.build.testOutputDirectory}/test-karaf-home/system/org/apache/felix/org.apache.felix.framework/5.6.10</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
diff --git a/main/src/test/resources/foo b/main/src/test/resources/foo
index e69de29bb2..52db93c6cd 100644
--- a/main/src/test/resources/foo
+++ b/main/src/test/resources/foo
@@ -0,0 +1,16 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
\ No newline at end of file
diff --git
a/main/src/test/resources/test-karaf-home/system/org/apache/aries/blueprint/org.apache.aries.blueprint.api/1.0.0/org.apache.aries.blueprint.api-1.0.0.jar
b/main/src/test/resources/test-karaf-home/system/org/apache/aries/blueprint/org.apache.aries.blueprint.api/1.0.0/org.apache.aries.blueprint.api-1.0.0.jar
deleted file mode 100644
index 43abe2461a..0000000000
Binary files
a/main/src/test/resources/test-karaf-home/system/org/apache/aries/blueprint/org.apache.aries.blueprint.api/1.0.0/org.apache.aries.blueprint.api-1.0.0.jar
and /dev/null differ
diff --git
a/main/src/test/resources/test-karaf-home/system/org/apache/felix/org.apache.felix.framework/5.6.10/org.apache.felix.framework-5.6.10.jar
b/main/src/test/resources/test-karaf-home/system/org/apache/felix/org.apache.felix.framework/5.6.10/org.apache.felix.framework-5.6.10.jar
deleted file mode 100644
index 71dbbefb80..0000000000
Binary files
a/main/src/test/resources/test-karaf-home/system/org/apache/felix/org.apache.felix.framework/5.6.10/org.apache.felix.framework-5.6.10.jar
and /dev/null differ
diff --git a/main/src/test/resources/test-karaf-home/system/pax-url-mvn.jar
b/main/src/test/resources/test-karaf-home/system/pax-url-mvn.jar
deleted file mode 100755
index 54d77bdc88..0000000000
Binary files a/main/src/test/resources/test-karaf-home/system/pax-url-mvn.jar
and /dev/null differ
diff --git a/wrapper/pom.xml b/wrapper/pom.xml
index 84981ef729..ac0424f28f 100644
--- a/wrapper/pom.xml
+++ b/wrapper/pom.xml
@@ -100,6 +100,30 @@
</resource>
</resources>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-wrapper</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>tanukisoft</groupId>
+ <artifactId>wrapper</artifactId>
+
<outputDirectory>${project.build.directory}/classes/org/apache/karaf/wrapper/internal/all</outputDirectory>
+ <destFileName>karaf-wrapper.jar</destFileName>
+ </artifactItem>
+ </artifactItems>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
@@ -123,6 +147,7 @@
<Private-Package>
org.apache.karaf.wrapper.commands,
org.apache.karaf.wrapper.internal,
+ org.apache.karaf.wrapper.internal.all,
org.apache.karaf.wrapper.internal.osgi,
org.apache.karaf.wrapper.internal.service,
org.apache.karaf.wrapper.management.internal,
diff --git
a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/all/karaf-wrapper.jar
b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/all/karaf-wrapper.jar
deleted file mode 100644
index 4db355bc34..0000000000
Binary files
a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/all/karaf-wrapper.jar
and /dev/null differ