Evening, all. I'm converting a project from Gradl...
# announcements
a
Evening, all. I'm converting a project from Gradle-Kotlin to Maven, and in the process of migration have kicked up a worrying warning message. I'm not sure where to report it, suggestions, please?
Copy code
[INFO] --- kotlin-maven-plugin:1.4.20-RC:compile (compile) @ app ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil (file:/Users/alecm/.m2/repository/org/jetbrains/kotlin/kotlin-compiler/1.4.20-RC/kotlin-compiler-1.4.20-RC.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
b
I'm curious why you're migrating to maven? Usually it's the other way around since gradle is the main recommended build tool for kotlin.
a
Hi @Big Chungus - it's an experiment. So far I have had really bad experiences with trying to use Kotlin-Gradle, there's so little
build.gradle.kts
documentation for so many of my dependencies, and now as part of the experiment I am learning that some other dependencies are deprecating
maven
, too. It is beginning to look that the only way to build Kotlin is to use non-Kotlin-gradle. i.e.: Groovy or whatever. Does this reflect your experience, please?
b
I have no issues with kotlin-gradle and love using it. The docs are not lacking, just spread out all over the place, so it can be somewhat hard to get a consistent picture of them.
a
My challenge is stuff like this: Wire Gradle Plugin - where I don't know enough Gradle to convert the Groovy config over to a KotlinGradle equivalent.
b
In most cases you should be able to just replace all
'
to
"
and all implicit groovy method invocations to explicits like
srcDir 'src/main/protos'
->
srcDir("src/main/protos")
a
@Big Chungus would you be able to advise me re: converting the gradle-plugin directives on this page, to the
.kts
equivalent, please?
If I insert
id("com.squareup.wire") version "3.5.0"
into the
plugins{}
then I just get a
Plugin ...was not found in any of the following sources
which seems odd for something that is in Maven
b
Most likely that plugin is not published with gradle plugin marker artifact. Another reason could be that it's not in gradlePluginPortal and you need to add its repo into settings.gradle.kts pluginManagement.repositories
❤️ 1
Also this groovy block is invalid
Copy code
plugins {
  id 'application'
  id 'org.jetbrains.kotlin.jvm'
  id 'com.squareup.wire'
}
Since the page there doesn't specify where the version is listed
a
so it should be something like:
id("com.squareup.wire") version "3.5.0"
?
b
Here's what you need in build.gradle.kts
Copy code
plugins {
  application
  kotlin("jvm") version "1.4.10"
  id("com.squareup.wire") version "3.5.0"
}
You might need to swap the order of kotlin and application plugins
a
Still fails. I have set the
pluginManagement.repositories
to include Maven, and it is still not being found.
Copy code
* What went wrong:
Plugin [id: 'com.squareup.wire', version: '3.5.0'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.squareup.wire:com.squareup.wire.gradle.plugin:3.5.0')
  Searched in the following repositories:
    Gradle Central Plugin Repository
    MavenRepo
The name at Maven does not match the above; on the website is it given as
wire-gradle-plugin
with hyphens. On that basis, I tried the following, too:
Copy code
implementation("com.squareup.wire:wire-gradle-plugin:3.5.0")
...and although that stops the breakage, it does not seem to install the plugin in a usable state; I cannot do
wire{}
for instance
b
Try this (in build.gradle.kts at the top, but after plugins block):
Copy code
buildscript {
  repositories {
    mavenCentral()
    gradlePluginPortal()
  }
  dependencies {
    classpath("com.squareup.wire:wire-gradle-plugin:3.5.0")
  }
}

apply(plugin = "wire-gradle-plugin")
If that doesn't work, try replacing apply line with
apply(plugin = "com.squareup.wire:wire-gradle-plugin")
P.S. Plugin docs are very bad 👮
❤️ 1
a
@Big Chungus - no joy, but I have logged an issue, and hopefully cited you: https://github.com/square/wire/issues/1848
Thank you greatly for your help, this has been terribly frustrating.
b
Yes you found my github handle right 😄 I'm at a loss why they've left out repo/version in their docs, though... First time I'm seeing such thing in published stuff.
a
It's even a quite popular package; there are several citations in this slack.
b
Did some search in their repo and this should work for you:
Copy code
buildscript {
  repositories {
    mavenCentral()
    gradlePluginPortal()
  }
  dependencies {
    classpath("com.squareup.wire:wire-gradle-plugin:3.5.0")
  }
}
apply(plugin = "com.squareup.wire")
It's not on gradlePluginPortal, sadly
So you do need mavenCentral repo setup
Looks like I was right and
Copy code
plugins {
  application
  kotlin("jvm") version "1.4.10"
  id("com.squareup.wire") version "3.5.0"
}
Is not gonna work due to the plugin not having plugin marker published
But buildScript way should resolve fine now. Let me know how it goes.
a
Plugin [id: 'com.squareup.wire', version: '3.5.0', apply: false] was not found in any of the following sources:
😕
ah, wait.
I forgot to remove the entry from plugin, at first. ..,, it loads but then fails to work. Documented at https://github.com/square/wire/issues/1848#issuecomment-724096310
<afk tea>
😢 1
@Big Chungus thank you for your help with all that 🙂
b
Np, I take it you've solved it? 🎉
a
Yes indeed - there's a simple but inobvious workaround.
hack on
resolutionStrategy
b
I've left a comment on that issue for plugin maintainers on how to publish it properly so they wouldn't need to hack it anymore.
❤️ 1
👍 1