diff --git a/tycho-its/projects/p2extra/publisherNoUnpack/features/test_feature_1.0.0.202402290953.jar b/tycho-its/projects/p2extra/publisherNoUnpack/features/test_feature_1.0.0.202402290953.jar new file mode 100644 index 0000000000..8c49c7a0ee Binary files /dev/null and b/tycho-its/projects/p2extra/publisherNoUnpack/features/test_feature_1.0.0.202402290953.jar differ diff --git a/tycho-its/projects/p2extra/publisherNoUnpack/plugins/test_plugin_1.0.0.202402290953.jar b/tycho-its/projects/p2extra/publisherNoUnpack/plugins/test_plugin_1.0.0.202402290953.jar new file mode 100644 index 0000000000..bed60b0cb3 Binary files /dev/null and b/tycho-its/projects/p2extra/publisherNoUnpack/plugins/test_plugin_1.0.0.202402290953.jar differ diff --git a/tycho-its/projects/p2extra/publisherNoUnpack/pom.xml b/tycho-its/projects/p2extra/publisherNoUnpack/pom.xml new file mode 100644 index 0000000000..e41dc9575a --- /dev/null +++ b/tycho-its/projects/p2extra/publisherNoUnpack/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + tycho-its-project.p2extra.publisherNoUnpack + parent + 1.0.0-SNAPSHOT + pom + + + + + + org.eclipse.tycho.extras + tycho-p2-extras-plugin + ${tycho-version} + + + prepare-package + + publish-features-and-bundles + + + + + . + target/repository + target/repository + true + false + + + + + + \ No newline at end of file diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/P2ExtrasPlugin.java b/tycho-its/src/test/java/org/eclipse/tycho/test/P2ExtrasPlugin.java index d4d53770a5..b83d4de6fa 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/P2ExtrasPlugin.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/P2ExtrasPlugin.java @@ -12,14 +12,25 @@ *******************************************************************************/ package org.eclipse.tycho.test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.File; +import java.io.IOException; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.apache.maven.it.VerificationException; import org.apache.maven.it.Verifier; import org.junit.Test; +import de.pdark.decentxml.Document; +import de.pdark.decentxml.Element; +import de.pdark.decentxml.XMLIOSource; +import de.pdark.decentxml.XMLParser; + public class P2ExtrasPlugin extends AbstractTychoIntegrationTest { @Test @@ -129,4 +140,38 @@ private void execute(Verifier verifier, boolean success, String project, String } } + @Test + public void testPublishFeaturesAndBundles_noUnpack() throws Exception { + final String pluginId = "test_plugin"; + final String featureId = "test_feature.feature.jar"; + + Verifier verifier = getVerifier("p2extra/publisherNoUnpack", false, true); + verifier.executeGoals(List.of("clean", "package")); + + Path contentXml = Path.of(verifier.getBasedir()).resolve("target/repository").resolve("content.xml"); + Element pluginUnitInContentXml = extractUnitFromContentXml(contentXml, pluginId); + assertFalse("test plugin should not be marked as zipped", hasChildWithZippedAttribute(pluginUnitInContentXml)); + Element featureUnitInContentXml = extractUnitFromContentXml(contentXml, featureId); + assertTrue("test feature should be marked as zipped", hasChildWithZippedAttribute(featureUnitInContentXml)); + } + + private static Element extractUnitFromContentXml(Path contentXml, String unitName) throws IOException { + XMLParser parser = new XMLParser(); + Document document = parser.parse(new XMLIOSource(contentXml.toFile())); + Element unitElement = document.getChild("repository/units"); + List units = unitElement.getChildren("unit"); + Optional extractedUnit = units.stream() + .filter(element -> unitName.equals(element.getAttribute("id").getValue())).findFirst(); + assertTrue(String.format("Unit with name '%s' not found in content.xml with units: %s", unitName, units), + extractedUnit.isPresent()); + return extractedUnit.get(); + } + + private static boolean hasChildWithZippedAttribute(Element element) { + if ("zipped".equals(element.getAttributeValue("key"))) { + return true; + } + return element.getChildren().stream().anyMatch(P2ExtrasPlugin::hasChildWithZippedAttribute); + } + }