@@ -7,6 +7,8 @@ class Tags {
77 Boolean errorOutputExpected = false
88 Boolean validateByHand = false
99 Boolean ignoreOutput = false // probably don't need this tag
10+ String fileRoot
11+ String mainClass
1012 String javaCmd = null
1113 List<String > args = []
1214 String jVMArgs = null
@@ -18,14 +20,19 @@ class Tags {
1820 this . lines = lines
1921 block = lines. join(' ' )
2022 mainMethod = block. contains(' main(String[] args)' )
23+ fileRoot = lines[0 ]. split(" /" )[-1 ] - " .java"
24+ mainClass = fileRoot
25+ javaCmd = extract(' main:' )
26+ if (javaCmd)
27+ mainClass = javaCmd
2128 compileTimeError = testFor(' CompileTimeError' )
2229 throwsException = testFor(' ThrowsException' )
2330 errorOutputExpected = testFor(' ErrorOutputExpected' )
2431 validateByHand = testFor(' ValidateByHand' )
2532 ignoreOutput = testFor(' IgnoreOutput' )
26- javaCmd = extract(' main:' )
2733 def argString = extract(' Args:' )
28- if (argString) args = argString. split(' ' )
34+ if (argString)
35+ args = argString. split(' ' )
2936 jVMArgs = extract(' JVMArgs:' )
3037 exec = extract(' Exec:' )
3138 runFirst = extract(' RunFirst:' )
@@ -39,11 +46,7 @@ class Tags {
3946 def re = " \\ /\\ / \\ {" + marker + / [^}]+}/
4047 def tagline = block =~ re
4148 if (tagline. getCount()) {
42- if (block. contains(" TestRegularExpression" ))
43- println tagline[0 ]
4449 def rtrim = tagline[0 ]. reverse(). dropWhile{ it != ' }' }. reverse()[0 .. -2 ]
45- if (block. contains(" TestRegularExpression" ))
46- println rtrim
4750 def ltrim = rtrim - (" // {" + marker)
4851 return ltrim. trim()
4952 } else {
@@ -130,26 +133,9 @@ subprojects {
130133 // Add tasks for java sources with main methods
131134 if ((tags. mainMethod || tags. javaCmd) && (! tags. compileTimeError)) {
132135
133- /* String maybeArgsLine = lines.find { it.startsWith('// {Args: ')}
134-
135- List maybeArgs = []
136- if (maybeArgsLine != null) {
137- maybeArgs = maybeArgsLine.trim().replaceAll('\\/\\/ \\{Args: ', '').reverse().replaceFirst('}', '').reverse().split(' ')
138- }
139- */
140- String mainClass = it. name. replaceAll(' .java' , ' ' )
141-
142- String taskName = mainClass
143-
144136 if (! tags. validateByHand) {
145137 // only add tasks that we know we can run successfully to the task list
146- tasks. add(taskName)
147- }
148-
149- // some java sources with a main method specify a different main class
150- String maybeMainLine = lines. find { it. startsWith(' // {main: ' )}
151- if (maybeMainLine != null ) {
152- mainClass = maybeMainLine. trim(). replaceAll(' \\ /\\ / \\ {main: ' , ' ' ). replaceAll(' }' , ' ' )
138+ tasks. add(tags. fileRoot)
153139 }
154140
155141 // some java sources with JVM args
@@ -178,8 +164,8 @@ subprojects {
178164
179165 OutputStream runErrorOutput = new TeeOutputStream (new FileOutputStream (errFile), System . err)
180166
181- task " $t askName " (type : JavaExec , dependsOn : maybeRunFirst) {
182- main = mainClass
167+ task " $t ags . fileRoot " (type : JavaExec , dependsOn : maybeRunFirst) {
168+ main = tags . mainClass
183169 classpath = sourceSets. main. runtimeClasspath
184170 args = tags. args
185171 jvmArgs = maybeJvmArgs
0 commit comments