google / google/protobuf-gradle-plugin
GenerateProto depends on compile tasks
- Dominant language
- Groovy
- Stars
- 1.8k
- Forks
- 288
- PR merge metrics
- No merged PRs in 30d
Description
**Background**
Test project structure ([link](https://github.com/rougsig/protobuf-gradle-plugin-compile)):
```
├── instances
│ ├── app
├── work-with-proto
│ ├── implementation pure-kotlin
│ │ ├── api lib-core
│ ├── implementation pure-java
│ ├── implementation proto-kotlin
│ │ ├── api lib-core
│ ├── implementation proto-java
│ ├── implementation pure-android
│ ├── implementation proto-android
```
`:generateProto` executed a bunch of unnecessary tasks:
`:lib-core:compileJava`, `:proto-android:compileDebugJavaWithJavac`, `:proto-java:compileJava`,
`:proto-kotlin:compileKotlin`, `:proto-kotlin:compileJava`, `:pure-android:compileDebugJavaWithJavac`,
`:pure-java:compileJava`, `:pure-kotlin:compileKotlin`, `:pure-kotlin:compileJava`
It just compile all dependencies, without any reason.
**How it works now**
Protobuf gradle plugin create `compileProtoPath` configuration that extends from `implementation` and `compileOnly`.
It's quite user-friendly, because all you project dependencies provides proto files by default. No need to duplication dependency for `compileProtoPath` configuration.
i.e.
```
dependencies {
implementation project(":with-proto")
// no need write string below.
// compileProtoPath configuration will take all implementation dependencies automatically.
// compileProtoPath project(":with-proto")
}
```
**What wrong**
[Gradle scan](https://scans.gradle.com/s/or2wn7tq5m56w) from test project for generate proto task.
Generate proto task resolves `compileProtoPath` configuration. `compileProtoPath` configuration resolves `implementation` and `compileOnly` configuration. As result we have compiled or downloaded all project's dependencies.
This is not good. It costs build time a lot. (that looks real, if project have a lot of dependencies https://github.com/google/protobuf-gradle-plugin/issues/551).
**Expected result**
Generate proto task does not compile and download all of the project's dependencies. It should only work with dependencies marked as path dependencies.
**Changes**
The `compileProtoPath` configuration does not extends from `implementation` and `compileOnly` configurations.
**Breaking changes**
If `compileProtoPath` configuration does not extends from `implementation` and `compileOnly` configurations, user should declarate all dependencies for generate proto task with `compileProtoPath` configuration. i.e.
```
dependencies {
implementation project(":with-proto")
// User should add all path dependencies with compileProtoPath configuration.
compileProtoPath project(":with-proto")
}
```
Contributor guide
Research direction
Inspect how the plugin creates the compileProtoPath configuration and how generateProto resolves it. Reproduce the behavior with the linked test project, then verify that generation resolves only explicitly declared path dependencies rather than implementation and compileOnly dependencies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java, kotlin
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100