From e5a4c66652e331fd13d6365fc969277cb5bf9953 Mon Sep 17 00:00:00 2001 From: Tom Tresansky Date: Tue, 13 Aug 2024 08:56:13 -0400 Subject: [PATCH 1/3] Remove unnecessary debug output --- .../src/main/java/org/gradle/util/ResourceLoader.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/unified-prototype/unified-plugin/plugin-common/src/main/java/org/gradle/util/ResourceLoader.java b/unified-prototype/unified-plugin/plugin-common/src/main/java/org/gradle/util/ResourceLoader.java index a38e416a..beabedd4 100644 --- a/unified-prototype/unified-plugin/plugin-common/src/main/java/org/gradle/util/ResourceLoader.java +++ b/unified-prototype/unified-plugin/plugin-common/src/main/java/org/gradle/util/ResourceLoader.java @@ -30,7 +30,6 @@ public void extractResourcesFromJar(String relativePath, File destDir) throws IO throw new IllegalArgumentException("Directory: '" + relativePath + "' not found on classpath."); } JarFile jarFile = ((JarURLConnection) jarDirURL.openConnection()).getJarFile(); - System.out.println("Using URL: " + jarDirURL); Iterator iterator = jarFile.entries().asIterator(); while (iterator.hasNext()) { @@ -39,21 +38,15 @@ public void extractResourcesFromJar(String relativePath, File destDir) throws IO if (entryName.startsWith(relativePath)) { String entrySuffix = entryName.substring(relativePath.length()); - System.out.println("Entry: " + entry + " name: " + entryName + " suffix: " + entrySuffix); File destFile = new File(destDir, entrySuffix); - System.out.println("Dest file: " + destFile); if (entry.isDirectory()) { - System.out.println("Is directory"); FileUtils.forceMkdir(destFile); - System.out.println("Created directory"); } else { - System.out.println("Is file"); try (InputStream is = jarFile.getInputStream(entry); FileOutputStream fos = new FileOutputStream(destFile)) { IOUtils.copy(is, fos); } - System.out.println("Copied file"); } } } From 1084af2e0132a116c0d3d49a12be146b4ea3967c Mon Sep 17 00:00:00 2001 From: Tom Tresansky Date: Tue, 13 Aug 2024 09:53:18 -0400 Subject: [PATCH 2/3] Fix project templates to be valid --- .../templates/java-application/build.gradle.dcl | 3 --- .../templates/java-application/settings.gradle.dcl | 10 ++++++++++ .../src/main/java/com/example/App.java | 5 ----- .../resources/templates/java-library/build.gradle.dcl | 1 - .../templates/java-library/settings.gradle.dcl | 10 ++++++++++ 5 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/settings.gradle.dcl create mode 100644 unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-library/settings.gradle.dcl diff --git a/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/build.gradle.dcl b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/build.gradle.dcl index 866fbc68..0f6096bb 100644 --- a/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/build.gradle.dcl +++ b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/build.gradle.dcl @@ -1,12 +1,9 @@ -package templates.`java-application` - javaApplication { // compile for 17 javaVersion = 17 mainClass = "com.example.App" dependencies { - implementation(project(":java-util")) implementation("com.google.guava:guava:32.1.3-jre") } diff --git a/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/settings.gradle.dcl b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/settings.gradle.dcl new file mode 100644 index 00000000..b9e24938 --- /dev/null +++ b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/settings.gradle.dcl @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + google() // for Android plugin + gradlePluginPortal() + } +} + +plugins { + id("org.gradle.experimental.jvm-ecosystem") version "0.1.10" +} diff --git a/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/src/main/java/com/example/App.java b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/src/main/java/com/example/App.java index 4df68009..c533e573 100644 --- a/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/src/main/java/com/example/App.java +++ b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-application/src/main/java/com/example/App.java @@ -1,6 +1,5 @@ package com.example; -import com.example.utils.Utils; import com.google.common.collect.ImmutableList; public class App { @@ -9,10 +8,6 @@ public static void main(String[] args) { ImmutableList.Builder builder = ImmutableList.builder(); builder.add("Hello from Java " + System.getProperty("java.version")); - // Verify that the Java library is available - Utils utils = new Utils(); - builder.add(utils.getWelcome()); - ImmutableList messages = builder.build(); messages.forEach(System.out::println); } diff --git a/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-library/build.gradle.dcl b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-library/build.gradle.dcl index 1eecd518..22cc9c76 100644 --- a/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-library/build.gradle.dcl +++ b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-library/build.gradle.dcl @@ -2,7 +2,6 @@ javaLibrary { javaVersion = 21 dependencies { - implementation(project(":java-util")) implementation("com.google.guava:guava:32.1.3-jre") } } diff --git a/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-library/settings.gradle.dcl b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-library/settings.gradle.dcl new file mode 100644 index 00000000..b9e24938 --- /dev/null +++ b/unified-prototype/unified-plugin/plugin-jvm/src/main/resources/templates/java-library/settings.gradle.dcl @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + google() // for Android plugin + gradlePluginPortal() + } +} + +plugins { + id("org.gradle.experimental.jvm-ecosystem") version "0.1.10" +} From 20675152fb848a1e0a069fb49fceeeeb6e7795e1 Mon Sep 17 00:00:00 2001 From: Tom Tresansky Date: Wed, 14 Aug 2024 14:20:00 -0400 Subject: [PATCH 3/3] Update to latest version of Gradle, including refinements to project spec API --- unified-prototype/gradle/wrapper/gradle-wrapper.properties | 2 +- .../api/experimental/buildinit/StaticProjectGenerator.java | 2 +- .../gradle/api/experimental/buildinit/JVMProjectSource.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/unified-prototype/gradle/wrapper/gradle-wrapper.properties b/unified-prototype/gradle/wrapper/gradle-wrapper.properties index e63530c2..34dc8023 100644 --- a/unified-prototype/gradle/wrapper/gradle-wrapper.properties +++ b/unified-prototype/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.11-20240812191308+0000-bin.zip +distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-8.11-20240814172604+0000-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/unified-prototype/unified-plugin/plugin-common/src/main/java/org/gradle/api/experimental/buildinit/StaticProjectGenerator.java b/unified-prototype/unified-plugin/plugin-common/src/main/java/org/gradle/api/experimental/buildinit/StaticProjectGenerator.java index 6efa8bc1..5f221a04 100644 --- a/unified-prototype/unified-plugin/plugin-common/src/main/java/org/gradle/api/experimental/buildinit/StaticProjectGenerator.java +++ b/unified-prototype/unified-plugin/plugin-common/src/main/java/org/gradle/api/experimental/buildinit/StaticProjectGenerator.java @@ -10,7 +10,7 @@ * as resources files in the {@link #TEMPLATES_ROOT} directory. */ @SuppressWarnings("UnstableApiUsage") -public final class StaticProjectGenerator implements InitProjectGenerator { +public abstract class StaticProjectGenerator implements InitProjectGenerator { private static final String TEMPLATES_ROOT = "templates"; @Override diff --git a/unified-prototype/unified-plugin/plugin-jvm/src/main/java/org/gradle/api/experimental/buildinit/JVMProjectSource.java b/unified-prototype/unified-plugin/plugin-jvm/src/main/java/org/gradle/api/experimental/buildinit/JVMProjectSource.java index 64d86d1b..1ddea38c 100644 --- a/unified-prototype/unified-plugin/plugin-jvm/src/main/java/org/gradle/api/experimental/buildinit/JVMProjectSource.java +++ b/unified-prototype/unified-plugin/plugin-jvm/src/main/java/org/gradle/api/experimental/buildinit/JVMProjectSource.java @@ -21,7 +21,7 @@ public List getProjectSpecs() { } @Override - public InitProjectGenerator getProjectGenerator() { - return new StaticProjectGenerator(); + public Class getProjectGenerator() { + return StaticProjectGenerator.class; } }