Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception handling for generateFeatures #672

Conversation

kathrynkodama
Copy link
Contributor

Handles exception for the generateFeatures task.

When the task runs standalone and an error occurs, a GradleException is thrown and users will see a build failure.

kathrynkodama@MacBook-Pro demo-devmode-scan % gradle generateFeatures

> Task :generateFeatures FAILED
Parsing the server file /Users/kathrynkodama/devex/featureGeneration/demo-devmode-scan/src/main/liberty/config/server.xml1 for features and includes.
SEVERE: CWMIG12083E: The cdi-2.0 feature requires the io.openliberty.servlet.api-4.0 feature which conflicts with the io.openliberty.servlet.api-3.1 feature that is required by the batch-1.0 feature.
SEVERE: CWMIG12083E: The cdi-2.0 feature requires the io.openliberty.servlet.api-4.0 feature which conflicts with the io.openliberty.servlet.api-3.1 feature that is required by the batch-1.0 feature.
SEVERE: CWMIG12083E: The cdi-2.0 feature requires the io.openliberty.servlet.api-4.0 feature which conflicts with the io.openliberty.servlet.api-3.1 feature that is required by the batch-1.0 feature.
SEVERE: CWMIG12085E: The feature list for the  application cannot be generated because of the conflicts between required features.
SEVERE: CWMIG12085E: The feature list for the  application cannot be generated because of the conflicts between required features.
SEVERE: CWMIG12085E: The feature list for the  application cannot be generated because of the conflicts between required features.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateFeatures'.
> A working set of features could not be generated due to conflicts between configured features and the application's API usage: [cdi-2.0, batch-1.0, webProfile-8.0, jpa-2.2, jaxrs-2.1]. Review and update your server configuration and application to ensure they are not using conflicting features and APIs from different levels of MicroProfile, Java EE, or Jakarta EE. Refer to the following set of suggested features for guidance: [cdi-2.0, mpHealth-2.2, batch-1.0, jpa-2.2, jaxrs-2.1]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
1 actionable task: 1 executed

When running the goal as part of dev mode:

On startup if generateFeatures throws an error dev mode will exit. If there is a feature conflict (most likely reason generate-features will fail) we fail here first to show users a more relevant error message rather than continuing on to installFeature and failing there. Error message indicates that users can disable feature generation with --generateFeatures=false

> Task :generateFeatures FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateFeatures'.
> A working set of features could not be generated due to conflicts between configured features and the application's API usage: [cdi-2.0, batch-1.0, webProfile-8.0, jpa-2.2, jaxrs-2.1]. Review and update your server configuration and application to ensure they are not using conflicting features and APIs from different levels of MicroProfile, Java EE, or Jakarta EE. Refer to the following set of suggested features for guidance: [cdi-2.0, mpHealth-2.2, batch-1.0, jpa-2.2, jaxrs-2.1]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
1 actionable task: 1 executed

> Task :libertyDev FAILED
To disable the automatic generation of features, start dev mode with --generateFeatures=false.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libertyDev'.
> Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.9.1-bin.zip'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 9s
1 actionable task: 1 executed

Once in the inner dev mode loop errors from generateFeatures will not fail dev mode, users will see the following error in their console:

> Task :generateFeatures FAILED
Parsing the server file /Users/kathrynkodama/devex/featureGeneration/demo-devmode-scan/src/main/liberty/config/server.xml1 for features and includes.
Parsing the server file /Users/kathrynkodama/devex/featureGeneration/demo-devmode-scan/src/main/liberty/config/configDropins/overrides/generated-features.xml for features and includes.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateFeatures'.
> A working set of features could not be generated due to conflicts between configured features: [cdi-2.0, mpHealth-2.2, jpa-2.2, webProfile-7.0, jaxrs-2.1]. Review and update your server configuration to ensure it is not using conflicting features from different levels of MicroProfile, Java EE, or Jakarta EE. Refer to the following set of suggested features for guidance: [cdi-2.0, mpHealth-2.2, batch-1.0, jpa-2.2, jaxrs-2.1]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 879ms
1 actionable task: 1 executed

> Task :libertyDev
Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.9.1-bin.zip'..
 To disable the automatic generation of features, type 'g' and press Enter.

Signed-off-by: Kathryn Kodama [email protected]

Copy link
Contributor

@TrevCraw TrevCraw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to ci.maven, the message To disable the automatic generation of features, start dev mode with --generateFeatures=false. is separated from the actual error and may give users the wrong impression. Is it possible to put that message next to the error message?

@kathrynkodama
Copy link
Contributor Author

Updated the error message shown when generateFeatures fails on dev mode startup to:

> Task :generateFeatures FAILED
Parsing the server file /Users/kathrynkodama/devex/featureGeneration/demo-devmode-scan/src/main/liberty/config/server.xml1 for features and includes.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateFeatures'.
> A working set of features could not be generated due to conflicts between configured features and the 
application's API usage: [cdi-2.0, batch-1.0, webProfile-8.0, jpa-2.2, jaxrs-2.1]. Review and update your server 
configuration and application to ensure they are not using conflicting features and APIs from different levels of 
MicroProfile, Java EE, or Jakarta EE. Refer to the following set of suggested features for guidance: [cdi-2.0, 
mpHealth-2.2, batch-1.0, jpa-2.2, jaxrs-2.1]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
1 actionable task: 1 executed
> Task :libertyDev FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libertyDev'.
> Execution failed for task ':generateFeatures'. To disable the automatic generation of features, start dev mode 
with --generateFeatures=false.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 8s
1 actionable task: 1 executed

