adobe / aemanalyser-maven-plugin

A Maven plugin used by developers who develop Java components for AEMaaCS (AEM as a Cloud Service) during their local Java builds to ensure that their components work correctly in when deployed to AEM as a Cloud Service.
Apache License 2.0
23 stars 20 forks source link

analyse error: Artifact requires [aem-guides-wknd.core/0.0.6] osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=11))" when compiled with Java 8 #15

Open kwin opened 3 years ago

kwin commented 3 years ago

When you execute mvn verify on https://github.com/kwin/aem-analyser-example/tree/analyse-failure-with-java8 with Java 8 you get

[ERROR] com.adobe.aem.guides:aem-guides-wknd.core:0.0.6: Artifact com.adobe.aem.guides:aem-guides-wknd.core:0.0.6 requires [aem-guides-wknd.core/0.0.6] osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=11))" in start level 20 but no artifact is providing a matching capability in this start level.
[ERROR] Analyser detected errors on feature 'biz.netcentric.aem:aem-analyser-example:slingosgifeature:aggregated-author.prod:0.0.1-SNAPSHOT'. See log output for error messages.

No error is emitted with Java 11! The capability version of osgi.ee should not be derived from Java version of the Maven build but rather from the Java version AEM is running with (always 11 for AEMaaCS).

kwin commented 3 years ago

Somehow the capabilities being calculated in https://github.com/apache/sling-org-apache-sling-feature-analyser/blob/master/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckRequirementsCapabilities.java#L65 take the current java version as basis. Somehow one needs to override that.

stefanseifert commented 3 years ago

a workaround until this is fixed: https://github.com/stefanseifert/aem-cloud-service-deployment-issues/commit/3d0ac6c5583bb604c117a323968f79fe9d01c3b4

it would be easier if the plugin would also support an "excludeTasks" option - but it does not. so we have to list all that are available and excluded that one that is problematic.

here is another problems showing the same problem outlined by @kwin based on archetype 25: https://github.com/stefanseifert/aem-cloud-service-deployment-issues/tree/feature/archetype-25-java11

kwin commented 3 years ago

Probably one can use the parameter https://github.com/apache/sling-slingfeature-maven-plugin/blob/d8a0bffbe4d1715c9d0f8791bb4db74772d7e9ad/src/main/java/org/apache/sling/feature/maven/mojos/AnalyseFeaturesMojo.java#L73 to set the right execution environment. Not sure which artifact to reference here, though.

kwin commented 3 years ago

I finally found the culprit and reported https://issues.apache.org/jira/browse/SLING-10288 for that.

cziegeler commented 3 years ago

I think the best is if the target framework is already described as part of the SDK feature model.

cziegeler commented 1 month ago

@rombert With SLING-10288 being implemented now, is there something we can do here?

rombert commented 1 month ago

I think this will be fixed with https://github.com/adobe/aemanalyser-maven-plugin/pull/245 . @kwin - could you validate that the current master + that PR fix the problem you reported?

kwin commented 1 month ago

I can't with the project from the description as you now require Java 11 to run aemanalyser (https://github.com/adobe/aemanalyser-maven-plugin/blob/d2df2a9ac36301a82a7a3887ee3b8eed7af903f0/parent-oss/pom.xml#L56).

rombert commented 1 month ago

@kwin - so I guess the problem was solved in a different manner by requiring Java 11 so this situation can no longer occur? I would suggest to close this then.

kwin commented 1 month ago

The general issue is that aemanalyser assumes the same Java version being used at build time (when executing the maven plugin) as during execution time of the OSGi runtime. The same would be true for building with Java 11 but running AEM in Java 17 (yes, I know, not yet supported).