Wire: Update README for 3.0

Created on 23 Jun 2019  路  13Comments  路  Source: square/wire

Include chapters on:

  • Kotlin generation
  • gRPC
  • Gradle plugin
documentation

Most helpful comment

I find this to be quite a common problem with published plugins, easiest way around it to do this in your settings.gradle.

resolutionStrategy {
      eachPlugin {
        if (requested.id.id == "com.squareup.wire") {
          useModule("com.squareup.wire:wire-gradle-plugin:${requested.version}")
        }
      }
  }

Docs are https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html

All 13 comments

@Egorand just found this project and it looks great - how is it possible to use the gradle plugin currently? We are making use of the kotlin DSL and specifying

plugins {
    id("com.squareup.wire") version "3.0.0-alpha03" apply false
}

or

plugins {
    id("com.squareup.wire")
}

fails with

* What went wrong:
Plugin [id: 'com.squareup.wire'] 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)

I believe we're not publishing to gradlePluginPortal() yet, so you won't be able to use the plugins block. @jrodbx would know more.

@jrodbx any update here? Would really love to be able to try out the 3.0 version.

Adding mavenCentral() to your buildscript repositories should resolve your issue @Globegitter.

@jrodbx I have tried both

// build.gradle.kts
buildscript {
    repositories {
        mavenCentral()
    }
}

as well as

// settings.gradle.kts
pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenCentral()
    }
}

and it is still failing - happy to put up a little github repository to reproduce if you want.

I am talking specifically about the new gradle plugin mentioned in the changelog, not just the library dependency.

Yep, understood that you're referencing the Gradle plugin. Yes, a sample repro case would be very helpful!

@jrodbx sorry for the delay but here we go: https://github.com/Globegitter/wire-gradle-plugin-repro

(@Globegitter fancy seeing you here Markus!)

FWIW I just ran into the same problem and resolved somewhat hackily.

In build.gradle added the plugin to the classpath:

dependencies {
    ...
   classpath 'com.squareup.wire:wire-gradle-plugin:3.0.0-rc01'
}

I also had to manually append the generated output to srcDirs with:

sourceSets {
    main.java.srcDirs += "$buildDir/generated/src/main/java"
}

I find this to be quite a common problem with published plugins, easiest way around it to do this in your settings.gradle.

resolutionStrategy {
      eachPlugin {
        if (requested.id.id == "com.squareup.wire") {
          useModule("com.squareup.wire:wire-gradle-plugin:${requested.version}")
        }
      }
  }

Docs are https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html

Does 3.0 or newer 3.0.1 support kotlin multiplatform officially ?
So wire can be used on iOS now?

We're working on it, here's the issue you can follow: https://github.com/square/wire/issues/880. If you're curious - take the latest snapshot for a spin and let us know how it worked for you!

3.0 has been released.

I had the same problem with the plugin:
Plugin [id: 'com.squareup.wire', version: '3.7.0'] was not found in any of the following sources:
It's just a simple Gradle project I'm trying to set up. Almost tried everything, but it didn't work, any solution?

Was this page helpful?
0 / 5 - 0 ratings