Skip to content

Commit

Permalink
Split init templates from plugin-android to plugin-android-init
Browse files Browse the repository at this point in the history
  • Loading branch information
big-guy committed Oct 30, 2024
1 parent b55a58b commit 86eddd2
Show file tree
Hide file tree
Showing 99 changed files with 56 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ gradlePlugin {
testSourceSets(project.sourceSets.getByName("integTest"))

plugins {
create("android-ecosystem") {
id = "org.gradle.experimental.android-ecosystem"
create("android-init") {
id = "org.gradle.experimental.android-ecosystem-init"
displayName = "Android Ecosystem Experimental Declarative Plugin"
description = "Experimental declarative plugin for the Android ecosystem"
implementationClass = "org.gradle.api.experimental.android.AndroidEcosystemPlugin"
tags = setOf("declarative-gradle", "android")
implementationClass = "org.gradle.api.experimental.android.AndroidEcosystemInitPlugin"
tags = setOf("declarative-gradle", "android", "init")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.gradle.api.experimental.android;

import org.gradle.api.Plugin;
import org.gradle.api.experimental.buildinit.StaticProjectGenerator;
import org.gradle.api.experimental.buildinit.StaticProjectSpec;
import org.gradle.api.initialization.Settings;
import org.gradle.buildinit.specs.internal.BuildInitSpecRegistry;

import javax.inject.Inject;
import java.util.List;

@SuppressWarnings("UnstableApiUsage")
public abstract class AndroidEcosystemInitPlugin implements Plugin<Settings> {
@Override
public void apply(Settings settings) {
// TODO: Add something for generating AGP-based templates
getBuildInitSpecRegistry().register(StaticProjectGenerator.class, List.of(
new StaticProjectSpec("android-application", "Declarative Android Application Project"),
new StaticProjectSpec("android-application-basic-activity", "Declarative Android Application Project with Basic Activity"),
new StaticProjectSpec("android-application-empty-activity", "Declarative Android Application Project with Empty Activity")
));
}

@Inject
protected abstract BuildInitSpecRegistry getBuildInitSpecRegistry();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
api(libs.android.kotlin.android)

implementation(project(":plugin-jvm"))
implementation(project(":plugin-android-init"))
implementation(libs.baseline.profile.plugin)
implementation(libs.dependency.guard.plugin)
implementation(libs.ksp.plugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,26 @@
import org.gradle.api.Plugin;
import org.gradle.api.experimental.android.application.StandaloneAndroidApplicationPlugin;
import org.gradle.api.experimental.android.library.StandaloneAndroidLibraryPlugin;
import org.gradle.api.experimental.buildinit.AbstractSpecContributingPlugin;
import org.gradle.api.experimental.buildinit.StaticProjectGenerator;
import org.gradle.api.experimental.buildinit.StaticProjectSpec;
import org.gradle.api.experimental.jvm.JvmEcosystemConventionsPlugin;
import org.gradle.api.initialization.Settings;
import org.gradle.api.internal.plugins.software.RegistersSoftwareTypes;
import org.gradle.buildinit.specs.BuildInitSpec;
import org.gradle.buildinit.specs.internal.BuildInitSpecRegistry;

import javax.inject.Inject;
import java.util.List;

@SuppressWarnings("UnstableApiUsage")
@RegistersSoftwareTypes({StandaloneAndroidApplicationPlugin.class, StandaloneAndroidLibraryPlugin.class})
public abstract class AndroidEcosystemPlugin extends AbstractSpecContributingPlugin implements Plugin<Settings> {
public abstract class AndroidEcosystemPlugin implements Plugin<Settings> {
@Override
public void apply(Settings target) {
registerSpecs();
target.getPlugins().apply("org.gradle.experimental.android-ecosystem-init");
target.getPlugins().apply(JvmEcosystemConventionsPlugin.class);
target.getDependencyResolutionManagement().getRepositories().google();
}

@Override
protected List<BuildInitSpec> getSpecs() {
return List.of(
new StaticProjectSpec("android-application", "Declarative Android Application Project"),
new StaticProjectSpec("android-application-basic-activity", "Declarative Android Application Project with Basic Activity"),
new StaticProjectSpec("android-application-empty-activity", "Declarative Android Application Project with Empty Activity")
);
}
@Inject
protected abstract BuildInitSpecRegistry getBuildInitSpecRegistry();
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.gradle.api.experimental.jvm;

import org.gradle.api.Plugin;
import org.gradle.api.experimental.buildinit.AbstractSpecContributingPlugin;
import org.gradle.api.experimental.buildinit.StaticProjectGenerator;
import org.gradle.api.experimental.buildinit.StaticProjectSpec;
import org.gradle.api.experimental.java.StandaloneJavaApplicationPlugin;
import org.gradle.api.experimental.java.StandaloneJavaLibraryPlugin;
import org.gradle.api.initialization.Settings;
import org.gradle.api.internal.plugins.software.RegistersSoftwareTypes;
import org.gradle.buildinit.specs.BuildInitSpec;
import org.gradle.buildinit.specs.internal.BuildInitSpecRegistry;

import javax.inject.Inject;
import java.util.List;

@SuppressWarnings("UnstableApiUsage")
Expand All @@ -18,17 +19,15 @@
StandaloneJvmLibraryPlugin.class,
StandaloneJvmApplicationPlugin.class
})
public abstract class JvmEcosystemPlugin extends AbstractSpecContributingPlugin implements Plugin<Settings> {
public abstract class JvmEcosystemPlugin implements Plugin<Settings> {
@Override
public void apply(Settings target) {
registerSpecs();
getBuildInitSpecRegistry().register(StaticProjectGenerator.class, List.of(
new StaticProjectSpec("java-application", "Declarative Java Application Project")
));
target.getPlugins().apply(JvmEcosystemConventionsPlugin.class);
}

@Override
protected List<BuildInitSpec> getSpecs() {
return List.of(
new StaticProjectSpec("java-application", "Declarative Java Application Project")
);
}
@Inject
protected abstract BuildInitSpecRegistry getBuildInitSpecRegistry();
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package org.gradle.api.experimental.kmp;

import org.gradle.api.Plugin;
import org.gradle.api.experimental.buildinit.AbstractSpecContributingPlugin;
import org.gradle.api.experimental.buildinit.StaticProjectGenerator;
import org.gradle.api.experimental.buildinit.StaticProjectSpec;
import org.gradle.api.experimental.jvm.JvmEcosystemConventionsPlugin;
import org.gradle.api.experimental.kotlin.StandaloneKotlinJvmApplicationPlugin;
import org.gradle.api.experimental.kotlin.StandaloneKotlinJvmLibraryPlugin;
import org.gradle.api.initialization.Settings;
import org.gradle.api.internal.plugins.software.RegistersSoftwareTypes;
import org.gradle.buildinit.specs.BuildInitSpec;
import org.gradle.buildinit.specs.internal.BuildInitSpecRegistry;

import javax.inject.Inject;
import java.util.List;


Expand All @@ -19,17 +20,15 @@
StandaloneKmpApplicationPlugin.class,
StandaloneKotlinJvmLibraryPlugin.class,
StandaloneKotlinJvmApplicationPlugin.class})
public abstract class KmpEcosystemPlugin extends AbstractSpecContributingPlugin implements Plugin<Settings> {
public abstract class KmpEcosystemPlugin implements Plugin<Settings> {
@Override
public void apply(Settings target) {
registerSpecs();
getBuildInitSpecRegistry().register(StaticProjectGenerator.class, List.of(
new StaticProjectSpec("kotlin-application", "Declarative Kotlin (JVM) Application Project")
));
target.getPlugins().apply(JvmEcosystemConventionsPlugin.class);
}

@Override
protected List<BuildInitSpec> getSpecs() {
return List.of(
new StaticProjectSpec("kotlin-application", "Declarative Kotlin (JVM) Application Project")
);
}
@Inject
protected abstract BuildInitSpecRegistry getBuildInitSpecRegistry();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public void apply(Project project) {

project.getPlugins().apply("org.jetbrains.kotlin.jvm");

// Setup Linting conventions
dslModel.getLint().getEnabled().convention(false);
dslModel.getLint().getXmlReport().convention(false);
dslModel.getLint().getCheckDependencies().convention(false);

linkDslModelToPlugin(project, dslModel);
}

Expand Down

0 comments on commit 86eddd2

Please sign in to comment.