akka / akka-grpc

Akka gRPC
https://doc.akka.io/docs/akka-grpc/
Other
431 stars 123 forks source link

Using gradle plugin DSL fails #716

Closed smarijic closed 4 years ago

smarijic commented 4 years ago

Hi,

I can't include akka-grpc using plugin DSL as it fails with following error:

An exception occurred applying plugin request [id: 'com.lightbend.akka.grpc.gradle', version: '0.7.2'] Failed to apply plugin [id 'com.lightbend.akka.grpc.gradle'] Could not find method protobuf() for arguments [akka.grpc.gradle.AkkaGrpcPlugin$_apply_closure1$_closure2@7e475405] on root project 'xzy' of type org.gradle.api.Project.

I've tried multiple gradle versions also, same result. Legacy usage with classpath works.

Is there something that I've missed?

arunkpatra commented 4 years ago

This is still the issue as of version 0.8.4 of the plugin.

raboof commented 4 years ago

This looks similar to #545, do you have the 'scala' plugin enabled?

I think we have seen this problem in other places as well, though - but I can't find a reference right now.

I wonder if the improvements in #1042 might help here as well.

Chr1stian commented 4 years ago

I have same issue (opened one that got closed and referred to this) and the 'scala' plugin is enabled as it is for a scala-project.

raboof commented 4 years ago

We're also seeing this problem in akka-grpc-quickstart-java.g8: #1034

The strange thing is we're not seeing it in the akka-grpc travis tests, and not on the akka-grpc-quickstart-scala.g8 tests (https://github.com/akka/akka-grpc-quickstart-scala.g8).

Do you also see the problem when you use the quickstart project? Can anyone spot the difference?

eshepelyuk commented 4 years ago

@raboof which repo should be taken into consideration for this bug ? I could take a look

raboof commented 4 years ago

@eshepelyuk that would be great!

It's hard to say where to start since it's still unclear what's triggering the problem - I can at least reproduce #1034 with sbt new akka/akka-grpc-quickstart-java.g8 and then ./gradlew build, even when I update the plugin version to 1.0.0-17-3dcade13

eshepelyuk commented 4 years ago

@raboof is there any existing repo to start with ? i don't have sbt and no sure what sbt new is doing at all.

raboof commented 4 years ago

ah, sorry :).

The code is in https://github.com/akka/akka-grpc-quickstart-java.g8 . Unfortunately this is a 'template', so you'll need the g8 tool to apply it: http://www.foundweekends.org/giter8/usage.html .

(Also I just noticed the jar artifacts of 1.0.0-17-3dcade13 haven't been uploaded correctly, but the problem occurs even before that)

eshepelyuk commented 4 years ago

But this repo doesn't have build.gradle , how one could run Gradle ?

ignasi35 commented 4 years ago

@eshepelyuk you have two options:

  1. install sbt and use sbt new akka/akka-grpc-quickstart-java.g8, or
  2. download a packaged version of the template code with sbt from https://developer.lightbend.com/start/?group=akka&project=akka-grpc-quickstart-java

:-)

raboof commented 4 years ago

this repo doesn't have build.gradle , how one could run Gradle ?

This repo is the template, it will process the files in https://github.com/akka/akka-grpc-quickstart-java.g8/tree/master/src/main/g8 to form a (local) repository that does have a build.gradle.

you have two options:

Actually if you don't have sbt you can also invoke g8 'directly' as documented at http://www.foundweekends.org/giter8/usage.html . But indeed getting the package at https://developer.lightbend.com/start/?group=akka&project=akka-grpc-quickstart-java is probably even more convenient

Chr1stian commented 4 years ago

I get the same error with akka-grpc-quickstart-java.g8, but not with akka-grpc-quickstart-scala. My project is based on the akka-grpc-quickstart-scala setup which does provoke the same error on ./gradlew build

raboof commented 4 years ago

@Chr1stian interesting, can you figure out what's the difference? Perhaps something with gradle version?

eshepelyuk commented 4 years ago

Is snapshot of gradle plugin published as well ?

raboof commented 4 years ago

Is snapshot of gradle plugin published as well ?

Yes: https://plugins.gradle.org/m2/com/lightbend/akka/grpc/akka-grpc-gradle-plugin/

eshepelyuk commented 4 years ago

Well, I am testing the latest version ( including my changes) and it seems I've introduced another plugin application bug.

