Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo failure #31

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
!/.idea/icon.png
!/.idea/icon_dark.png
*/**/.idea

.kotlin/
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,16 @@ Building release distributables will fail if the required JDK tools are not avai

```shell
# Run from sources
./gradlew :gradle-client:run
./gradlew :gradle-client:jvmRun

# Run from sources in continuous mode
./gradlew -t :gradle-client:run
./gradlew -t :gradle-client:jmvRun

# TODO: Not working?
# Run debug build type from build installation
./gradlew :gradle-client:runDistributable

# TODO: Not working?
# Run release build type from build installation
./gradlew :gradle-client:runReleaseDistributable
```
Expand Down
9 changes: 9 additions & 0 deletions build-action/build.gradle.dcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
javaLibrary {
javaVersion = 8

dependencies {
// TODO: Update these to current versions
implementation("org.gradle:gradle-tooling-api:8.12-20241009055624+0000")
implementation("org.gradle:gradle-declarative-dsl-tooling-models:8.12-20241009055624+0000")
}
}
14 changes: 0 additions & 14 deletions build-action/build.gradle.kts

This file was deleted.

4 changes: 0 additions & 4 deletions build.gradle.kts

This file was deleted.

27 changes: 27 additions & 0 deletions declarative-logic/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[versions]
compose-plugin = "1.6.11"
declarative = "0.1.38"
detekt = "1.23.6"
kotlin = "2.0.21"
sqldelight = "2.0.2"

[libraries]
declarative = { module = "org.gradle.experimental.kmp-ecosystem:org.gradle.experimental.kmp-ecosystem.gradle.plugin", version.ref = "declarative" }
detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
jetbrains-compose = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "compose-plugin" }
kotlin-compose = { module = "org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin", version.ref = "kotlin" }
kotlin-multiplatform = { module = "org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin", version.ref = "kotlin" }
kotlin-serialization = { module = "org.jetbrains.kotlin.plugin.serialization:org.jetbrains.kotlin.plugin.serialization.gradle.plugin", version.ref = "kotlin" }
sqldelight = { module = "app.cash.sqldelight:gradle-plugin", version.ref = "sqldelight" }
sqldelight-runtime = { module = "app.cash.sqldelight:runtime", version.ref = "sqldelight" }
sqldelight-extensions-coroutines = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sqldelight" }
sqldelight-driver-sqlite = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" }

[plugins]
declarative = { id = "org.gradle.client.ecosystem.custom-ecosystem", version.ref = "declarative" }
jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kmp-ecosystem = { id = "org.gradle.experimental.kmp-ecosystem", version.ref = "declarative" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }

36 changes: 36 additions & 0 deletions declarative-logic/plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// TODO: This file must unfortunately remain non-DCL, until we can create a new plugin project ecosystem type in the prototype
plugins {
id("java-gradle-plugin")
}

description = "Declarative plugins containing custom software types for the gradle-client project."

dependencies {
api(libs.declarative)
api(libs.kotlin.multiplatform)
api(libs.kotlin.serialization)
api(libs.kotlin.compose)
api(libs.jetbrains.compose)
api(libs.sqldelight)
api(libs.detekt)
}

gradlePlugin {
plugins {
create("custom-ecosystem") {
id = "org.gradle.client.ecosystem.custom-ecosystem"
implementationClass = "org.gradle.client.ecosystem.CustomEcosystemPlugin"
}

create("desktop-compose-application") {
id = "org.gradle.client.softwaretype.desktop-compose-application"
implementationClass = "org.gradle.client.softwaretype.CustomDesktopComposeApplicationPlugin"
}
}
}

