Skip to content

Commit

Permalink
Merge pull request #122 from gradle/tt/prep-0.1.14-for-nia
Browse files Browse the repository at this point in the history
Comment out init project generation types
  • Loading branch information
tresat authored Sep 30, 2024
2 parents 88843d8 + 4da6f53 commit 3a89531
Show file tree
Hide file tree
Showing 17 changed files with 204 additions and 139 deletions.
2 changes: 1 addition & 1 deletion unified-prototype/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=512m
org.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=1g
android.useAndroidX=true
2 changes: 1 addition & 1 deletion unified-prototype/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-8.11-20240815222552+0000-bin.zip
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-8.11-20240927185041+0000-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Empty file.
28 changes: 14 additions & 14 deletions unified-prototype/kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ balanced-match@^1.0.0:
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

binary-extensions@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==
version "2.3.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522"
integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==

brace-expansion@^1.1.7:
version "1.1.11"
Expand All @@ -63,11 +63,11 @@ brace-expansion@^2.0.1:
balanced-match "^1.0.0"

braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"

browser-stdout@1.3.1:
version "1.3.1"
Expand Down Expand Up @@ -156,19 +156,19 @@ emoji-regex@^8.0.0:
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==

escalade@^3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27"
integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==
version "3.2.0"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5"
integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==

escape-string-regexp@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
* A {@link InitProjectSource} of project specifications for Android projects.
*/
@SuppressWarnings("UnstableApiUsage")
public final class AndroidProjectSource implements InitProjectSource {
@Override
public List<InitProjectSpec> getProjectSpecs() {
return List.of(
new StaticProjectSpec("android-application", "Declarative Android Application Project")
);
}

@Override
public Class<? extends InitProjectGenerator> getProjectGenerator() {
return StaticProjectGenerator.class;
}
}
public final class AndroidProjectSource {}
//implements InitProjectSource {
// @Override
// public List<InitProjectSpec> getProjectSpecs() {
// return List.of(
// new StaticProjectSpec("android-application", "Declarative Android Application Project")
// );
// }
//
// @Override
// public Class<? extends InitProjectGenerator> getProjectGenerator() {
// return StaticProjectGenerator.class;
// }
//}
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
package org.gradle.api.experimental.buildinit;

import org.gradle.api.file.Directory;
import org.gradle.buildinit.projectspecs.InitProjectConfig;
//import org.gradle.api.file.Directory;
//import org.gradle.buildinit.projectspecs.InitProjectConfig;
import org.gradle.buildinit.projectspecs.InitProjectGenerator;
import org.gradle.util.ResourceLoader;
//import org.gradle.util.ResourceLoader;

