-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to stable Kotlin DSL 1.0.4 (included in Gradle 5.0) (#275)
This makes the Kotlin support compatible with Gradle 5.0. Compatibility with Gradle 4.10 is kept.
- Loading branch information
1 parent
50c6e65
commit 1a64a64
Showing
8 changed files
with
178 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+1.72 KB
(100%)
examples/exampleKotlinDslProject/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
34 changes: 34 additions & 0 deletions
34
src/main/groovy/com/google/protobuf/gradle/KtDslCompatibilityUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.google.protobuf.gradle; | ||
|
||
import kotlin.Unit; | ||
import kotlin.jvm.functions.Function1; | ||
import org.gradle.api.NamedDomainObjectContainer; | ||
import org.gradle.kotlin.dsl.NamedDomainObjectContainerExtensionsKt; | ||
import org.gradle.kotlin.dsl.NamedDomainObjectContainerScope; | ||
|
||
public class KtDslCompatibilityUtils { | ||
|
||
/** | ||
* This method is used to delegate the NamedDomainObjectContainer configuration to | ||
* to which ever kotlin-dsl ext implementation is available on the classpath. | ||
* | ||
* Since NamedDomainObjectContainerExtensionsKt.invoke is an inline extension function, our | ||
* usages in 'ProtobufConfiguratorExts.kt' would use the byte code for which ever kotlin-dsl | ||
* version we compiled against. This caused issues with providing compatibility with | ||
* kotlin-dsl 1.0.0-rc3 and 1.0.4 (Stable). | ||
* | ||
* Since the kotlin compiler creates a static implementations of all extensions, we can create a | ||
* delegating utility function that ensures we are not inline-ing our kotlin-dsl compilation | ||
* target byte code. | ||
* | ||
* @param container Container to apply the scope configuration | ||
* @param block A kotlin lambda to apply to the NamedDomainObjectContainerScope | ||
* @return A NamedDomainObjectContainer with the block lambda applied to is NamedDomainObjectContainerScope | ||
*/ | ||
static <T> NamedDomainObjectContainer<T> configureNamedDomainObjectContainer( | ||
NamedDomainObjectContainer<T> container, | ||
Function1<? super NamedDomainObjectContainerScope<T>, Unit> block){ | ||
|
||
return NamedDomainObjectContainerExtensionsKt.invoke(container, block); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters