Rewrite throws error on rewriteDiscover

Hi I am currently trying to upgrade our project to 2024.06 and when I try to run rewriteDiscover I get an error saying that “com.mgmtp.a12.mr:commons-master:39.107.0” is not available. This package is apperently required by “kernel-core-facade:29.1.0”.

I also get this error:

No matching variant of com.mgmtp.a12.dataservices:dataservices-parent:37.0.0 was found. The consumer was configured to find a library for use during runtime, packaged as a jar, preferably optimized for standard JVMs, and
its dependencies declared externally but:
- Variant ‘apiElements’ capability com.mgmtp.a12.dataservices:dataservices-parent:37.0.0:
- Incompatible because this component declares a platform for use during compile-time and the consumer needed a library for use during runtime

What should i do to run rewrite correctly?

Hello,

Thank you for posting this question.

That’s probably associated with this question 2024.06 Template - Dependency can not be resolved - #7 by jlemsky

Please let me know if it works now :grinning:

Sadly this didn’t fix our issue. The problem seems to stem from our artifactory not having the commons-master:39.107.0 package. I will ask around in our project and update here.

In the meantime there is still the other problem we get regarding the libraries.

Hello,

I have a quick check, there’s no commons-master:39.107.0 in geta12 artifactory

I would suggest a temporary fix by

implementation('com.mgmtp.a12.mr:commons-master) {
        version {
            strictly '39.107.1'
        }
    }

We will proceed to publish the artifacts again

So I added that and now the one error is gone when executing “./gradlew rewriteDryRun”. But I still get the other error with “commons-master declares a component for use during compile-time: -Incompatible because this component declares a platform and the consumer needed a library”.

How do i go about that problem?

The Problem appears to only occur when trying to use the rewrite tool to upgrade. Manually updating the versions and then refactoring the code works as I would expect it.

Moin @nick-linked-tensor,

we will investigate why the rewrite isn‘t working properly for you and provide a fix as soon as possible.

Hi,
The commons-master:39.107.0 artifact is on getA12; we can remove the workaround by overwriting the version. Could you please check again?

Moin everybody,
we followed up with @nick-linked-tensor, and the issue seems to be a misconfiguration for the rewrite in the build.gradle.

The configuration should look similar like this:

plugins {
       // … other plugins
       id("org.openrewrite.rewrite") version("6.16.2")
}

rewrite {
    activeRecipe(
        'com.mgmtp.a12.dataservices.UpgradeDataServicesProperties_37',
        'com.mgmtp.a12.dataservices.UpgradeDataServices_37',
        'com.mgmtp.a12.uaa.openrewrite.UpgradeUaa_8_0',
        'com.mgmtp.a12.kernel.UpgradeKernel_29',
    )
}

dependencies {
    // … other dependencies

    rewrite("com.mgmtp.a12.dataservices:dataservices-rewrite:37.0.0")
    rewrite("com.mgmtp.a12.uaa:uaa-rewrite:8.0.0")
    rewrite("com.mgmtp.a12.kernel:kernel-rewrite:29.1.1")
}   

For more information and step-by-step explanations on how to use codemods and rewrite artifacts, please checkout the Migration Guide 2024.06.