/**
* An {@link InitProjectGenerator} that generates a project from a static template packaged
* as resources files in the {@link #TEMPLATES_ROOT} directory.
*/
@SuppressWarnings("UnstableApiUsage")
public abstract class StaticProjectGenerator implements InitProjectGenerator {
private static final String TEMPLATES_ROOT = "templates";

@Override
public void generate(InitProjectConfig config, Directory projectDir) {
if (!(config.getProjectSpec() instanceof StaticProjectSpec projectSpec)) {
throw new IllegalArgumentException("Unknown project type: " + config.getProjectSpec().getDisplayName() + " (" + config.getProjectSpec().getClass().getName() + ")");
}

String templatePath = TEMPLATES_ROOT + "/" + projectSpec.getTemplatePath();
ResourceLoader resourceLoader = new ResourceLoader();

try {
resourceLoader.extractDirectoryFromResources(templatePath, projectDir.getAsFile());
} catch (Exception e) {
throw new RuntimeException("Error extracting resources for: '" + projectSpec.getDisplayName() + "' from: '" + templatePath + "'!", e);
}
}
}
public abstract class StaticProjectGenerator {}
//implements InitProjectGenerator {
// private static final String TEMPLATES_ROOT = "templates";
//
// @Override
// public void generate(InitProjectConfig config, Directory projectDir) {
// if (!(config.getProjectSpec() instanceof StaticProjectSpec projectSpec)) {
// throw new IllegalArgumentException("Unknown project type: " + config.getProjectSpec().getDisplayName() + " (" + config.getProjectSpec().getClass().getName() + ")");
// }
//
// String templatePath = TEMPLATES_ROOT + "/" + projectSpec.getTemplatePath();
// ResourceLoader resourceLoader = new ResourceLoader();
//
// try {
// resourceLoader.extractDirectoryFromResources(templatePath, projectDir.getAsFile());
// } catch (Exception e) {
// throw new RuntimeException("Error extracting resources for: '" + projectSpec.getDisplayName() + "' from: '" + templatePath + "'!", e);
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@
* using the {@link StaticProjectGenerator}
*/
@SuppressWarnings("UnstableApiUsage")
public final class StaticProjectSpec implements InitProjectSpec {
private final String templatePath;
private final String displayName;

public StaticProjectSpec(String templatePath, String displayName) {
this.templatePath = templatePath;
this.displayName = displayName;
}

@Override
public String getDisplayName() {
return displayName;
}

@Override
public List<InitProjectParameter<?>> getParameters() {
return Collections.emptyList();
}

public String getTemplatePath() {
return templatePath;
}
}
public final class StaticProjectSpec {}
//implements InitProjectSpec {
// private final String templatePath;
// private final String displayName;
//
// public StaticProjectSpec(String templatePath, String displayName) {
// this.templatePath = templatePath;
// this.displayName = displayName;
// }
//
// @Override
// public String getDisplayName() {
// return displayName;
// }
//
// @Override
// public List<InitProjectParameter<?>> getParameters() {
// return Collections.emptyList();
// }
//
// public String getTemplatePath() {
// return templatePath;
// }
//}
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package org.gradle.api.experimental.buildinit;

import java.util.List;
//import java.util.List;

import org.gradle.buildinit.projectspecs.InitProjectGenerator;
import org.gradle.buildinit.projectspecs.InitProjectSpec;
//import org.gradle.buildinit.projectspecs.InitProjectGenerator;
//import org.gradle.buildinit.projectspecs.InitProjectSpec;
import org.gradle.buildinit.projectspecs.InitProjectSource;

/**
* A {@link InitProjectSource} of project specifications for JVM projects.
*/
@SuppressWarnings("UnstableApiUsage")
public final class JVMProjectSource implements InitProjectSource {
@Override
public List<InitProjectSpec> getProjectSpecs() {
return List.of(
new StaticProjectSpec("java-application", "Declarative Java Application Project")
);
}

@Override
public Class<? extends InitProjectGenerator> getProjectGenerator() {
return StaticProjectGenerator.class;
}
}
public final class JVMProjectSource {}
//implements InitProjectSource {
// @Override
// public List<InitProjectSpec> getProjectSpecs() {
// return List.of(
// new StaticProjectSpec("java-application", "Declarative Java Application Project")
// );
// }
//
// @Override
// public Class<? extends InitProjectGenerator> getProjectGenerator() {
// return StaticProjectGenerator.class;
// }
//}
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package org.gradle.api.experimental.buildinit;

import org.gradle.buildinit.projectspecs.InitProjectGenerator;
//import org.gradle.buildinit.projectspecs.InitProjectGenerator;
import org.gradle.buildinit.projectspecs.InitProjectSource;
import org.gradle.buildinit.projectspecs.InitProjectSpec;
//import org.gradle.buildinit.projectspecs.InitProjectSpec;

import java.util.List;
//import java.util.List;

