-
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.
implement compatibility support for gradle 4.10
- Loading branch information
1 parent
9d1da25
commit 6fe9209
Showing
6 changed files
with
42 additions
and
10 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,4 +159,5 @@ class Utils { | |
} | ||
} | ||
} | ||
|
||
} |
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