Skip to content

Latest commit

 

History

History
132 lines (82 loc) · 4.42 KB

File metadata and controls

132 lines (82 loc) · 4.42 KB

Declarative Gradle - Unified Plugin Prototypes

This directory contains prototypes of plugins for JVM, Android, and KMP projects built using "unified" plugins that all utilize a similar model and are implemented using the Declarative DSL.

Currently, these different ecosystems still apply distinct plugins, but those plugins all share a common plugin-common dependency, which will gradually grow to contain more functionality.

Java

Sample Java projects live in the testbed-java-library and testbed-java-application directories.

These samples show the definition of a simple Java application and library that target a single version of Java.

To run the application, use:

> ./gradlew testbed-java-application:run

JVM

Sample Java projects live in the testbed-jvm-library and testbed-jvm-application directories.

These samples show the definition of a simple Java application and library that are implemented using a mix of Java 11 and Java 17 source code.

To run the application, use:

> ./gradlew testbed-java-application:run

Kotlin JVM

Sample Kotlin JVM projects live in the testbed-kotlin-jvm-library and testbed-kotlin-jvm-application directories.

These samples show the definition of a simple Kotlin JVM application and library that target a single version of Kotlin and Java.

To run the application, use:

> ./gradlew testbed-kotlin-jvm-application:run

Kotlin KMP

The sample Kotlin Multiplatform project lives in the testbed-kotlin-library and testbed-kotlin-application directories.

The unified-prototype/plugin-kmp plugin demonstrates creating extensions using the Declarative DSL, and loading the data from those extensions into the KMP project used by KGP.

The sample project demonstrates setting properties, using a common dependencies block, and adding dependencies to specific targets.

Implementation Notes

An Apache Commons dependency is used by the JVM code. A SQLDelight dependency is used by the JS code. The kotlinx.datetime multiplatform dep is used by common code.

The StandaloneKmpLibraryPlugin plugin works by using project.afterEvaluate to load data from the Declarative DSL extensions into KGP's model.

Limitations

The KMP example is currently limited, and does not support any targets other than nodeJs, jvm and macOsArm64.

Running

From the testbed-kotlin-application directory, run jvmRun using the Gradle wrapper in the parent directory:

cd testbed-kotlin-application
../gradlew jvmRun

Building

From the testbed-kotlin-application directory, run build using the Gradle wrapper in the parent directory:

cd testbed-kotlin-application
../gradlew build

to build the JS, JVM and KMP metadata jars for the example KMP project build in the testbed-kotlin-application/build/libs directory.

You can also build the JS and JVM libs separately:

cd testbed-kotlin-application
../gradlew jsJar
cd testbed-kotlin-application
../gradlew jvmJar

Android

Sample Android projects live in the testbed-android-library and testbed-android-application directories. The unified-prototype/plugin-android plugin demonstrates creating extensions using the Declarative DSL, and loading the data from those extensions into the Android project used by AGP.

The sample project demonstrates setting properties, using a common dependencies block, and adding dependencies to specific Android targets.

Implementation Notes

Guava is declared as an implementation dependency. The OKHttp dep is used by the release build type's implementation, and is not necessary for the debug variant.

Both plugin implementations work by using project.afterEvaluate to load data from the Declarative DSL extensions into AGP's model.

Limitations

The Android example is currently limited, and does not support many use cases such as adding tests or running the publish task. It requires JDK >= 17 to build.

Running

From the testbed-android-library or testbed-android-application directory, run build using the Gradle wrapper in the parent directory:

cd testbed-android-application
../gradlew build

to build debug and release aars for the example Android project build in the testbed-android/build/outputs/aar directory.

You can also build the Debug and Release variants separately:

gradlew :testbed-android-application:assembleDebug
gradlew :testbed-android-application:assembleRelease