Skip to content

Cleanup Gradle buildscripts and fix deprecations #73

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Jonathing
Copy link
Member

Name entails. Gradle should no longer complain or generate problem reports with this project.

I've split each part of this into its own commit, each with its own justification in its commit description.

- Added global repositories
  - Removed repository declarations from individual projects
- Added plugins to the version catalog
  - Projects now use the plugin aliases
- Removed unused libraries
- Cleaned up and standardized the syntax for the version catalog
- PomUtils is now designed to be directly referenced
- Declared common values like display name and vendor at top of the
script
- Replaced `gitversion.version` with `gitversion`
- Using `licenses { license }` instead of `license` in MavenPOM
  - The base `license` method is not part of MavenPOM but rather
DefaultMavenPOM, Gradle's own implementation of MavenPOM, which is
internal and should not be referenced directly.
EventBus 7 is currently using type-safe project accessors, and this
mandates that each included build has its name properly declared. Since
buildSrc is an included build, its name is now declared in its own
`settings.gradle` file.
As an included build, buildSrc does not share the EventBus project's
version catalog. As such, I've created its own and am using it here.
The test projects are creating custom tasks and are lazily configuring
their properties in their buildscripts. However, they are using
Project#file which eagerly resolves the file object before passing it
into the task property. This can result to issues in future Gradle
versions where practices involving eager resolution are discouraged.

I've replaced these usages with invocations to `ProjectLayout`, which
can be accessed directly in the script or by using the `project` object
as I've done here. This allows defining a file or directory location
without eager resolution, putting their values in a provider that can
then be passed into the task inputs without issue.
In Gradle 9, Gradle is removing the default conventions for custom
testing tasks created by consumer projects. I've declared the proper
classpaths using `Test#classpath` and `Test#testClassesDirs` to silence
the warning in the problems report and to ensure Gradle 9 compatibility.
To simplify buildscripts and to prevent needing to change multiple
values if need be, we've begun naming projects based on their artifact
names and using that in the maven publications instead of manually
writing out the desired artifact name (potentially multiple times).

This required changing the project name from "EventBus" to "eventbus".
Minor nitpicks to improve consistency. We do not use any plugins that
are hosted only on the Forge maven, so I have removed it from the plugin
management repositories.
Copy link
Contributor

@PaintNinja PaintNinja left a comment

Choose a reason for hiding this comment

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

Running ./gradlew jmh fails for me: https://scans.gradle.com/s/z7oofla5lgive

ERROR: org.openjdk.jmh.runner.RunnerException: Can not touch the result file: fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedFile, C:\Users\oscar\Documents\GitHub\PaintNinja\EventBus\eventbus-jmh\build\jmh_results\jmh-Adoptium-21.json)

Comment on lines +36 to +37
library 'junit-engine', 'org.junit.jupiter', 'junit-jupiter-engine' versionRef 'junit'
library 'junit-platform-launcher', 'org.junit.platform', 'junit-platform-launcher' version '1.10.1'
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor alignment mistake here

Comment on lines -57 to +55
rootProject.name = 'EventBus'
rootProject.name = 'eventbus'
Copy link
Contributor

Choose a reason for hiding this comment

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

Looked into this, I'd prefer having the projectDisplayName be the project.name and instead adding an artifactName variable that does a .toLowerCase(Locale.ROOT) on it. Some IntelliJ versions fail to sync projects if they're in a folder that's not named exactly the same as the project name, case-sensitive. In the latest version of IJ, the project name is treated as the display name.

Copy link
Member

Choose a reason for hiding this comment

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

That was my memory as well. Tho honestly just would prefer to have the artifact name hardcoded instead of being .toLowerCased simply for ease of understanding.

Comment on lines +113 to +119
'Adoptium': [21],
'Amazon': [21],
'Azul': (21),
'BellSoft': (21),
'Graal_VM': [21],
'Microsoft': [21],
'Oracle': (21),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'Adoptium': [21],
'Amazon': [21],
'Azul': (21),
'BellSoft': (21),
'Graal_VM': [21],
'Microsoft': [21],
'Oracle': (21),
'Adoptium': [21],
'Amazon': [21],
'Azul': [21],
'BellSoft': [21],
'Graal_VM': [21],
'Microsoft': [21],
'Oracle': [21],

@Jonathing
Copy link
Member Author

I probably forgot to ensure the parent directory. Whoops.

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.

3 participants