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

Move the :gradle-plugin project into the main build #763

Merged
merged 2 commits into from
Nov 2, 2023

Conversation

RBusarow
Copy link
Collaborator

@RBusarow RBusarow commented Oct 31, 2023

Inspired by Molecule #131

The :gradle-plugin project is now part of two builds.

The "build-logic" build creates a version that can be applied to projects in the main build (samples). This sits in between the normal build-logic build and the main build, so that the :gradle-plugin project can still consume the convention plugins.

The root build creates the version that's actually published to Maven Central and the plugin portal. The :gradle-plugin project no longer needs special treatment when publishing or executing CI.

Even though the total number of Gradle builds in the repository hasn't changed, we now just have one significant build (the root) and two implementation-detail builds that are never invoked on their own. That means we don't need to symlink any gradle directories or the libs.versions.toml catalog file. As a happy side effect: fixes #744 and fixes #757.

Inspired by Molecule [#131](cashapp/molecule#131)

The `:gradle-plugin` project is now part of two builds.

The "build-logic" build creates a version that can be applied to projects in the main build (samples).  This sits in between the normal `build-logic` build and the main build, so that the `:gradle-plugin` project can still consume the convention plugins.

The "main" build creates the version that's actually published to Maven Central and the plugin portal.  The `:gradle-plugin` project no longer needs special treatment when publishing or executing CI.
They can be replaced with the newer types once real integration tests are in place
@@ -37,6 +34,15 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.File
import java.util.concurrent.ConcurrentHashMap

@Suppress("DEPRECATION")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since gradle-plugin is now in the main build, it now gets the "warnings as errors" behavior in CI.

@RBusarow RBusarow marked this pull request as ready for review October 31, 2023 02:11
Copy link
Member

@JoelWilcox JoelWilcox left a comment

Choose a reason for hiding this comment

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

Noice

.github/workflows/ci.yml Show resolved Hide resolved
}

buildConfig {
className('BuildProperties')
packageName('com.squareup.anvil.plugin')
useKotlinOutput { topLevelConstants = true }
useKotlinOutput {
internalVisibility = true
Copy link
Member

Choose a reason for hiding this comment

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

Is this effectively changing all default visibility modifiers to internal instead of public / why do we care about adding it here? The README comment documenting this was ambiguous to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's lots of ambiguous terms here. 🤣

This makes it so that properties in the generated BuildProperties.kt file definitely have internal visibility, like:

...
internal const val GROUP: String = "com.squareup.anvil"
...

This plugin generates internal properties by default, so I'm adding it here just to be explicit.

Choose a reason for hiding this comment

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

Perhaps this also causes the error I'm seeing trying to sync the project:
`A problem occurred evaluating project ':gradle-plugin-build-logic:gradle-plugin'.

Could not get unknown property 'GROUP' for extension 'buildConfig' of type com.github.gmazzo.gradle.plugins.internal.DefaultBuildConfigExtension.`

Comment on lines -363 to +375
val variantFilter: VariantFilter,
val variantFilter: VariantFilter
Copy link
Member

Choose a reason for hiding this comment

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

This makes me sad 😭

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well FWIW, it's disabled in .editorconfig:

anvil/.editorconfig

Lines 494 to 495 in 7507b27

ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false

This error (😉) would have been allowed in CI because we're still using KtLint 0.41.0, which had no concept of trailing commas.

@RBusarow RBusarow merged commit 0ee0ccb into main Nov 2, 2023
19 checks passed
@RBusarow RBusarow deleted the rick/build-logic-composite-wrapper branch November 2, 2023 03:15
RBusarow added a commit that referenced this pull request Nov 2, 2023
…ties

The symnlinked properties file caused issues with syncing in Windows.

#763 (comment)
RBusarow added a commit that referenced this pull request Nov 30, 2023
It will be applied everywhere with the new convention plugins, but it hasn't been since [(#763)](#763) landed.  Since we now add trailing commas, there's a bit of a diff.
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.

IDE not syncing on fresh pull Configuration error in gradle-plugin when building on Windows
3 participants