/**
* A {@link InitProjectSource} of project specifications for Kotlin (JVM) projects.
*/
@SuppressWarnings("UnstableApiUsage")
public final class KMPProjectSource implements InitProjectSource{
@Override
public List<InitProjectSpec> getProjectSpecs() {
return List.of(
new StaticProjectSpec("kotlin-application", "Declarative Kotlin (JVM) Application Project")
);
}

@Override
public Class<? extends InitProjectGenerator> getProjectGenerator() {
return StaticProjectGenerator.class;
}
}
public final class KMPProjectSource {}
// implements InitProjectSource {
// @Override
// public List<InitProjectSpec> getProjectSpecs() {
// return List.of(
// new StaticProjectSpec("kotlin-application", "Declarative Kotlin (JVM) Application Project")
// );
// }
//
// @Override
// public Class<? extends InitProjectGenerator> getProjectGenerator() {
// return StaticProjectGenerator.class;
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.gradle.api.experimental.common.HasCliExecutables;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Nested;
import org.gradle.declarative.dsl.model.annotations.Configuring;
import org.gradle.declarative.dsl.model.annotations.Restricted;
Expand All @@ -17,11 +18,17 @@ public interface KmpApplication extends HasApplicationDependencies, HasCliExecut
@Input
Property<String> getLanguageVersion();

@Internal
@Nested
KmpApplicationTargetContainer getTargets();
KmpApplicationTargetContainer getTargetsContainer();

@Nested
default StaticKmpApplicationTargets getTargets() {
return getTargetsContainer();
}

@Configuring
default void targets(Action<? super KmpApplicationTargetContainer> action) {
default void targets(Action<? super StaticKmpApplicationTargets> action) {
action.execute(getTargets());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
import org.gradle.api.Action;
import org.gradle.api.internal.CollectionCallbackActionDecorator;
import org.gradle.api.internal.DefaultPolymorphicDomainObjectContainer;
import org.gradle.declarative.dsl.model.annotations.Adding;
import org.gradle.declarative.dsl.model.annotations.Configuring;
import org.gradle.declarative.dsl.model.annotations.Restricted;
import org.gradle.internal.instantiation.InstantiatorFactory;
import org.gradle.internal.reflect.Instantiator;
import org.gradle.internal.service.ServiceRegistry;

import javax.inject.Inject;

@Restricted
public abstract class KmpApplicationTargetContainer extends DefaultPolymorphicDomainObjectContainer<KmpApplicationTarget> {
public abstract class KmpApplicationTargetContainer extends DefaultPolymorphicDomainObjectContainer<KmpApplicationTarget> implements StaticKmpApplicationTargets {
@Inject
public KmpApplicationTargetContainer(Instantiator instantiator, InstantiatorFactory instantiatorFactory, CollectionCallbackActionDecorator callbackDecorator, ServiceRegistry services) {
super(KmpApplicationTarget.class, instantiator, instantiatorFactory.decorateLenient(services), callbackDecorator);
Expand All @@ -22,34 +18,34 @@ public KmpApplicationTargetContainer(Instantiator instantiator, InstantiatorFact
registerBinding(KmpApplicationNativeTarget.class, KmpApplicationNativeTarget.class);
}

@Adding
@Override
public void jvm() {
maybeCreate("jvm", KmpApplicationJvmTarget.class);
}

@Configuring
@Override
public void jvm(Action<? super KmpApplicationJvmTarget> action) {
KmpApplicationJvmTarget target = maybeCreate("jvm", KmpApplicationJvmTarget.class);
action.execute(target);
}

@Adding
@Override
public void nodeJs() {
maybeCreate("nodeJs", KmpApplicationNodeJsTarget.class);
}

@Configuring
@Override
public void nodeJs(Action<? super KmpApplicationNodeJsTarget> action) {
KmpApplicationNodeJsTarget target = maybeCreate("nodeJs", KmpApplicationNodeJsTarget.class);
action.execute(target);
}

@Adding
@Override
public void macOsArm64() {
maybeCreate("macOsArm64", KmpApplicationNativeTarget.class);
}

@Configuring
@Override
public void macOsArm64(Action<? super KmpApplicationNativeTarget> action) {
KmpApplicationNativeTarget target = maybeCreate("macOsArm64", KmpApplicationNativeTarget.class);
action.execute(target);
Expand Down
Loading

0 comments on commit 3a89531

Please sign in to comment.