@@ -134,22 +134,36 @@ class GradleService(val editor: Editor) {
134134
135135
136136
137- fun ProjectConnection.newSketchBuild (): BuildLauncher {
137+ private fun ProjectConnection.newSketchBuild (): BuildLauncher {
138138 finishedTasks.clear()
139- // TODO: Research if we can generate these programmatically
140- // Ideally they would not be placed into the sketch folder
141139
142- val initGradle = kotlin.io.path.createTempDirectory().resolve(" init.gradle.kts" ).apply {
140+ val workingDir = kotlin.io.path.createTempDirectory()
141+ val group = System .getProperty(" processing.group" , " org.processing" )
142+
143+ val variables = mapOf (
144+ " group" to group,
145+ " version" to Base .getVersionName(),
146+ " sketchFolder" to folder.absolutePath,
147+ " workingDir" to workingDir.toAbsolutePath().toString(),
148+ " settings" to Platform .getSettingsFolder().absolutePath.toString()
149+ )
150+
151+ val initGradle = workingDir.resolve(" init.gradle.kts" ).apply {
143152 val content = """
144153 beforeSettings{
145154 pluginManagement {
146155 repositories {
147156 maven { url = uri("${Platform .getContentFile(" repository" ).absolutePath} ") }
148- //mavenLocal()
149157 gradlePluginPortal()
150158 }
151159 }
152160 }
161+ allprojects{
162+ repositories {
163+ maven { url = uri("${Platform .getContentFile(" repository" ).absolutePath} ") }
164+ mavenCentral()
165+ }
166+ }
153167 """ .trimIndent()
154168
155169 writeText(content)
@@ -161,20 +175,24 @@ class GradleService(val editor: Editor) {
161175 Messages .log(" build.gradle.kts not found in ${folder} , creating one" )
162176 // TODO: Allow for other plugins to be registered
163177 // TODO: Allow for the whole configuration to be overridden
178+ // TODO: Move this to java mode
164179 val content = """
165180 // Managed by: Processing ${Base .getVersionName()}
166181 // If you delete this comment Processing will no longer update the build scripts
167182
168183 plugins{
169- id("processing.java .gradle") version "${Base .getVersionName()} "
184+ id("org.processing .gradle") version "${Base .getVersionName()} "
170185 }
171186 """ .trimIndent()
172187 buildGradle.writeText(content)
173188 }
174189
175190 return this .newBuild()
176191// .setJavaHome(Platform.getJavaHome())
177- .withArguments(" --init-script" , initGradle.toAbsolutePath().toString())
192+ .withArguments(
193+ " --init-script" , initGradle.toAbsolutePath().toString(),
194+ * variables.entries.map { " -Pprocessing.${it.key} =${it.value} " }.toTypedArray()
195+ )
178196 .addProgressListener(ProgressListener { event ->
179197 val name = event.descriptor.name
180198 if (event is TaskStartEvent ) {
0 commit comments