OpenLiberty / ci.maven

Maven plugins for managing Liberty profile servers #devops
Apache License 2.0
126 stars 90 forks source link

Disable feature generation when an unknown feature is detected #1544

Open kathrynkodama opened 2 years ago

kathrynkodama commented 2 years ago

When running liberty:dev if a specified feature is unknown by the binary scanner, we should disable feature generation and continue on.

[INFO] Running liberty:generate-features
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.974 s
[INFO] Finished at: 2022-06-08T15:41:29-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.6:dev (default-cli) on project guide-microprofile-graphql-system: Failed to generate a working set of features. Error scanning the application for Liberty features: java.lang.RuntimeException: CWMIG12125E: Unknown restfulWS-3.0 feature found. To disable the automatic generation of features, start dev mode with -DgenerateFeatures=false. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

We do something similar if we cannot find the binary scanner jar, see https://github.com/OpenLiberty/ci.maven/blob/9466c8755dc0996e8bd2d4a92dc875276e20d142/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java#L388-L391

We should also ask for a new exception from the binary scanner in this scenario. Something like FeatureUnknownException.

We should also add an integration test to cover this scenario.

gkwan-ibm commented 2 years ago

Workaround for LMP 3.6 dev mode to disable feature generation manually, run

mvn liberty:dev -DgenerateFeatures=false
gkwan-ibm commented 2 years ago

if users remove the unknown feature, will the generation be resumed automatically or users can press a command to resume?

gkwan-ibm commented 2 years ago

The message CWMIG12125E: Unknown restfulWS-3.0 feature found. is not quite right. The restfulWS-3.0 is a known feature for OL and user but not the scanner.

TrevCraw commented 2 years ago

@gkwan-ibm

if users remove the unknown feature, will the generation be resumed automatically or users can press a command to resume?

Users can use the g hotkey to turn feature generation back on.

The message CWMIG12125E: Unknown restfulWS-3.0 feature found. is not quite right. The restfulWS-3.0 is a known feature for OL and user but not the scanner.

We will ask for a new exception from the binary scanner for this scenario and then we will provide our own user facing error message.

yeekangc commented 2 years ago

Not failing should be the default behaviour for forward compatibility or future proofing. A message can certainly be logged.

inad9300 commented 2 years ago

Related to this issue, I have recently upgraded to 3.6 and was greeted with the following message:

[ERROR] Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.6:dev (default-cli) on project backend: Failed to generate a working set of features. Error scanning the application for Liberty features: java.lang.RuntimeException: CWMIG12125E: Unknown microProfile-5.0 feature found. To disable the automatic generation of features, start dev mode with -DgenerateFeatures=false.

I have the following list of features in server.xml:

    <featureManager>
        <feature>jakartaee-9.1</feature>
        <feature>microProfile-5.0</feature>
    </featureManager>

Where microProfile-5.0 should be a valid, well-known feature: https://openliberty.io/docs/latest/reference/feature/microProfile-5.0.html.

kathrynkodama commented 2 years ago

@inad9300 Thank you for your feedback! Supporting microprofile-5.0 for feature generation in the Liberty Maven Plugin is one of our high priority issues that the team is currently working on: https://github.com/OpenLiberty/ci.maven/issues/1450

In the meantime, a workaround is to continue using the previous 3.5.2 release of the Liberty Maven Plugin, or if working with the 3.6 release, disable feature generation by starting dev mode with mvn liberty:dev -DgenerateFeatures=false.