Also updated the comments inserted in the generated-features.xml file. See OpenLiberty/ci.maven#1331 (comment)

@kathrynkodama kathrynkodama merged commit 550bb60 into OpenLiberty:generateFeatures Dec 13, 2021
cherylking pushed a commit that referenced this pull request Dec 15, 2021
* Add Generate Features prototype and implement the necessary interfaces.

Signed-off-by: Paul Gooderham <[email protected]>

* Add the generateFeatures command line and build file option.

Signed-off-by: Paul Gooderham <[email protected]>

* Add comment to existing server.xml and scan gradle classes dirs.

Signed-off-by: Paul Gooderham <[email protected]>

* Code cleanup.

Signed-off-by: Paul Gooderham <[email protected]>

* Make generateFeatures option command line only. Clean up streams code.

Signed-off-by: Paul Gooderham <[email protected]>

* Allow generateFeatures=false

* Add classFile option to GenerateFeaturesTask (#640)

Signed-off-by: Kathryn Kodama <[email protected]>

* Get binary scanner jar from connected repos

* Fix name of API method.

Signed-off-by: Paul Gooderham <[email protected]>

* Use gradle convention for latest release version

* Update message

* Change generated file name to generated-features.xml (#644)

Signed-off-by: Kathryn Kodama <[email protected]>

* Fix NPE and remove getAllServerFeatures

* Fix IO error when server is not yet setup.

Signed-off-by: Paul Gooderham <[email protected]>

* Quick fix

Signed-off-by: Paul Gooderham <[email protected]>

* Remove binary scanner jar parameter

* Handle optimize and non-optimize cases

* Add a system where the binary scanner handler detects an error generated
by the scanner and calls it again with fewer restrictions in order to
generate a list of suggested features that should work. This error
and suggested solution is then displayed to the user.

* Improved error reporting after code review.

Signed-off-by: Paul Gooderham <[email protected]>

* After writing server.xml ensure <server> element is on a new line.

Signed-off-by: Paul Gooderham <[email protected]>

* Move the xml document rewrite code into ci.common.

Signed-off-by: Paul Gooderham <[email protected]>

* Remove unused import.

Signed-off-by: Paul Gooderham <[email protected]>

* Use the binary scanner support in ci.common.

Signed-off-by: Paul Gooderham <[email protected]>

* Remove unused imports and class variable.

Signed-off-by: Paul Gooderham <[email protected]>

* Allow info messages to appear in output by default and without setting log level to Info.

Signed-off-by: Paul Gooderham <[email protected]>

* Get existing features for feature gen from the source config dir (#661)

* Get existing features for feature gen from the source config dir

Signed-off-by: Kathryn Kodama <[email protected]>

* Call generate features on dev mode startup and restart

Signed-off-by: Kathryn Kodama <[email protected]>

* Simplify getServerFeatureUtil method

Signed-off-by: Kathryn Kodama <[email protected]>

* Update to use latest snapshot from ci.common

Signed-off-by: Kathryn Kodama <[email protected]>

* Add binary scanner sonatype repo to dev test

Signed-off-by: Kathryn Kodama <[email protected]>

* Update sonatype repo link in dev tests

Signed-off-by: Kathryn Kodama <[email protected]>

* Diable feature generation in dev tests

Signed-off-by: Kathryn Kodama <[email protected]>

* Added optimize parameter for generating features

* Added optimize parameter to generateFeatures task

* Feature generation, create generated xml file with empty feature list (#664)

* When no features left to generate create generated xml file with empty feature list

Signed-off-by: Kathryn Kodama <[email protected]>

* Improve comment in generated-features.xml

Signed-off-by: Kathryn Kodama <[email protected]>

* Improve formatting for comments

Signed-off-by: Kathryn Kodama <[email protected]>

* Allow optimize to be passed in as a String parameter

* Use binary scanner Maven coordinates promoted by the scanner team.

Signed-off-by: Paul Gooderham <[email protected]>

* Fix compileJava call in recompileBuildFile

* Put snapshot repo on project level for dev tests

Signed-off-by: Kathryn Kodama <[email protected]>

* Updated debug statements

* Use new method downloadBuildArtifact() to search buildscript portion of build.gradle

Signed-off-by: Paul Gooderham <[email protected]>

* Exception handling for generateFeatures (#672)

* Exception handling for generateFeatures

Signed-off-by: Kathryn Kodama <[email protected]>

* Updated generateFeatures error message and generated-features.xml comment

Signed-off-by: Kathryn Kodama <[email protected]>

* Remove unnecessary imports and adjust copyright header

Signed-off-by: Kathryn Kodama <[email protected]>

* Update dev test project build.gradle

Signed-off-by: Kathryn Kodama <[email protected]>

* Improve comment for default generateFeatures behaviour

Signed-off-by: Kathryn Kodama <[email protected]>

* Improve exception handling message when generate features fails (#675)

* Improve exception handling message when generate features fails

Signed-off-by: Kathryn Kodama <[email protected]>

* Add return boolean for libertyGenerateFeatures method

Signed-off-by: Kathryn Kodama <[email protected]>

* Add missing return statement for createNewInstallFeatureUtil (#678)

Signed-off-by: Kathryn Kodama <[email protected]>

Co-authored-by: Paul Gooderham <[email protected]>
Co-authored-by: Eric Lau <[email protected]>
Co-authored-by: Kathryn Kodama <[email protected]>
@kathrynkodama kathrynkodama deleted the featureGen-exception-handling branch January 24, 2022 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants