From 34523203fb17845b561784872ef5b66c8f37679c Mon Sep 17 00:00:00 2001 From: gjoranv Date: Sun, 8 May 2022 01:35:29 +0200 Subject: Embed annotations, defaults and vespalog in jdisc_core - Scan the new compile scoped deps for Export-Package. --- jdisc_core/pom.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jdisc_core/pom.xml b/jdisc_core/pom.xml index 928258b5e75..19826c6de75 100644 --- a/jdisc_core/pom.xml +++ b/jdisc_core/pom.xml @@ -66,7 +66,6 @@ com.yahoo.vespa defaults ${project.version} - test com.google.guava @@ -171,7 +170,11 @@ com.yahoo.vespa annotations ${project.version} - provided + + + com.yahoo.vespa + vespalog + ${project.version} @@ -249,7 +252,10 @@ ${project.build.directory}/dependency/slf4j-jdk14.jar ${project.build.directory}/dependency/jcl-over-slf4j.jar ${project.build.directory}/dependency/log4j-over-slf4j.jar + ${project.build.directory}/dependency/annotations.jar ${project.build.directory}/dependency/config-lib.jar + ${project.build.directory}/dependency/defaults.jar + ${project.build.directory}/dependency/vespalog.jar ${project.build.directory}/dependency/yolean.jar ${project.build.directory}/dependency/jaxb-api.jar ${project.build.directory}/dependency/jaxb-core.jar -- cgit v1.2.3 From 260f7bef67c8132c23b4f7dd7c334f45ea25ceed Mon Sep 17 00:00:00 2001 From: gjoranv Date: Thu, 21 Apr 2022 23:11:58 +0200 Subject: Set vespajlib, vespalog and defaults to scope provided. - These artifacts are included on classpath and will be exported via jdisc_core. (vespajlib has actually been embedded in jdisc_core since 2017) --- container-core/pom.xml | 38 ++++++++++++++++++++------------------ container-disc/pom.xml | 8 ++++++++ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/container-core/pom.xml b/container-core/pom.xml index 7b1b6195879..d0d0226e58a 100644 --- a/container-core/pom.xml +++ b/container-core/pom.xml @@ -127,22 +127,6 @@ vdslib ${project.version} - - com.yahoo.vespa - vespajlib - ${project.version} - - - log4j - log4j - - - - - com.yahoo.vespa - vespalog - ${project.version} - org.hdrhistogram HdrHistogram @@ -221,6 +205,12 @@ ${project.version} provided + + com.yahoo.vespa + hosted-zone-api + ${project.version} + provided + com.yahoo.vespa jdisc_core @@ -235,13 +225,25 @@ com.yahoo.vespa - yolean + vespajlib ${project.version} provided + + + log4j + log4j + + com.yahoo.vespa - hosted-zone-api + vespalog + ${project.version} + provided + + + com.yahoo.vespa + yolean ${project.version} provided diff --git a/container-disc/pom.xml b/container-disc/pom.xml index a64349855b1..af901d4d62b 100644 --- a/container-disc/pom.xml +++ b/container-disc/pom.xml @@ -105,15 +105,23 @@ + + com.yahoo.vespa + defaults + ${project.version} + provided + com.yahoo.vespa vespajlib ${project.version} + provided com.yahoo.vespa vespalog ${project.version} + provided com.yahoo.vespa -- cgit v1.2.3 From 94088fe6442c1016e0202e63c800d21733dd7aee Mon Sep 17 00:00:00 2001 From: gjoranv Date: Wed, 4 May 2022 13:54:08 +0200 Subject: Add simple integration test for ExportPackages - Add plugin management for failsafe-plugin --- jdisc_core/pom.xml | 13 +++++++ .../com/yahoo/jdisc/core/ExportPackagesIT.java | 42 ++++++++++++++++++++++ parent/pom.xml | 6 ++++ 3 files changed, 61 insertions(+) create mode 100644 jdisc_core/src/test/java/com/yahoo/jdisc/core/ExportPackagesIT.java diff --git a/jdisc_core/pom.xml b/jdisc_core/pom.xml index 19826c6de75..cf2502c73b8 100644 --- a/jdisc_core/pom.xml +++ b/jdisc_core/pom.xml @@ -283,6 +283,19 @@ + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M6 + + + + integration-test + verify + + + + org.apache.maven.plugins maven-jar-plugin diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ExportPackagesIT.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ExportPackagesIT.java new file mode 100644 index 00000000000..395ddc889ae --- /dev/null +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ExportPackagesIT.java @@ -0,0 +1,42 @@ +package com.yahoo.jdisc.core; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.FileReader; +import java.util.Properties; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * Integration tests for {@link ExportPackages}. + * + * @author gjoranv + */ +public class ExportPackagesIT { + + @Rule + public TemporaryFolder tempFolder= new TemporaryFolder(); + + @Test + public void export_packages_are_added_from_dependency_jars() throws Exception { + File file = tempFolder.newFile(ExportPackages.PROPERTIES_FILE); + + ExportPackages.main(new String[] { file.getAbsolutePath(), "target/dependency/guice-no_aop.jar" }); + assertTrue(file.exists()); + Properties props = new Properties(); + String exportPackages; + try (FileReader reader = new FileReader(file)) { + props.load(reader); + exportPackages = props.getProperty(ExportPackages.EXPORT_PACKAGES); + } + assertNotNull(exportPackages); + + assertTrue(exportPackages.contains("com.google.inject")); + + } + +} diff --git a/parent/pom.xml b/parent/pom.xml index 125bf7bdad9..acd1ed6f25d 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -106,6 +106,11 @@ maven-enforcer-plugin ${maven-enforcer-plugin.version} + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven-failsafe-plugin.version} + org.apache.maven.plugins maven-install-plugin @@ -953,6 +958,7 @@ 3.3.0 2.8.2 3.0.0 + 3.0.0-M6 3.0.0-M1 3.2.0 3.3.1 -- cgit v1.2.3 From 5a3a26acee10bf41a908c1d7d731cd96f764d953 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Fri, 6 May 2022 22:58:36 +0200 Subject: Do not install vespajlib as a bundle in standalone-container. - Exists both on classpath and embedded in container-disc --- standalone-container/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/standalone-container/pom.xml b/standalone-container/pom.xml index a605bdb7d39..25c4b8f801f 100644 --- a/standalone-container/pom.xml +++ b/standalone-container/pom.xml @@ -92,7 +92,6 @@ container-disc-jar-with-dependencies.jar, model-evaluation-jar-with-dependencies.jar, model-integration-jar-with-dependencies.jar, - vespajlib.jar -- cgit v1.2.3 From a51532b7dcf5974be3d61eeaeb873da8b7d70753 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Sun, 8 May 2022 01:20:50 +0200 Subject: Set all deps to provided in vespalog - Must scan vespajlib explicitly for exported packages in jdisc_core, now that it's no longer embedded in vespalog. --- jdisc_core/pom.xml | 1 + vespalog/pom.xml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/jdisc_core/pom.xml b/jdisc_core/pom.xml index cf2502c73b8..1943e2905fa 100644 --- a/jdisc_core/pom.xml +++ b/jdisc_core/pom.xml @@ -255,6 +255,7 @@ ${project.build.directory}/dependency/annotations.jar ${project.build.directory}/dependency/config-lib.jar ${project.build.directory}/dependency/defaults.jar + ${project.build.directory}/dependency/vespajlib.jar ${project.build.directory}/dependency/vespalog.jar ${project.build.directory}/dependency/yolean.jar ${project.build.directory}/dependency/jaxb-api.jar diff --git a/vespalog/pom.xml b/vespalog/pom.xml index aab362e3395..1fa007d6029 100644 --- a/vespalog/pom.xml +++ b/vespalog/pom.xml @@ -22,16 +22,19 @@ org.mockito mockito-core + test com.yahoo.vespa vespajlib ${project.version} + provided com.yahoo.vespa defaults ${project.version} + provided com.yahoo.vespa -- cgit v1.2.3 From d79c95b8b64e052a00f5eb069df14788ca655d26 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Fri, 6 May 2022 20:05:07 +0200 Subject: Allow loading classes from jdisc_core as well as container-disc. - If no bundle is explicitly specified, try container-disc first, then the system bundle (jdisc_core-with-deps) --- .../src/main/java/com/yahoo/osgi/OsgiImpl.java | 34 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java index 4909f9a76eb..761d4057db3 100644 --- a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java +++ b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java @@ -27,6 +27,8 @@ public class OsgiImpl implements Osgi { // The initial bundles are never scheduled for uninstall private final List initialBundles; + private final Bundle systemBundle; + // An initial bundle that is not the framework, and can hence be used to look up current bundles private final Bundle alwaysCurrentBundle; @@ -37,6 +39,7 @@ public class OsgiImpl implements Osgi { if (initialBundles.isEmpty()) throw new IllegalStateException("No initial bundles!"); + systemBundle = getSystemBundle(initialBundles); alwaysCurrentBundle = firstNonFrameworkBundle(initialBundles); if (alwaysCurrentBundle == null) throw new IllegalStateException("The initial bundles only contained the framework bundle!"); @@ -59,19 +62,30 @@ public class OsgiImpl implements Osgi { if (bundle != null) { return resolveFromBundle(spec, bundle); } else { - return resolveFromClassPath(spec); + return resolveFromThisBundleOrSystemBundle(spec); } } + /** + * Tries to resolve the given class from this class' bundle classloader. + * If unsuccessful, resolves the class from . + */ @SuppressWarnings("unchecked") - private static Class resolveFromClassPath(BundleInstantiationSpecification spec) { + private Class resolveFromThisBundleOrSystemBundle(BundleInstantiationSpecification spec) { + log.fine(() -> "Resolving class from container-disc: " + spec.classId.getName()); try { return (Class) Class.forName(spec.classId.getName()); } catch (ClassNotFoundException e) { - throw new IllegalArgumentException("Could not create a component with id '" + spec.classId.getName() + - "'. Tried to load class directly, since no bundle was found for spec: " + spec.bundle + - ". If a bundle with the same name is installed, there is a either a version mismatch" + - " or the installed bundle's version contains a qualifier string."); + log.fine(() -> "Resolving class from the system bundle (jdisc core): " + spec.classId.getName()); + try { + return (Class) systemBundle.loadClass(spec.classId.getName()); + } catch (ClassNotFoundException e2) { + throw new IllegalArgumentException( + "Could not create a component with id '" + spec.classId.getName() + + "'. Tried to load class directly, since no bundle was found for spec: " + spec.bundle + + ". If a bundle with the same name is installed, there is a either a version mismatch" + + " or the installed bundle's version contains a qualifier string."); + } } } @@ -157,6 +171,14 @@ public class OsgiImpl implements Osgi { return jdiscOsgi.isFelixFramework(); } + private static Bundle getSystemBundle(List bundles ) { + for (Bundle b : bundles) { + if (b instanceof Framework) + return b; + } + throw new IllegalStateException("No system bundle in " + bundles); + } + private static Bundle firstNonFrameworkBundle(List bundles) { for (Bundle b : bundles) { if (! (b instanceof Framework)) -- cgit v1.2.3 From 79b1ac396104b7314afb23733ecc9e80fc8769f9 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Sun, 8 May 2022 19:24:08 +0200 Subject: Use 'annotations' from jdisc_core, do not embed in container-disc. --- container-core/pom.xml | 11 ++++++----- container-disc/pom.xml | 8 +++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/container-core/pom.xml b/container-core/pom.xml index d0d0226e58a..be22e5cae5c 100644 --- a/container-core/pom.xml +++ b/container-core/pom.xml @@ -17,11 +17,6 @@ - - com.yahoo.vespa - annotations - ${project.version} - com.yahoo.vespa container-documentapi @@ -169,6 +164,12 @@ no_aop provided + + com.yahoo.vespa + annotations + ${project.version} + provided + com.yahoo.vespa component diff --git a/container-disc/pom.xml b/container-disc/pom.xml index af901d4d62b..f84e1868724 100644 --- a/container-disc/pom.xml +++ b/container-disc/pom.xml @@ -46,7 +46,13 @@ assertj-core test - + + com.yahoo.vespa + annotations + ${project.version} + provided + + com.yahoo.vespa config-lib ${project.version} -- cgit v1.2.3 From ca729113517a0671a539db5eec49475a137a0791 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Sun, 8 May 2022 19:36:55 +0200 Subject: Add 'defaults' for logserver (previously pulled in by vespalog) --- logserver/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/logserver/pom.xml b/logserver/pom.xml index 409f3e51217..2d5eecd01ce 100644 --- a/logserver/pom.xml +++ b/logserver/pom.xml @@ -15,6 +15,11 @@ Log server. + + com.yahoo.vespa + defaults + ${project.version} + com.yahoo.vespa vespajlib -- cgit v1.2.3 From 91449bc0aa5bf0196f0be48add49098865702f4a Mon Sep 17 00:00:00 2001 From: gjoranv Date: Sun, 8 May 2022 20:02:12 +0200 Subject: Don't try to resolve from the system bundle for test frameworks .. as they have none. --- .../src/main/java/com/yahoo/osgi/OsgiImpl.java | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java index 761d4057db3..1e171a19b05 100644 --- a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java +++ b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java @@ -39,7 +39,7 @@ public class OsgiImpl implements Osgi { if (initialBundles.isEmpty()) throw new IllegalStateException("No initial bundles!"); - systemBundle = getSystemBundle(initialBundles); + systemBundle = getSystemBundle(initialBundles, jdiscOsgi); alwaysCurrentBundle = firstNonFrameworkBundle(initialBundles); if (alwaysCurrentBundle == null) throw new IllegalStateException("The initial bundles only contained the framework bundle!"); @@ -76,17 +76,19 @@ public class OsgiImpl implements Osgi { try { return (Class) Class.forName(spec.classId.getName()); } catch (ClassNotFoundException e) { - log.fine(() -> "Resolving class from the system bundle (jdisc core): " + spec.classId.getName()); - try { - return (Class) systemBundle.loadClass(spec.classId.getName()); - } catch (ClassNotFoundException e2) { - throw new IllegalArgumentException( - "Could not create a component with id '" + spec.classId.getName() + - "'. Tried to load class directly, since no bundle was found for spec: " + spec.bundle + - ". If a bundle with the same name is installed, there is a either a version mismatch" + - " or the installed bundle's version contains a qualifier string."); + if (hasFelixFramework()) { + log.fine(() -> "Resolving class from the system bundle (jdisc core): " + spec.classId.getName()); + try { + return (Class) systemBundle.loadClass(spec.classId.getName()); + } catch (ClassNotFoundException e2) { + // empty + } } } + throw new IllegalArgumentException( + "Could not create a component with id '" + spec.classId.getName() + "'. Tried to load class directly, " + + "since no bundle was found for spec: " + spec.bundle + ". If a bundle with the same name is installed, " + + "there is a either a version mismatch or the installed bundle's version contains a qualifier string."); } @SuppressWarnings("unchecked") @@ -171,12 +173,13 @@ public class OsgiImpl implements Osgi { return jdiscOsgi.isFelixFramework(); } - private static Bundle getSystemBundle(List bundles ) { + private static Bundle getSystemBundle(List bundles, OsgiFramework jdiscOsgi) { for (Bundle b : bundles) { if (b instanceof Framework) return b; } - throw new IllegalStateException("No system bundle in " + bundles); + if (jdiscOsgi.isFelixFramework()) throw new IllegalStateException("No system bundle in " + bundles); + return null; } private static Bundle firstNonFrameworkBundle(List bundles) { -- cgit v1.2.3