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

Unable to apply com.jfrog.artifactory plugin in a build-logic included build gradle.kts precompiled build script #96

Closed
maksym-moroz opened this issue Jan 9, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@maksym-moroz
Copy link

Describe the bug

Specifying the dependency in a root-level build.gradle.kts with a version directly or via version catalog and not applying it but instead opting to apply it inside build-logic convention plugin produces the following error log

* Where:
Precompiled script plugin '***/build-logic/src/main/kotlin/artifactory-publishing.gradle.kts' line: 1

* What went wrong:
Plugin [id: 'com.jfrog.artifactory'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)

Current behavior

Unable to apply com.jfrog.artifactory plugin to lift out the publishing logic into a convention plugin

Reproduction steps

No response

Expected behavior

Being able to set up publishing from a convention plugin inside an included build

Artifactory Gradle plugin version

5.1.13 or any

Operating system type and version

MacOS

JFrog Artifactory version

No response

Gradle version

8.2.0

@maksym-moroz maksym-moroz added the bug Something isn't working label Jan 9, 2024
@yahavi
Copy link
Member

yahavi commented Jan 11, 2024

@maksym-moroz
Appreciate you flagging this problem!
Could you please share a basic reproducer project? Just a small GitHub project that we can fork to replicate the issue.
Thanks!

@maksym-moroz
Copy link
Author

For those interested in extracting jfrog-artifactory setup into a precompiled convention plugin, here is the quick guide.

To apply jfrog-artifactory inside your convention plugin you first need to satisfy the dependency on it inside build.gradle.kts for your included build

dependencies {
    implementation(libs.jfrog.artifactory)
}

This is where I faced the problem since applying a plugin via implementation is not allowed.
Here is the Gradle spec for addressing this problem, however it's not done yet but there is a workaround described, copying it here in case the link dies:

It is currently not possible to use the plugin id (and version) or the version catalog for dependency declaration, which means the required coordinates have to be known or be derived somehow. The steps to retrieve the coordinates are manual and cumbersome: One has to lookup the plugin on the Plugin Portal, find the coordinates in the legacy snippet at the bottom and copy them from there.

For jfrog-artifactory legacy path is org.jfrog.buildinfo:build-info-extractor-gradle

Adding this as a library to the version catalog and then referring to it from build.gradle.kts dependencies block allows you to add id("com.jfrog.artifactory") to your precompiled convention plugin.

For some reason using artifactory {} block is not possible as it keeps getting unrecognised after getting generated.
For those wondering how to configure it in case you face the same issue, extension is called ArtifactoryPluginConvention, i.e. configure<ArtifactoryPluginConvention> {...}

Hope this helps.

@yahavi
Copy link
Member

yahavi commented Jan 15, 2024

Thank you very much for your guidance, @maksym-moroz!
It will certainly be beneficial to others who encounter this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants