(dirPath: string)
| 216 | } |
| 217 | |
| 218 | async getMainClassName(dirPath: string) { |
| 219 | const maxSize = this.env.ceProps('max-asm-size', 64 * 1024 * 1024); |
| 220 | const files = await fs.readdir(dirPath); |
| 221 | const results = await Promise.all( |
| 222 | files |
| 223 | .filter(f => f.endsWith('.class')) |
| 224 | .map(async classFile => { |
| 225 | const options = { |
| 226 | maxOutput: maxSize, |
| 227 | customCwd: dirPath, |
| 228 | }; |
| 229 | const objResult = await this.exec(this.compiler.objdumper, [classFile], options); |
| 230 | if (objResult.code !== 0) { |
| 231 | return null; |
| 232 | } |
| 233 | |
| 234 | if (this.mainRegex.test(objResult.stdout)) { |
| 235 | return classFile; |
| 236 | } |
| 237 | return null; |
| 238 | }), |
| 239 | ); |
| 240 | |
| 241 | const candidates = results.filter(file => file !== null); |
| 242 | if (candidates.length > 0) { |
| 243 | // In case of multiple candidates, we'll just take the first one. |
| 244 | const fileName = unwrap(candidates[0]); |
| 245 | return fileName.substring(0, fileName.lastIndexOf('.')); |
| 246 | } |
| 247 | // We were unable to find a main method, let's error out assuming "Main" |
| 248 | return 'Main'; |
| 249 | } |
| 250 | |
| 251 | override getArgumentParserClass() { |
| 252 | return JavaParser; |
no test coverage detected