This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch issue/SLING-10288 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-analyser.git
commit 5d140fdf45093f1c4b0fa11a8af914a81b9ecee4 Merge: 847f9ce 20a670a Author: Robert Munteanu <[email protected]> AuthorDate: Mon Jun 10 11:51:47 2024 +0200 Merge branch 'master' into local/2-SLING-10288 readme.md | 6 ++++-- .../feature/analyser/extensions/AnalyserMetaDataHandler.java | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --cc src/main/java/org/apache/sling/feature/analyser/extensions/AnalyserMetaDataHandler.java index 7e7e031,830bc7b..06c02d9 --- a/src/main/java/org/apache/sling/feature/analyser/extensions/AnalyserMetaDataHandler.java +++ b/src/main/java/org/apache/sling/feature/analyser/extensions/AnalyserMetaDataHandler.java @@@ -55,8 -48,6 +55,7 @@@ public class AnalyserMetaDataHandler im @Override public void postProcess(HandlerContext handlerContext, Feature feature, Extension extension) { - - ++ if (AnalyserMetaDataExtension.EXTENSION_NAME.equals(extension.getName())) { LOG.debug("Handling analyser-metadata extension {}", extension); JsonObject extensionJSONStructure = extension.getJSONStructure().asJsonObject(); @@@ -94,41 -82,8 +93,42 @@@ } } ) - );; - ); ++ ); + + if (frameworkDefinitionHolder[0] != null) { + JsonObject v = frameworkDefinitionHolder[0]; + // TODO - add test + // TODO - finalise contract + // TODO - make use of the information in the Analyser, if present + FrameworkScanner scanner = ServiceLoader.load(FrameworkScanner.class).iterator().next(); + try { + ExecutionEnvironmentExtension executionEnv = ExecutionEnvironmentExtension.getExecutionEnvironmentExtension(feature); + if ( executionEnv != null ) { + ArtifactId frameworkId = executionEnv.getFramework().getId(); + if ( executionEnv.getJavaVersion() == null ) { + LOG.warn("No java version set in execution environment extension, skipping version validation"); + } else { + Version requiredJavaVersion = executionEnv.getJavaVersion(); + Version currentJavaVersion = new Version(SystemUtils.JAVA_VERSION); + + if ( requiredJavaVersion.getMajor() != currentJavaVersion.getMajor() ) + throw new IllegalStateException("Execution environment requires Java " + requiredJavaVersion.getMajor() + ", but running on " + currentJavaVersion.getMajor() + ". Aborting."); + + } + BundleDescriptor fw = scanner.scan(frameworkId, feature.getFrameworkProperties(), handlerContext.getArtifactProvider()); + JsonObjectBuilder wrapper = Json.createObjectBuilder(v); + wrapper.add(Constants.PROVIDE_CAPABILITY, fw.getCapabilities().toString()); + wrapper.add(Constants.EXPORT_PACKAGE, fw.getExportedPackages().toString()); + result.add(Constants.SYSTEM_BUNDLE_SYMBOLICNAME, wrapper); + } else { + LOG.warn("No execution environment found, not creating framework capabilities"); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + feature.getExtensions().remove(extension); // Mark the extension as optional now that we've processed it.