eshepelyuk commented 4 years ago

@raboof @ignasi35 I will provide a PR for fixing this issues and a regression I've introduced in my previous PR. Fix seems working - need to refactor tests for a plugin.

eshepelyuk commented 4 years ago

Created #1054

raboof commented 4 years ago

Looks like this should now be fixed on master, tested with akka-grpc snapshot version 1.0.0-24-1ff30e97 (adding the snapshot repository to the gradle build as maven { url 'http://dl.bintray.com/akka/snapshots' })

@eshepelyuk do you want to do a final test before we close this issue (and perhaps release akka-grpc 1.0.1 to get this improvement out there)?

eshepelyuk commented 4 years ago

Already did some testing and auto tests are passing too. Seems like working now.

raboof commented 4 years ago

Great, thanks for this great work!

Chr1stian commented 4 years ago

Hi again,

Thanks for the effort @eshepelyuk , might be something I am doing wrong, but DSL seems to still not be working for my project.

After adding id "com.lightbend.akka.grpc.gradle" version "1.0.0-25-716e655d" to plugins I get the following error when building gradle:

A problem occurred configuring root project 'my-project-name'.
> Could not resolve all dependencies for configuration ':compileClasspathCopy'.
raboof commented 4 years ago

You likely have to add the snapshot repository to be able to fetch the libraries:

maven { url 'http://dl.bintray.com/akka/snapshots' }
Chr1stian commented 4 years ago
repositories {
    maven {
        url 'http://dl.bintray.com/akka/snapshots'
    }
    jcenter()
}

Still same error :/

raboof commented 4 years ago

That's weird, the quickstart seems to work for me. Can you share the complete output?

eshepelyuk commented 4 years ago

This worked for me ( modified plugin-tester-scala )

plugins {
  id "com.lightbend.akka.grpc.gradle" version "1.0.0-29-572f9dc1"
}

akkaGrpc {
  serverPowerApis = true // This isn't default
}

repositories {
  mavenCentral()
  maven {
    url "https://dl.bintray.com/akka/snapshots" 
  }
}

def scalaBinaryVersion = "2.12"

dependencies {
  implementation group: 'ch.megard', name: "akka-http-cors_${scalaBinaryVersion}", version: '0.4.2'
  testImplementation "com.typesafe.akka:akka-stream-testkit_${scalaBinaryVersion}:2.5.31"
  testImplementation "org.scalatest:scalatest_${scalaBinaryVersion}:3.1.2"
  testImplementation "org.scalatestplus:junit-4-12_${scalaBinaryVersion}:3.1.2.0"
}
eshepelyuk commented 4 years ago

@raboof I got a proposal - plugin may analyze its version and automatically add akka snapshot repository to the project repositories for version resolution.

It will remove a need to boilerplate this piece of build file when trying to use snapshot versions.

  maven {
    url "https://dl.bintray.com/akka/snapshots" 
  }
Chr1stian commented 4 years ago

Thanks guys! 🥇 I could not share the entire output as there are some privacy concerns for my company, sorry about that. If I had posted it you could probably have told me what the issue was at once :p I just had to specify the repository for some local/JFrog plugins/dependencies and all is fine. Thanks again! Looking forward to a new full release with the fix included 👍

raboof commented 4 years ago

@raboof I got a proposal - plugin may analyze its version and automatically add akka snapshot repository to the project repositories for version resolution.

It will remove a need to boilerplate this piece of build file when trying to use snapshot versions.

  maven {
    url "https://dl.bintray.com/akka/snapshots" 
  }

That sounds great to me!

raboof commented 4 years ago

Thanks guys! 1st_place_medal I could not share the entire output as there are some privacy concerns for my company

Makes sense!

I just had to specify the repository for some local/JFrog plugins/dependencies and all is fine. Thanks again! Looking forward to a new full release with the fix included +1

Thanks for validating! I'll be happy to cut a 1.0.1 version soon - @eshepelyuk is there anything more you'd like to get in there before I do?

eshepelyuk commented 4 years ago

Thanks for validating! I'll be happy to cut a 1.0.1 version soon - @eshepelyuk is there anything more you'd like to get in there before I do?

yes - I would like to cleanup that thing with publishToMavenLocal in Travis CI pipeline. And implement consistent approach for both java and scala projects. Also docs update.