Skip to content

Commit

Permalink
Fix Gradle publish task to work (#4961)
Browse files Browse the repository at this point in the history
Motivation:

`gradle publish` fails to publish because of illegal usage in `grpc-kotlin` without dependencies.

```
Task ':grpc-kotlin:kotlinSourcesJar' uses this output of task
':grpc-kotlin:generateProto' without declaring an explicit or
implicit dependency. This can lead to incorrect results being produced,
depending on what order the tasks are executed.
```
https://github.com/line/armeria/actions/runs/5275219571/jobs/9540456642#step:8:1415

Modifications:

- Make `kotlinSourcesJar` depend on `generateProto` and `copyAlpnAgent`

Result:

Publish artifacts to Maven Central
  • Loading branch information
ikhoon authored Jun 15, 2023
1 parent 9ee82c7 commit 27d8a9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions gradle/scripts/lib/java-rpc-proto.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ configure(projectsWithFlags('java')) {
sourcesJarTask.dependsOn(task)
}

def kotlinSourcesJar = tasks.findByName('kotlinSourcesJar')
if (kotlinSourcesJar) {
// A workaround for ':grpc-kotlin:kotlinSourcesJar' uses this output of task
// ':grpc-kotlin:generateProto' without declaring an explicit or implicit dependency.
kotlinSourcesJar.dependsOn(task)
}

def copyAlpnAgentTask= tasks.findByName('copyAlpnAgent')
if (copyAlpnAgentTask) {
// A workaround for ':generateProto' uses this output of task ':copyAlpnAgent' without
Expand Down
7 changes: 6 additions & 1 deletion gradle/scripts/lib/kotlin.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ configure(projectsWithFlags('kotlin')) {
def target = project.tasks.findByName('compileJava')?.targetCompatibility ?:
project.findProperty('javaTargetCompatibility') ?: '1.8'
def compilerArgs = ['-java-parameters', '-Xjsr305=strict', '-Xskip-prerelease-check']
def copyAlpnAgentTask = tasks.findByName("copyAlpnAgent")
// A workaround to find all Kotlin compilation tasks.
// The standard way, `tasks.withType(KotlinCompile)`, does not work here.
tasks.matching {
Expand All @@ -17,11 +18,15 @@ configure(projectsWithFlags('kotlin')) {
task.kotlinOptions.jvmTarget = target
task.kotlinOptions.freeCompilerArgs = compilerArgs

def copyAlpnAgentTask = tasks.findByName("copyAlpnAgent")
if (copyAlpnAgentTask != null) {
task.dependsOn(copyAlpnAgentTask)
}
}

def kotlinSourcesJar = tasks.findByName('kotlinSourcesJar')
if (kotlinSourcesJar != null && copyAlpnAgentTask != null) {
kotlinSourcesJar.dependsOn(copyAlpnAgentTask)
}
}

if (!rootProject.hasProperty('noLint')) {
Expand Down

0 comments on commit 27d8a9a

Please sign in to comment.