@@ -59,9 +59,16 @@ application {
5959}
6060
6161sourceSets {
62+ main {
63+ java {
64+ output.setResourcesDir(destinationDirectory.get())
65+ }
66+ }
6267 create(" utility" )
6368}
6469
70+ tasks.named(" processResources" ).configure { dependsOn(" compileJava" ) }
71+
6572val utilityImplementation by configurations.getting {
6673 extendsFrom(configurations.implementation.get())
6774}
@@ -161,3 +168,36 @@ tasks.withType<Test>().configureEach {
161168 exceptionFormat = TestExceptionFormat .FULL
162169 }
163170}
171+
172+ tasks.named(" classes" ) {
173+ dependsOn(" createRunScript" )
174+ }
175+
176+ tasks.register(" createRunScript" ) {
177+ dependsOn(" compileJava" , " compileKotlin" , " processResources" )
178+
179+ doLast {
180+ // Get the Java executable from JAVA_HOME environment variable
181+ val javaHome = System .getenv(" JAVA_HOME" ) ? : throw IllegalStateException (" JAVA_HOME is not set" )
182+ val javaExecutable = " $javaHome /bin/java"
183+
184+ // Collect runtime classpath elements into a single string with path separator
185+ val runtimeClasspath = configurations[" runtimeClasspath" ].files.joinToString(File .pathSeparator) {
186+ it.absolutePath
187+ }
188+
189+ // Get the output directory for the main/java source set
190+ val mainJavaOutputDir = project.sourceSets[" main" ].java.destinationDirectory.get().asFile.absolutePath
191+
192+ // Assemble the module-path to include both the runtime classpath and the main/java output directory
193+ val modulePath = " $runtimeClasspath${File .pathSeparator}$mainJavaOutputDir "
194+
195+ // Assemble the command
196+ val command = " clear; $javaExecutable -ea -p $modulePath -m holocore/com.projectswg.holocore.ProjectSWG --print-colors"
197+
198+ // File to write the run command
199+ val outputFile = file(" ${layout.buildDirectory.asFile.get().absolutePath} /run" )
200+ outputFile.writeText(command)
201+ outputFile.setExecutable(true )
202+ }
203+ }
0 commit comments