Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gradle Plugin to 7.4.2 + Fix Overflowing Poetry #257

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ast/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'kotlin-kapt'
id 'com.vanniktech.maven.publish'
}

apply plugin: 'kotlin-kapt'

sourceCompatibility = 1.8
kotlin {
jvmToolchain(11)
}

dependencies {
implementation deps.kotlin.stdlib
Expand All @@ -14,5 +16,3 @@ dependencies {
testImplementation deps.test.junit
testImplementation deps.test.truth
}

apply plugin: 'com.vanniktech.maven.publish'
11 changes: 5 additions & 6 deletions compiler/ast/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'kotlin-kapt'
id 'com.vanniktech.maven.publish'
}

apply plugin: 'kotlin-kapt'

sourceCompatibility = 1.8

kotlin {
jvmToolchain(11)
}

dependencies {
implementation deps.kotlin.stdlib
Expand All @@ -22,5 +23,3 @@ dependencies {
testImplementation deps.test.compileTesting
testImplementation deps.test.roomCompilerProcessingTesting
}

apply plugin: 'com.vanniktech.maven.publish'
7 changes: 4 additions & 3 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'com.vanniktech.maven.publish'
}

sourceCompatibility = 1.8
kotlin {
jvmToolchain(11)
}

dependencies {
implementation deps.kotlin.stdlib
Expand Down Expand Up @@ -35,5 +38,3 @@ dependencies {
test {
inputs.files(file("$rootDir/tests/src"))
}

apply plugin: 'com.vanniktech.maven.publish'
7 changes: 4 additions & 3 deletions compiler/ksp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'com.vanniktech.maven.publish'
}

sourceCompatibility = 1.8
kotlin {
jvmToolchain(11)
}

dependencies {
implementation deps.kotlin.stdlib
Expand All @@ -27,5 +30,3 @@ dependencies {
testImplementation deps.test.compileTesting
testImplementation deps.test.compileTestingKotlin
}

apply plugin: 'com.vanniktech.maven.publish'
28 changes: 8 additions & 20 deletions compiler/src/main/kotlin/motif/compiler/XFunSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ import com.squareup.kotlinpoet.AnnotationSpec
import com.squareup.kotlinpoet.FunSpec
import com.squareup.kotlinpoet.KModifier
import com.squareup.kotlinpoet.ParameterSpec
import com.squareup.kotlinpoet.javapoet.KotlinPoetJavaPoetPreview
import com.squareup.kotlinpoet.javapoet.toKTypeName
import com.uber.xprocessing.ext.modifiers
import javax.lang.model.element.Modifier
import motif.compiler.KotlinTypeWorkaround.javaToKotlinType

@OptIn(KotlinPoetJavaPoetPreview::class)
object XFunSpec {
/** Copied from [FunSpec.overriding] and modified to leverage [javaToKotlinType]& XProcessing. */
fun overriding(
Expand All @@ -50,23 +47,13 @@ object XFunSpec {
env.requireType(method.returnType.typeName)
}

val builder = overriding(methodElement)
builder.returns(javaToKotlinType(returnType))

var i = 0
val size = builder.parameters.size
val resolvedParameterTypes = method.parameterTypes
while (i < size) {
val parameter = builder.parameters[i]
val type = javaToKotlinType(resolvedParameterTypes[i])
Copy link
Contributor Author

@davissuber davissuber Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the real type we want, but we can only get it from method (which has the enclosing generic context), but not methodElement (which has the unresolved T as type). Hence, we pass method.parameterTypes into the overriding function.

builder.parameters[i] = parameter.toBuilder(parameter.name, type).build()
i++
}

return builder
return overriding(methodElement, method.parameterTypes).returns(javaToKotlinType(returnType))
}

private fun overriding(method: XMethodElement): FunSpec.Builder {
private fun overriding(
method: XMethodElement,
resolvedParameterTypes: List<XType>
): FunSpec.Builder {
var modifiers: Set<Modifier> = method.modifiers.toMutableSet()
require(
Modifier.PRIVATE !in modifiers &&
Expand All @@ -90,9 +77,10 @@ object XFunSpec {
.forEach { funBuilder.addTypeVariable(it) }
*/

method.parameters.forEach {
method.parameters.forEachIndexed { index, parameter ->
funBuilder.addParameter(
ParameterSpec.builder(it.name, it.type.typeName.toKTypeName()).build())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This toKTypeName eventually creates an infinite loop somewhere in kotlin poet due to the unresolved type references itself in the generic type parameter.

ParameterSpec.builder(parameter.name, javaToKotlinType(resolvedParameterTypes[index]))
.build())
}
if (method.isVarArgs()) {
funBuilder.parameters[funBuilder.parameters.lastIndex] =
Expand Down
7 changes: 4 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'com.vanniktech.maven.publish'
}

sourceCompatibility = 1.8
kotlin {
jvmToolchain(11)
}

dependencies {
api project(':models')

implementation deps.kotlin.stdlib
}

apply plugin: 'com.vanniktech.maven.publish'
8 changes: 4 additions & 4 deletions errormessage/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'com.vanniktech.maven.publish'
}

sourceCompatibility = 1.8

kotlin {
jvmToolchain(11)
}

dependencies {
implementation deps.kotlin.stdlib
implementation project(':core')
}

apply plugin: 'com.vanniktech.maven.publish'
4 changes: 2 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ ext.deps = [
targetSdkVersion: 30,

gradlePlugins: [
android: 'com.android.tools.build:gradle:4.2.0',
android: 'com.android.tools.build:gradle:7.4.2',
kotlin: "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}",
ksp: "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:${versions.ksp}",
dokka: "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}",
mavenPublish: 'com.vanniktech:gradle-maven-publish-plugin:0.18.0',
spotless: "com.diffplug.spotless:spotless-plugin-gradle:5.11.0",
shadow: "com.github.jengelman.gradle.plugins:shadow:6.1.0",
shadow: "com.github.johnrengelman:shadow:8.1.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks questionable - but it is still the same library - upgrade is needed for the new gradle plugin version.

]
],
"kotlin": [
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 1 addition & 2 deletions intellij/ast/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id "org.jetbrains.intellij" version "1.15.0"
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'com.vanniktech.maven.publish'
}

intellij {
Expand Down Expand Up @@ -32,5 +33,3 @@ tasks {
enabled = false
}
}

apply plugin: 'com.vanniktech.maven.publish'
3 changes: 1 addition & 2 deletions intellij/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id "org.jetbrains.intellij" version "1.15.0"
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'com.vanniktech.maven.publish'
}

intellij {
Expand Down Expand Up @@ -42,5 +43,3 @@ tasks {
enabled = false
}
}

apply plugin: 'com.vanniktech.maven.publish'
7 changes: 4 additions & 3 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apply plugin: 'java-library'
plugins {
id 'java-library'
id 'com.vanniktech.maven.publish'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand All @@ -7,5 +10,3 @@ dependencies {
// Dagger is part of the API since we generate code which depends on Dagger's API in the consuming gradle module.
api deps.dagger
}

apply plugin: 'com.vanniktech.maven.publish'
11 changes: 5 additions & 6 deletions models/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'kotlin-kapt'
id 'com.vanniktech.maven.publish'
}

apply plugin: 'kotlin-kapt'

sourceCompatibility = 1.8

kotlin {
jvmToolchain(11)
}

dependencies {
api project(':ast')
Expand All @@ -19,5 +20,3 @@ dependencies {
testImplementation deps.test.truth
testImplementation deps.test.compileTesting
}

apply plugin: 'com.vanniktech.maven.publish'
8 changes: 6 additions & 2 deletions samples/sample-kotlin-ksp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ plugins {
id 'org.jetbrains.kotlin.android'
}

kotlin {
jvmToolchain(11)
}

android {
compileSdkVersion deps.build.compileSdkVersion
buildToolsVersion deps.build.buildToolsVersion
Expand All @@ -26,8 +30,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how useful these are, much of the code is already in kotlin.

targetCompatibility JavaVersion.VERSION_11
}

variantFilter { variant ->
Expand Down
12 changes: 8 additions & 4 deletions samples/sample-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}

kotlin {
jvmToolchain(11)
}
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion deps.build.compileSdkVersion
Expand All @@ -25,8 +29,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

variantFilter { variant ->
Expand Down
8 changes: 6 additions & 2 deletions samples/sample-lib-ksp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ plugins {
id 'org.jetbrains.kotlin.android'
}

kotlin {
jvmToolchain(11)
}

android {
namespace 'com.example.sample_lib_ksp'
compileSdkVersion deps.build.compileSdkVersion
Expand All @@ -26,8 +30,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

androidComponents {
Expand Down
11 changes: 6 additions & 5 deletions tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
plugins {
id 'com.google.devtools.ksp'
id 'java-library'
id 'kotlin'
id 'kotlin-kapt'
}

apply plugin: 'java-library'
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'

sourceCompatibility = 1.8
kotlin {
jvmToolchain(11)
}

kotlin {
sourceSets {
Expand Down
4 changes: 3 additions & 1 deletion tests/compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ plugins {
id 'org.jetbrains.kotlin.jvm'
}

sourceCompatibility = 1.8
kotlin {
jvmToolchain(11)
}

dependencies {
implementation deps.autoCommon
Expand Down
24 changes: 24 additions & 0 deletions tests/src/main/java/testcases/KT006_reference_self/Child.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2023 Uber Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package testcases.KT006_reference_self

@motif.Scope
interface Child {

@motif.Objects
abstract class Objects : ObjectComponent<Bar>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key ingredient of the repro case, that an Objects inherits a function that contains a self-referencing generic parameter


}
Loading