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

Make Klib-related Gradle tasks public #204

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from
Open

Conversation

fzhinkin
Copy link
Collaborator

@fzhinkin fzhinkin commented Mar 26, 2024

What was done:

  • cleaned up klib-related tasks API
  • rewrote code gluing up tasks together to utilize Gradle properties for proper dependency tracking
  • made tasks public
  • made some programmatic API classes used as tasks inputs serializable

Fixed #203

@fzhinkin fzhinkin added enhancement New feature or request klib labels Mar 27, 2024
@fzhinkin fzhinkin linked an issue Mar 27, 2024 that may be closed by this pull request
@fzhinkin fzhinkin marked this pull request as ready for review March 27, 2024 09:20
@fzhinkin fzhinkin requested a review from shanshin March 27, 2024 09:20
Base automatically changed from 199-disable-tasks-for-empty-projects to develop March 27, 2024 14:36
src/main/kotlin/-Utils.kt Show resolved Hide resolved
src/main/kotlin/-Utils.kt Show resolved Hide resolved
src/main/kotlin/-Utils.kt Show resolved Hide resolved
import java.util.jar.JarFile
import javax.inject.Inject

public open class KotlinApiBuildTask @Inject constructor(
) : BuildTaskBase() {
@OutputFile
public lateinit var outputApiFile: File

Choose a reason for hiding this comment

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

Why File but not RegularFileProperty?
It seems that because of this, lateinit looks very unusual

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change moves the property back from BuildTaskBase, so I left the same type. However, as this PR will break binary compatibility for the Compare task, it might be worth breaking it here as well and providing a more robust implementation in return.

Choose a reason for hiding this comment

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

You can try to add a reliable field, but maintain backward compatibility.
In BuildTaskBase

    @get:Internal
    public abstract var outputApiFile: File

In KotlinApiBuildTask

    @get:OutputFile
    ...
    public val realOutputApiFile: RegularFileProperty = project.objects.fileProperty()

    @get:Internal
    public override var outputApiFile: File
        get() = realOutputApiFile.get().asFile
        set(value) = realOutputApiFile.set(value)
  • I didn 't check it )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The main issue here is that we definitely want to phase these old properties out and ask users to migrate to realXXX ones, but old properties already claimed good names :(

Choose a reason for hiding this comment

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

Will changing property type break a lot? Because if we don't change it now, it will stay that way for a long time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A few weeks ago I had an impression that there are a lot of projects relying on these properties. After checking it once again, it seems like I was wrong and there are only a couple of projects on GH relying on it.

Originally, I was reluctant to make breaking changes as I wanted to limit the scope of the release to KLib support only. But as there are some other breaking changes already, it might be worth changing this part too and provide a migration guide for those who use corresponding properties.

As it was previously discussed elsewhere, currently BCV is mostly concerned with its own source compatibility as there are no other projects (beside Adam's BCV-MU) extending the BCV, so it should be more or less fine to change property types now.

src/main/kotlin/KotlinApiCompareTask.kt Outdated Show resolved Hide resolved
src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt Outdated Show resolved Hide resolved
src/main/kotlin/-Utils.kt Show resolved Hide resolved
src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt Outdated Show resolved Hide resolved
src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt Outdated Show resolved Hide resolved
src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt Outdated Show resolved Hide resolved
@fzhinkin fzhinkin requested a review from shanshin June 21, 2024 13:56
src/main/kotlin/BuildTaskBase.kt Outdated Show resolved Hide resolved
src/main/kotlin/BuildTaskBase.kt Outdated Show resolved Hide resolved
src/main/kotlin/BuildTaskBase.kt Outdated Show resolved Hide resolved
src/main/kotlin/BuildTaskBase.kt Outdated Show resolved Hide resolved
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputFile
import java.io.File


public abstract class BuildTaskBase : DefaultTask() {

Choose a reason for hiding this comment

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

Should we link a public task so tightly to a specific extension?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These tasks are tightly bound to BCV anyway. The thing that worries me more is implicit initialization of properties, but I'm not sure that making initialization explicit and moving it to BinaryCompatibilityValidatorPlugin will make a big difference for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request klib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make KLib validation related tasks public
2 participants