// TODO: This is more properly done as part of the root level settings file, but isn't supported in DCL
// move this to daemon toolchain once Gradle supports it
require(JavaVersion.current() == JavaVersion.VERSION_17) {
"This build requires Java 17, currently using ${JavaVersion.current()}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.gradle.client.ecosystem;

import org.gradle.api.Plugin;
import org.gradle.api.initialization.Settings;
import org.gradle.api.internal.plugins.software.RegistersSoftwareTypes;
import org.gradle.client.softwaretype.CustomDesktopComposeApplicationPlugin;

@SuppressWarnings("UnstableApiUsage")
@RegistersSoftwareTypes({CustomDesktopComposeApplicationPlugin.class})
public abstract class CustomEcosystemPlugin implements Plugin<Settings> {
@Override
public void apply(Settings target) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Contains ecosystem plugins that define the {@link org.gradle.api.internal.plugins.software.SoftwareType SoftwareType}s
* used by this project .
*/
@org.gradle.api.NonNullApi
package org.gradle.client.ecosystem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.gradle.client.softwaretype;

import org.gradle.api.Action;
import org.gradle.api.experimental.kmp.KmpApplication;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Nested;
import org.gradle.client.softwaretype.compose.Compose;
import org.gradle.client.softwaretype.detekt.Detekt;
import org.gradle.client.softwaretype.sqldelight.SqlDelight;
import org.gradle.declarative.dsl.model.annotations.Configuring;
import org.gradle.declarative.dsl.model.annotations.Restricted;

public interface CustomDesktopComposeApplication {
@Restricted
Property<String> getGroup();

@Restricted
Property<String> getVersion();

@Nested
KmpApplication getKotlinApplication();

@Configuring
default void kotlinApplication(Action<? super KmpApplication> action) {
action.execute(getKotlinApplication());
}

@Nested
Compose getCompose();

@Configuring
default void compose(Action<? super Compose> action) {
action.execute(getCompose());
}

@Nested
SqlDelight getSqlDelight();

@Configuring
default void sqlDelight(Action<? super SqlDelight> action) {
action.execute(getSqlDelight());
}

@Nested
Detekt getDetekt();

@Configuring
default void detekt(Action<? super Detekt> action) {
action.execute(getDetekt());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.gradle.client.softwaretype;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.internal.plugins.software.SoftwareType;

import static org.gradle.api.experimental.kmp.StandaloneKmpApplicationPlugin.PluginWiring.wireKMPApplication;
import static org.gradle.client.softwaretype.compose.ComposeSupport.wireCompose;
import static org.gradle.client.softwaretype.detekt.DetektSupport.wireDetekt;
import static org.gradle.client.softwaretype.sqldelight.SqlDelightSupport.needToWireSqlDelight;
import static org.gradle.client.softwaretype.sqldelight.SqlDelightSupport.wireSqlDelight;

@SuppressWarnings("UnstableApiUsage")
public abstract class CustomDesktopComposeApplicationPlugin implements Plugin<Project> {
public static final String DESKTOP_COMPOSE_APP = "desktopComposeApp";

@SoftwareType(name = DESKTOP_COMPOSE_APP, modelPublicType = CustomDesktopComposeApplication.class)
public abstract CustomDesktopComposeApplication getDesktopComposeApp();

@Override
public void apply(Project project) {
CustomDesktopComposeApplication dslModel = getDesktopComposeApp();

project.setGroup(dslModel.getGroup());
project.setVersion(dslModel.getVersion());

wireKMPApplication(project, dslModel.getKotlinApplication());
project.getPlugins().apply("org.jetbrains.kotlin.plugin.serialization");

wireDetekt(project, dslModel.getDetekt());

/*
* It's necessary to defer checking the NDOC in our extension for contents until after project evaluation.
* If you move the check below outside of afterEvaluate, it fails. Inside, it succeeds.
* Without the afterEvaluate, the databases is seen as empty, and the plugin fails, with this warning:
* https://github.com/plangrid/sqldelight/blob/917cb8e5ee437d37bfdbdcbb3fded09b683fe826/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightPlugin.kt#L112
*/
project.afterEvaluate(p -> {
if (needToWireSqlDelight(dslModel)) {
wireSqlDelight(project, dslModel);
}
});

wireCompose(project, dslModel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.gradle.client.softwaretype.compose;

import org.gradle.api.Action;
import org.gradle.api.tasks.Nested;
import org.gradle.declarative.dsl.model.annotations.Configuring;
import org.gradle.declarative.dsl.model.annotations.Restricted;

public interface BuildType {
@Nested
Proguard getProguard();

@Configuring
default void proguard(Action<? super Proguard> action) {
action.execute(getProguard());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.gradle.client.softwaretype.compose;

import org.gradle.api.Action;
import org.gradle.api.tasks.Nested;
import org.gradle.declarative.dsl.model.annotations.Configuring;
import org.gradle.declarative.dsl.model.annotations.Restricted;

public interface BuildTypes {
@Nested
BuildType getRelease();

@Configuring
default void release(Action<? super BuildType> action) {
action.execute(getRelease());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.gradle.client.softwaretype.compose;

import org.gradle.api.Action;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Nested;
import org.gradle.declarative.dsl.model.annotations.Configuring;
import org.gradle.declarative.dsl.model.annotations.Restricted;

public interface Compose {
@Restricted
Property<String> getMainClass();

NamedDomainObjectContainer<JvmArg> getJvmArgs();

@Nested
BuildTypes getBuildTypes();

@Configuring
default void buildTypes(Action<? super BuildTypes> action) {
action.execute(getBuildTypes());
}

@Nested
NativeDistributions getNativeDistributions();

@Configuring
default void nativeDistributions(Action<? super NativeDistributions> action) {
action.execute(getNativeDistributions());
}
}
Loading
Loading