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

Improve stability of gradle build info extraction #4222

Merged

Conversation

matthiasblaesing
Copy link
Contributor

While trying to work with the gradle projects from liferay-portal it
was observed, that loading failed with an exception. There are two
problems:

  1. The liferay build provides incomplete implementation of JavaExec,
    which do not support setting the standard input

  2. The generated UnsupportedOperation exception carries a null message,
    rendering the @nonnull annotation in GradleReport invalid and
    causing NullPointerExceptions in use sites.

Fixes:

  1. Setting stdin is changed to be a best-effort operation. It is
    assumed that, if the setter fails, the access to stdin is not
    expected and thus does not need to be wired.

  2. If a null message is passed into GradleReport, it is replaced with
    an empty string.

While trying to work with the gradle projects from liferay-portal it
was observed, that loading failed with an exception. There are two
problems:

1. The liferay build provides incomplete implementation of JavaExec,
   which do not support setting the standard input

2. The generated UnsupportedOperation exception carries a null message,
   rendering the @nonnull annotation in GradleReport invalid and
   causing NullPointerExceptions in use sites.

Fixes:

1. Setting stdin is changed to be a best-effort operation. It is
   assumed that, if the setter fails, the access to stdin is not
   expected and thus does not need to be wired.

2. If a null message is passed into GradleReport, it is replaced with
   an empty string.
@matthiasblaesing
Copy link
Contributor Author

For the liferay-portal I also did:

  • Do a priming build of the liferay-portal, run ant all
  • Copy the gradle folder with the gradle-wrapper.jar from the root folder to the modules folder (else the gradle wrapper was not found). After the move, the properties file is found in modules/gradle/wrapper/gradle-wrapper.properties, while it was in gradle/wrapper/gradle-wrapper.properties before. Of course the reference to local copy of the gradle distribution needs to be updated then.
  • Rename the patched gradle distribution from gradle-6.6.1.LIFERAY-PATCHED-1-bin.zip to gradle-6.6.1-LIFERAY-PATCHED1-bin.zip (else the extracted gradle version string is rejected)
  • I had to patch modules/apps/portal-search-elasticsearch7/portal-search-elasticsearch7-impl/build.gradle and replace the variable ${project.'liferay.home'} with a fixed reference to my build bundles.

I'm not a totally happy camper (it is dog slow, blows away my memory, some test classpaths are still broken), but at least I can open the projects.

@lkishalmi @sdedic what do you think?

@matthiasblaesing
Copy link
Contributor Author

The exception I observed:

2022-06-13T19:56:47.896+0200 [DEBUG] [org.netbeans.modules.gradle.tooling.NetBeansRunSinglePlugin] Failed to set STDIN for Plugin: task ':apps:portal-search-elasticsearch7:portal-search-elasticsearch7-impl:autoUpdateXml'
java.lang.UnsupportedOperationException
	at com.liferay.gradle.plugins.tasks.BasePortalToolsTask.setStandardInput(BasePortalToolsTask.java:88)
	at com.liferay.gradle.plugins.tasks.DirectDeployTask_Decorated.setStandardInput(Unknown Source)
	at org.netbeans.modules.gradle.tooling.NetBeansRunSinglePlugin.lambda$apply$0(NetBeansRunSinglePlugin.java:66)
	at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:100)
	at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:95)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)

Copy link
Contributor

@lkishalmi lkishalmi left a comment

Choose a reason for hiding this comment

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

These changes seems to be sane.
I still have to look at how the liferay stuff works.

@matthiasblaesing
Copy link
Contributor Author

Thanks for the review - the liferay repository can be found here (I noticed, that that information was missing):

https://github.com/liferay/liferay-portal

@mbien mbien added the Gradle [ci] enable "build tools" tests label Jun 15, 2022
@mbien mbien added this to the NB15 milestone Jun 15, 2022
@matthiasblaesing matthiasblaesing merged commit e2d8fdf into apache:master Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gradle [ci] enable "build tools" tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants