@@ -103,15 +103,15 @@ abstract class BasePluginTest {
103
103
val outputServerShadowJar: JarPath get() = jarPath(" server/build/libs/server-1.0-all.jar" )
104
104
105
105
fun getDefaultProjectBuildScript (
106
- javaPlugin : String = "java",
106
+ plugin : String = "java",
107
107
withGroup : Boolean = false,
108
108
withVersion : Boolean = false,
109
109
): String {
110
110
val groupInfo = if (withGroup) " group = 'my'" else " "
111
111
val versionInfo = if (withVersion) " version = '1.0'" else " "
112
112
return """
113
113
plugins {
114
- id('$javaPlugin ')
114
+ id('$plugin ')
115
115
id('com.gradleup.shadow')
116
116
}
117
117
$groupInfo
@@ -194,26 +194,43 @@ abstract class BasePluginTest {
194
194
packageName : String = "my",
195
195
withImports : Boolean = false,
196
196
className : String = "Main ",
197
+ isJava : Boolean = true,
197
198
): String {
198
- val imports = if (withImports) " import junit.framework.Test;" else " "
199
- val classRef = if (withImports) " \" Refs: \" + Test.class.getName()" else " \" Refs: null\" "
200
- path(" src/$sourceSet /java/$packageName /$className .java" ).writeText(
201
- """
202
- package $packageName ;
203
- $imports
204
- public class $className {
205
- public static void main(String[] args) {
206
- if (args.length == 0) {
207
- throw new IllegalArgumentException("No arguments provided.");
199
+ if (isJava) {
200
+ val imports = if (withImports) " import junit.framework.Test;" else " "
201
+ val classRef = if (withImports) " \" Refs: \" + Test.class.getName()" else " \" Refs: null\" "
202
+ path(" src/$sourceSet /java/$packageName /$className .java" ).writeText(
203
+ """
204
+ package $packageName ;
205
+ $imports
206
+ public class $className {
207
+ public static void main(String[] args) {
208
+ if (args.length == 0) throw new IllegalArgumentException("No arguments provided.");
209
+ String content = String.format("Hello, World! (%s) from $className ", (Object[]) args);
210
+ System.out.println(content);
211
+ System.out.println($classRef );
208
212
}
209
- String content = String.format("Hello, World! (%s) from $className ", (Object[]) args);
210
- System.out.println(content);
211
- System.out.println($classRef );
212
213
}
213
- }
214
- """ .trimIndent(),
215
- )
216
- return packageName.replace(' .' , ' /' ) + " /$className .class"
214
+ """ .trimIndent(),
215
+ )
216
+ } else {
217
+ val imports = if (withImports) " import junit.framework.Test;" else " "
218
+ val classRef = if (withImports) " \" Refs: \" + Test.class.getName()" else " \" Refs: null\" "
219
+ path(" src/$sourceSet /kotlin/$packageName /$className .kt" ).writeText(
220
+ """
221
+ package $packageName
222
+ $imports
223
+ fun main(vararg args: String) {
224
+ if (args.isEmpty()) throw IllegalArgumentException("No arguments provided.")
225
+ val content ="Hello, World! (%s) from $className ".format(*args)
226
+ println(content)
227
+ println($classRef )
228
+ }
229
+ """ .trimIndent(),
230
+ )
231
+ }
232
+ val baseClassPath = packageName.replace(' .' , ' /' ) + " /$className "
233
+ return if (isJava) " $baseClassPath .class" else " ${baseClassPath} Kt.class"
217
234
}
218
235
219
236
fun writeClientAndServerModules (
0 commit comments