summaryrefslogtreecommitdiffstats
path: root/bundle-plugin-test
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2019-10-20 19:09:07 +0200
committergjoranv <gv@verizonmedia.com>2019-10-23 17:06:02 +0200
commit15f690295f559730a37fab0bbdd00473f8d466a4 (patch)
tree9d43ca2f2b0144e860f977b1911c29fff0d6c06f /bundle-plugin-test
parent43383af739e522ef69cc7fd1b0b0115e454e8e4f (diff)
Add test with a bundle using artifact version as ExportPackages
- Verify that useArtifactVersionForExportPackages is honoured also for a compile scoped bundle dependency.
Diffstat (limited to 'bundle-plugin-test')
-rw-r--r--bundle-plugin-test/integration-test/pom.xml23
-rw-r--r--bundle-plugin-test/integration-test/src/test/java/com/yahoo/BundleIT.java18
-rw-r--r--bundle-plugin-test/integration-test/src/test/java/com/yahoo/ExportPackageVersionIT.java68
-rw-r--r--bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/pom.xml39
-rw-r--r--bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/src/main/java/ai/vespa/explicitversion_dep/package-info.java6
-rw-r--r--bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/src/main/java/ai/vespa/noversion_dep/package-info.java5
-rw-r--r--bundle-plugin-test/test-bundles/artifact-version-for-exports/pom.xml36
-rw-r--r--bundle-plugin-test/test-bundles/artifact-version-for-exports/src/main/java/ai/vespa/explicitversion/package-info.java6
-rw-r--r--bundle-plugin-test/test-bundles/artifact-version-for-exports/src/main/java/ai/vespa/noversion/package-info.java5
-rw-r--r--bundle-plugin-test/test-bundles/main/pom.xml8
-rw-r--r--bundle-plugin-test/test-bundles/pom.xml17
11 files changed, 205 insertions, 26 deletions
diff --git a/bundle-plugin-test/integration-test/pom.xml b/bundle-plugin-test/integration-test/pom.xml
index 62204f23999..642d74fb0e9 100644
--- a/bundle-plugin-test/integration-test/pom.xml
+++ b/bundle-plugin-test/integration-test/pom.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<!-- Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
<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
@@ -17,11 +17,6 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>config</artifactId>
<version>${project.version}</version>
@@ -33,6 +28,16 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>com.yahoo.vespa.bundle-plugin</groupId>
@@ -40,6 +45,12 @@
<classifier>bundle</classifier>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa.bundle-plugin</groupId>
+ <artifactId>artifact-version-for-exports</artifactId>
+ <classifier>bundle</classifier>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/BundleIT.java b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/BundleIT.java
index 2ed1d7f0bc6..5e76b08ab9f 100644
--- a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/BundleIT.java
+++ b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/BundleIT.java
@@ -9,10 +9,10 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Collection;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
@@ -54,19 +54,13 @@ public class BundleIT {
}
}
- private File findBundleJar(String bundleName) {
- File[] componentFile = new File(TEST_BUNDLE_PATH).listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File file, String fileName) {
- return fileName.endsWith("-bundle.jar");
- }
- });
-
- if (componentFile.length != 1) {
- throw new RuntimeException("Failed finding component jar file");
+ static File findBundleJar(String bundleName) {
+ Path bundlePath = Paths.get(TEST_BUNDLE_PATH, bundleName + "-bundle.jar");
+ if (! Files.exists(bundlePath)) {
+ throw new RuntimeException("Failed finding component jar file: " + bundlePath);
}
- return componentFile[0];
+ return bundlePath.toFile();
}
@Test
diff --git a/bundle-plugin-test/integration-test/src/test/java/com/yahoo/ExportPackageVersionIT.java b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/ExportPackageVersionIT.java
new file mode 100644
index 00000000000..e2cee71ca9e
--- /dev/null
+++ b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/ExportPackageVersionIT.java
@@ -0,0 +1,68 @@
+// Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+
+import static com.yahoo.BundleIT.findBundleJar;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Verifies that the 'useArtifactVersionForExportPackages' setting for the bundle-plugin works as intended.
+ *
+ * @author gjoranv
+ */
+public class ExportPackageVersionIT {
+
+ private static Attributes mainAttributes;
+
+ @BeforeClass
+ public static void setup() {
+ try {
+ File componentJar = findBundleJar("artifact-version-for-exports");
+ mainAttributes = new JarFile(componentJar).getManifest().getMainAttributes();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Test
+ public void artifact_version_without_qualifier_is_used_as_export_version() {
+ // Bundle-Version is artifact version without qualifier
+ String bundleVersion = mainAttributes.getValue("Bundle-Version");
+ String expectedExport = "ai.vespa.noversion;version=" + bundleVersion;
+
+ String exportPackage = mainAttributes.getValue("Export-Package");
+ assertThat(exportPackage, containsString(expectedExport));
+
+ // Verify that there is no qualifier
+ assertThat(exportPackage, not(containsString(expectedExport + ".")));
+ }
+
+ @Test
+ public void explicit_version_in_ExportPackage_annotation_overrides_artifact_version() {
+ String exportPackage = mainAttributes.getValue("Export-Package");
+ assertThat(exportPackage, containsString("ai.vespa.explicitversion;version=2.4.6.RELEASE"));
+ }
+
+ @Test
+ public void artifact_version_of_dependency_is_used_as_export_version_for_package_in_compile_scoped_dependency() {
+ String exportPackage = mainAttributes.getValue("Export-Package");
+ // Verify against the artifact version from the test bundle's pom.
+ assertThat(exportPackage, containsString("ai.vespa.noversion_dep;version=3.2.1"));
+ }
+
+ @Test
+ public void explicit_version_in_ExportPackage_annotation_overrides_artifact_version_of_compile_scoped_dependency() {
+ String exportPackage = mainAttributes.getValue("Export-Package");
+ assertThat(exportPackage, containsString("ai.vespa.explicitversion_dep;version=3.6.9.RELEASE"));
+ }
+
+}
diff --git a/bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/pom.xml b/bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/pom.xml
new file mode 100644
index 00000000000..e958618472b
--- /dev/null
+++ b/bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!-- Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<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>
+ <parent>
+ <groupId>com.yahoo.vespa.bundle-plugin</groupId>
+ <artifactId>test-bundles</artifactId>
+ <version>7-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>artifact-version-for-exports-dep</artifactId>
+ <version>3.2.1</version>
+ <packaging>container-plugin</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>container-dev</artifactId>
+ <version>${project.parent.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>bundle-plugin</artifactId>
+ <version>${project.parent.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <useArtifactVersionForExportPackages>true</useArtifactVersionForExportPackages>
+ <configGenVersion>${project.parent.version}</configGenVersion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/src/main/java/ai/vespa/explicitversion_dep/package-info.java b/bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/src/main/java/ai/vespa/explicitversion_dep/package-info.java
new file mode 100644
index 00000000000..3eea8b11f1e
--- /dev/null
+++ b/bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/src/main/java/ai/vespa/explicitversion_dep/package-info.java
@@ -0,0 +1,6 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+@ExportPackage(version = @Version(major = 3, minor = 6, micro = 9, qualifier = "RELEASE"))
+package ai.vespa.explicitversion_dep;
+
+import com.yahoo.osgi.annotation.ExportPackage;
+import com.yahoo.osgi.annotation.Version;
diff --git a/bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/src/main/java/ai/vespa/noversion_dep/package-info.java b/bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/src/main/java/ai/vespa/noversion_dep/package-info.java
new file mode 100644
index 00000000000..794e177f7e7
--- /dev/null
+++ b/bundle-plugin-test/test-bundles/artifact-version-for-exports-dep/src/main/java/ai/vespa/noversion_dep/package-info.java
@@ -0,0 +1,5 @@
+// Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+@ExportPackage
+package ai.vespa.noversion_dep;
+
+import com.yahoo.osgi.annotation.ExportPackage;
diff --git a/bundle-plugin-test/test-bundles/artifact-version-for-exports/pom.xml b/bundle-plugin-test/test-bundles/artifact-version-for-exports/pom.xml
new file mode 100644
index 00000000000..ac7263c8846
--- /dev/null
+++ b/bundle-plugin-test/test-bundles/artifact-version-for-exports/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!-- Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<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>
+ <parent>
+ <groupId>com.yahoo.vespa.bundle-plugin</groupId>
+ <artifactId>test-bundles</artifactId>
+ <version>7-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>artifact-version-for-exports</artifactId>
+ <version>7-SNAPSHOT</version>
+ <packaging>container-plugin</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>com.yahoo.vespa.bundle-plugin</groupId>
+ <artifactId>artifact-version-for-exports-dep</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <useArtifactVersionForExportPackages>true</useArtifactVersionForExportPackages>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/bundle-plugin-test/test-bundles/artifact-version-for-exports/src/main/java/ai/vespa/explicitversion/package-info.java b/bundle-plugin-test/test-bundles/artifact-version-for-exports/src/main/java/ai/vespa/explicitversion/package-info.java
new file mode 100644
index 00000000000..96cf6a3bf85
--- /dev/null
+++ b/bundle-plugin-test/test-bundles/artifact-version-for-exports/src/main/java/ai/vespa/explicitversion/package-info.java
@@ -0,0 +1,6 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+@ExportPackage(version = @Version(major = 2, minor = 4, micro = 6, qualifier = "RELEASE"))
+package ai.vespa.explicitversion;
+
+import com.yahoo.osgi.annotation.ExportPackage;
+import com.yahoo.osgi.annotation.Version;
diff --git a/bundle-plugin-test/test-bundles/artifact-version-for-exports/src/main/java/ai/vespa/noversion/package-info.java b/bundle-plugin-test/test-bundles/artifact-version-for-exports/src/main/java/ai/vespa/noversion/package-info.java
new file mode 100644
index 00000000000..e7e11e39889
--- /dev/null
+++ b/bundle-plugin-test/test-bundles/artifact-version-for-exports/src/main/java/ai/vespa/noversion/package-info.java
@@ -0,0 +1,5 @@
+// Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+@ExportPackage
+package ai.vespa.noversion;
+
+import com.yahoo.osgi.annotation.ExportPackage;
diff --git a/bundle-plugin-test/test-bundles/main/pom.xml b/bundle-plugin-test/test-bundles/main/pom.xml
index 1c02a516fe8..90d575c2a0b 100644
--- a/bundle-plugin-test/test-bundles/main/pom.xml
+++ b/bundle-plugin-test/test-bundles/main/pom.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<!-- Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
<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
@@ -16,12 +16,6 @@
<packaging>container-plugin</packaging>
<dependencies>
<dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>container-dev</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<scope>provided</scope>
diff --git a/bundle-plugin-test/test-bundles/pom.xml b/bundle-plugin-test/test-bundles/pom.xml
index 680f43ba057..b18c0b9ba3f 100644
--- a/bundle-plugin-test/test-bundles/pom.xml
+++ b/bundle-plugin-test/test-bundles/pom.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<!-- Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
<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
@@ -43,6 +43,21 @@
</plugins>
</build>
<modules>
+ <module>artifact-version-for-exports</module>
+ <module>artifact-version-for-exports-dep</module>
<module>main</module>
</modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>container-dev</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <maven.javadoc.skip>true</maven.javadoc.skip>
+ </properties>
</project>