Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Aug 19, 2024
1 parent b53c618 commit f94bb37
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 80 deletions.
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ allprojects {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
}

configurations.all {
val conf = this
conf.resolutionStrategy.eachDependency {
if (requested.group == "dev.kord.codegen") {
when (requested.name) {
"kotlinpoet" -> useVersion("main-20240811.165308-18")
"ksp" -> useVersion("main-20240811.165308-20")
}
}
}
}
}

subprojects {
Expand All @@ -22,3 +34,4 @@ tasks {
outputDirectory = layout.projectDirectory.dir("docs/api")
}
}

6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ ksp-api = { group = "com.google.devtools.ksp", name = "symbol-processing-api", v
kotlinpoet = { group = "com.squareup", name = "kotlinpoet-jvm", version.ref = "kotlinpoet" }
kotlinpoet-ksp = { group = "com.squareup", name = "kotlinpoet-ksp", version.ref = "kotlinpoet" }

codegen-kotlinpoet = { group = "dev.kord.codegen", name = "kotlinpoet", version = "main-20230912.212936-5" }
codegen-ksp = { group = "dev.kord.codegen", name = "ksp", version = "main-20230912.211940-5" }
codegen-ksp-processor = { group = "dev.kord.codegen", name = "ksp-processor", version = "main-20230912.211940-7" }
codegen-kotlinpoet = { group = "dev.kord.codegen", name = "kotlinpoet", version = "main-20240811.165308-18" }
codegen-ksp = { group = "dev.kord.codegen", name = "ksp", version = "main-20240811.165308-20" }
codegen-ksp-processor = { group = "dev.kord.codegen", name = "ksp-processor", version = "main-20240811.165308-19" }

mockk = { group = "io.mockk", name = "mockk", version = "1.13.12" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public inline fun Annotatable.Builder<*>.addAnnotation(type: KClass<out Annotati
return AnnotationSpec(type, block).also(::addAnnotation)
}

@DelicateKotlinPoetApi(message =
"Mirror APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
public fun Annotatable.Builder<*>.addAnnotation(`annotation`: AnnotationMirror): AnnotationSpec =
AnnotationSpec(`annotation`).also(::addAnnotation)

@DelicateKotlinPoetApi(message =
"Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
public fun Annotatable.Builder<*>.addAnnotation(`annotation`: Annotation,
includeDefaultValues: Boolean = false): AnnotationSpec = AnnotationSpec(`annotation`,
includeDefaultValues).also(::addAnnotation)

@DelicateKotlinPoetApi(message =
"Mirror APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
public fun Annotatable.Builder<*>.addAnnotation(`annotation`: AnnotationMirror): AnnotationSpec =
AnnotationSpec(`annotation`).also(::addAnnotation)
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public inline fun TypeSpec.Builder.addConstructor(block: FunSpecBuilderScope = {
return FunSpec.`constructor`(block).also(::addFunction)
}

public inline fun MemberSpecHolder.Builder<*>.addFunction(memberName: MemberName,
block: FunSpecBuilderScope = {}): FunSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return FunSpec(memberName, block).also(::addFunction)
}

public inline fun MemberSpecHolder.Builder<*>.addFunction(name: String, block: FunSpecBuilderScope =
{}): FunSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return FunSpec(name, block).also(::addFunction)
}

public inline fun MemberSpecHolder.Builder<*>.addFunction(memberName: MemberName,
block: FunSpecBuilderScope = {}): FunSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return FunSpec(memberName, block).also(::addFunction)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ public fun FunSpec.Builder.addParameter(

public inline fun FunSpec.Builder.addParameter(
name: String,
type: TypeName,
modifiers: Iterable<KModifier>,
type: Type,
vararg modifiers: KModifier,
block: ParameterSpecBuilderScope = {},
): ParameterSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return ParameterSpec(name, type, modifiers, block).also(::addParameter)
return ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter)
}

public fun FunSpec.Builder.addParameter(
type: TypeName,
modifiers: Iterable<KModifier>,
type: Type,
vararg modifiers: KModifier,
block: ParameterSpecBuilderScope = {},
): SubSpecDelegateProvider<ParameterSpec> = produceByName { name ->
ParameterSpec(name, type, modifiers, block).also(::addParameter)
ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter)
}

public inline fun FunSpec.Builder.addParameter(
name: String,
type: Type,
type: KClass<*>,
vararg modifiers: KModifier,
block: ParameterSpecBuilderScope = {},
): ParameterSpec {
Expand All @@ -60,7 +60,7 @@ public inline fun FunSpec.Builder.addParameter(
}

public fun FunSpec.Builder.addParameter(
type: Type,
type: KClass<*>,
vararg modifiers: KModifier,
block: ParameterSpecBuilderScope = {},
): SubSpecDelegateProvider<ParameterSpec> = produceByName { name ->
Expand All @@ -69,7 +69,7 @@ public fun FunSpec.Builder.addParameter(

public inline fun FunSpec.Builder.addParameter(
name: String,
type: Type,
type: TypeName,
modifiers: Iterable<KModifier>,
block: ParameterSpecBuilderScope = {},
): ParameterSpec {
Expand All @@ -78,7 +78,7 @@ public inline fun FunSpec.Builder.addParameter(
}

public fun FunSpec.Builder.addParameter(
type: Type,
type: TypeName,
modifiers: Iterable<KModifier>,
block: ParameterSpecBuilderScope = {},
): SubSpecDelegateProvider<ParameterSpec> = produceByName { name ->
Expand All @@ -87,20 +87,20 @@ public fun FunSpec.Builder.addParameter(

public inline fun FunSpec.Builder.addParameter(
name: String,
type: KClass<*>,
vararg modifiers: KModifier,
type: Type,
modifiers: Iterable<KModifier>,
block: ParameterSpecBuilderScope = {},
): ParameterSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter)
return ParameterSpec(name, type, modifiers, block).also(::addParameter)
}

public fun FunSpec.Builder.addParameter(
type: KClass<*>,
vararg modifiers: KModifier,
type: Type,
modifiers: Iterable<KModifier>,
block: ParameterSpecBuilderScope = {},
): SubSpecDelegateProvider<ParameterSpec> = produceByName { name ->
ParameterSpec(name, type, modifiers = modifiers, block).also(::addParameter)
ParameterSpec(name, type, modifiers, block).also(::addParameter)
}

public inline fun FunSpec.Builder.addParameter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ public fun MemberSpecHolder.Builder<*>.addProperty(

public inline fun MemberSpecHolder.Builder<*>.addProperty(
name: String,
type: TypeName,
modifiers: Iterable<KModifier>,
type: Type,
vararg modifiers: KModifier,
block: PropertySpecBuilderScope = {},
): PropertySpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return PropertySpec(name, type, modifiers, block).also(::addProperty)
return PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty)
}

public fun MemberSpecHolder.Builder<*>.addProperty(
type: TypeName,
modifiers: Iterable<KModifier>,
type: Type,
vararg modifiers: KModifier,
block: PropertySpecBuilderScope = {},
): SubSpecDelegateProvider<PropertySpec> = produceByName { name ->
PropertySpec(name, type, modifiers, block).also(::addProperty)
PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty)
}

public inline fun MemberSpecHolder.Builder<*>.addProperty(
name: String,
type: Type,
type: KClass<*>,
vararg modifiers: KModifier,
block: PropertySpecBuilderScope = {},
): PropertySpec {
Expand All @@ -59,51 +59,51 @@ public inline fun MemberSpecHolder.Builder<*>.addProperty(
}

public fun MemberSpecHolder.Builder<*>.addProperty(
type: Type,
type: KClass<*>,
vararg modifiers: KModifier,
block: PropertySpecBuilderScope = {},
): SubSpecDelegateProvider<PropertySpec> = produceByName { name ->
PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty)
}

@DelicateKotlinPoetApi(message =
"Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
public inline fun MemberSpecHolder.Builder<*>.addProperty(
name: String,
type: Type,
type: TypeName,
modifiers: Iterable<KModifier>,
block: PropertySpecBuilderScope = {},
): PropertySpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return PropertySpec(name, type, modifiers, block).also(::addProperty)
}

@DelicateKotlinPoetApi(message =
"Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
public fun MemberSpecHolder.Builder<*>.addProperty(
type: Type,
type: TypeName,
modifiers: Iterable<KModifier>,
block: PropertySpecBuilderScope = {},
): SubSpecDelegateProvider<PropertySpec> = produceByName { name ->
PropertySpec(name, type, modifiers, block).also(::addProperty)
}

@DelicateKotlinPoetApi(message =
"Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
public inline fun MemberSpecHolder.Builder<*>.addProperty(
name: String,
type: KClass<*>,
vararg modifiers: KModifier,
type: Type,
modifiers: Iterable<KModifier>,
block: PropertySpecBuilderScope = {},
): PropertySpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty)
return PropertySpec(name, type, modifiers, block).also(::addProperty)
}

@DelicateKotlinPoetApi(message =
"Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
public fun MemberSpecHolder.Builder<*>.addProperty(
type: KClass<*>,
vararg modifiers: KModifier,
type: Type,
modifiers: Iterable<KModifier>,
block: PropertySpecBuilderScope = {},
): SubSpecDelegateProvider<PropertySpec> = produceByName { name ->
PropertySpec(name, type, modifiers = modifiers, block).also(::addProperty)
PropertySpec(name, type, modifiers, block).also(::addProperty)
}

public inline fun MemberSpecHolder.Builder<*>.addProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@ import com.squareup.kotlinpoet.TypeSpecHolder
import kotlin.contracts.InvocationKind.EXACTLY_ONCE
import kotlin.contracts.contract

public inline fun TypeSpecHolder.Builder<*>.addAnnotationClass(className: ClassName,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.`annotation`(className, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addAnnotationClass(name: String,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.`annotation`(name, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addClass(className: ClassName,
public inline fun TypeSpecHolder.Builder<*>.addAnnotationClass(className: ClassName,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.`class`(className, block).also(::addType)
return TypeSpec.`annotation`(className, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addClass(name: String, block: TypeSpecBuilderScope =
Expand All @@ -31,16 +25,16 @@ public inline fun TypeSpecHolder.Builder<*>.addClass(name: String, block: TypeSp
return TypeSpec.`class`(name, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addCompanionObject(name: String? = null,
public inline fun TypeSpecHolder.Builder<*>.addClass(className: ClassName,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.companionObject(name, block).also(::addType)
return TypeSpec.`class`(className, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addEnum(className: ClassName,
public inline fun TypeSpecHolder.Builder<*>.addCompanionObject(name: String? = null,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.`enum`(className, block).also(::addType)
return TypeSpec.companionObject(name, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addEnum(name: String, block: TypeSpecBuilderScope = {}):
Expand All @@ -49,17 +43,10 @@ public inline fun TypeSpecHolder.Builder<*>.addEnum(name: String, block: TypeSpe
return TypeSpec.`enum`(name, block).also(::addType)
}

@Deprecated(
replaceWith = ReplaceWith(expression =
"TypeSpec.classBuilder(className).addModifiers(KModifier.EXPECT)"),
message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.",
level = DeprecationLevel.WARNING,
)
@Suppress(names = arrayOf("DEPRECATION"))
public inline fun TypeSpecHolder.Builder<*>.addExpectClass(className: ClassName,
public inline fun TypeSpecHolder.Builder<*>.addEnum(className: ClassName,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.expectClass(className, block).also(::addType)
return TypeSpec.`enum`(className, block).also(::addType)
}

@Deprecated(
Expand All @@ -75,10 +62,17 @@ public inline fun TypeSpecHolder.Builder<*>.addExpectClass(name: String, block:
return TypeSpec.expectClass(name, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addFunInterface(className: ClassName,
@Deprecated(
replaceWith = ReplaceWith(expression =
"TypeSpec.classBuilder(className).addModifiers(KModifier.EXPECT)"),
message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.",
level = DeprecationLevel.WARNING,
)
@Suppress(names = arrayOf("DEPRECATION"))
public inline fun TypeSpecHolder.Builder<*>.addExpectClass(className: ClassName,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.funInterface(className, block).also(::addType)
return TypeSpec.expectClass(className, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addFunInterface(name: String,
Expand All @@ -87,10 +81,10 @@ public inline fun TypeSpecHolder.Builder<*>.addFunInterface(name: String,
return TypeSpec.funInterface(name, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addInterface(className: ClassName,
public inline fun TypeSpecHolder.Builder<*>.addFunInterface(className: ClassName,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.`interface`(className, block).also(::addType)
return TypeSpec.funInterface(className, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addInterface(name: String, block: TypeSpecBuilderScope =
Expand All @@ -99,10 +93,10 @@ public inline fun TypeSpecHolder.Builder<*>.addInterface(name: String, block: Ty
return TypeSpec.`interface`(name, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addObject(className: ClassName,
public inline fun TypeSpecHolder.Builder<*>.addInterface(className: ClassName,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.`object`(className, block).also(::addType)
return TypeSpec.`interface`(className, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addObject(name: String, block: TypeSpecBuilderScope =
Expand All @@ -111,6 +105,12 @@ public inline fun TypeSpecHolder.Builder<*>.addObject(name: String, block: TypeS
return TypeSpec.`object`(name, block).also(::addType)
}

public inline fun TypeSpecHolder.Builder<*>.addObject(className: ClassName,
block: TypeSpecBuilderScope = {}): TypeSpec {
contract { callsInPlace(block, EXACTLY_ONCE) }
return TypeSpec.`object`(className, block).also(::addType)
}

@Deprecated(
replaceWith = ReplaceWith(expression =
"TypeSpec.classBuilder(name).addModifiers(KModifier.VALUE)"),
Expand Down
Loading

0 comments on commit f94bb37

Please sign in to comment.