Skip to content

Commit

Permalink
Merge pull request #4 from gradle/gradle/restricted-dsl-demo-update
Browse files Browse the repository at this point in the history
Update Gradle wrapper, do some housekeeping in `DECLARATIVE_GRADLE.md`
  • Loading branch information
h0tk3y committed Mar 7, 2024
2 parents 9b18680 + ad1f2a4 commit 48e6cdb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
44 changes: 27 additions & 17 deletions DECLARATIVE_GRADLE.md
Expand Up @@ -15,17 +15,17 @@ You can simply build from the command line or import in Studio.

or import in Studio and use the `app` run configuration to run the app in an emulator.

You can then edit the [declarative settings file](./settings.gradle.something).
You can then edit the [declarative settings file](./settings.gradle.something) and [declarative build files](./feature/search/build.gradle.something).

## Restricted DSL
## Declarative DSL

* The `.gradle.something` extension name is temporary.

## Demonstration content

This demonstration includes [declarative settings files](#declarative-settings) and
[declarative build files](#declarative-build-files).
The Gradle distribution also exports the [restricted DSL schemas](#restricted-dsl-schemas) that
The Gradle distribution also exports the [declarative DSL schemas](#declarative-dsl-schemas) that
it uses to evaluate the files.

* The available models are currently taken from the current Gradle API.
Expand All @@ -46,6 +46,17 @@ Supported APIs in `settings.gradle.something`:
* (+ `val dependencyResolutionManagement`)
* `enableFeaturePreview(name: String)`

* `fun plugins(configure: PluginDependenciesSpec.() -> Unit)`

* `PluginDependenciesSpec`:
* `fun id(id: String): PluginDependencySpec`
* `fun kotlin(id: String): PluginDependencySpec` (this function is not in the Java API)
* The `alias` functions are not supported yet.

* `PluginDependencySpec`:
* `fun version(version: String?): PluginDependencySpec` (a builder function)
* `fun apply(apply: Boolean): PluginDependencySpec` (a builder function)

* `ProjectDescriptor`:
* `var name: String`

Expand Down Expand Up @@ -73,9 +84,6 @@ In command line builds, check the result with:
./gradlew :feature:search:dependencyInsight --configuration prodDebugCompileClasspath --dependency feature
```

Currently, only plugins and project dependencies are supported. Everything else has been
moved to convention plugins for now.

The plugins and the rest of a build file are interpreted in two separate steps, similar to
the other DSLs.

Expand All @@ -101,14 +109,12 @@ Supported APIs for project evaluation:
* `fun project(path: String): ProjectDependency`

* `DependencyHandler`:
* `fun api(dependency: ProjectDependency)`
* `fun compileOnly(dependency: ProjectDependency)`
* `fun implementation(dependency: ProjectDependency)`
* `fun testImplementation(dependency: ProjectDependency)`
* `fun androidTestImplementation(dependency: ProjectDependency)`
* These configurations are hardcoded for now.
* `fun <configurationName>(dependency: ProjectDependency)` where `<configurationName>` is any
of the names of the configurations registered in the project

* Extensions registered by the plugins, see https://github.com/h0tk3y/restricted-dsl-plugin-schema-demo

### Restricted DSL schemas
### Declarative DSL schemas

When the prototype evaluates declarative settings and build files, it constructs a schema used for
resolution and validation.
Expand All @@ -120,7 +126,11 @@ any dependency on their original types.
The schemas are serializable, and the current prototype always writes them to
`.gradle/restricted-schema` during the build.

There are three different schemas that you can find in those directories after a build:
* `settings.something.schema` for the `settings.gradle.something` file,
* `plugins.something.schema` for the plugins DSL in `build.gradle.something`, and
* `project.something.schema` for the rest of `build.gradle.something`.
There schemas that you can find in those directories after a build are:
* for `settings.gradle.something`:
* `settingsPluginManagement.something.schema` for `pluginManagement { ... }`
* `settingsPlugins.something.schema` for the plugins DSL, and
* `settings.something.schema` for the settings file content,
* for `build.gradle.something`:
* `plugins.something.schema` for the plugins DSL in `build.gradle.something`, and
* `project.something.schema` for the rest of `build.gradle.something`.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-8.8-20240303001623+0000-bin.zip
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-8.8-20240307004408+0000-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down

0 comments on commit 48e6cdb

Please sign in to comment.