public String getOutputFile(CompilerConfiguration configuration) throws CompilerException { return configuration.getOutputFileName() + "." + getTypeExtension(configuration); }
private String[] buildCompilerArguments(CompilerConfiguration config, String[] sourceFiles) throws CompilerException { List args = new ArrayList(); if (config.isDebug()) { args.add("/debug+"); } else { args.add("/debug-"); } // config.isShowWarnings() // config.getSourceVersion() // config.getTargetVersion() // config.getSourceEncoding() // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- for (Iterator it = config.getClasspathEntries().iterator(); it.hasNext(); ) { String element = (String) it.next(); File f = new File(element); if (!f.isFile()) { continue; } args.add("/reference:\"" + element + "\""); } // ---------------------------------------------------------------------- // Main class // ---------------------------------------------------------------------- Map compilerArguments = config.getCustomCompilerArguments(); String mainClass = (String) compilerArguments.get("-main"); if (!StringUtils.isEmpty(mainClass)) { args.add("/main:" + mainClass); } // ---------------------------------------------------------------------- // Xml Doc output // ---------------------------------------------------------------------- String doc = (String) compilerArguments.get("-doc"); if (!StringUtils.isEmpty(doc)) { args.add( "/doc:" + new File(config.getOutputLocation(), config.getOutputFileName() + ".xml") .getAbsolutePath()); } // ---------------------------------------------------------------------- // Xml Doc output // ---------------------------------------------------------------------- String nowarn = (String) compilerArguments.get("-nowarn"); if (!StringUtils.isEmpty(nowarn)) { args.add("/nowarn:" + nowarn); } // ---------------------------------------------------------------------- // Out - Override output name, this is required for generating the unit test dll // ---------------------------------------------------------------------- String out = (String) compilerArguments.get("-out"); if (!StringUtils.isEmpty(out)) { args.add("/out:" + new File(config.getOutputLocation(), out).getAbsolutePath()); } else { args.add( "/out:" + new File(config.getOutputLocation(), getOutputFile(config)).getAbsolutePath()); } // ---------------------------------------------------------------------- // Resource File - compile in a resource file into the assembly being created // ---------------------------------------------------------------------- String resourcefile = (String) compilerArguments.get("-resourcefile"); if (!StringUtils.isEmpty(resourcefile)) { String resourceTarget = (String) compilerArguments.get("-resourcetarget"); args.add("/res:" + new File(resourcefile).getAbsolutePath() + "," + resourceTarget); } // ---------------------------------------------------------------------- // Target - type of assembly to produce, lib,exe,winexe etc... // ---------------------------------------------------------------------- String target = (String) compilerArguments.get("-target"); if (StringUtils.isEmpty(target)) { args.add("/target:library"); } else { args.add("/target:" + target); } // ---------------------------------------------------------------------- // remove MS logo from output (not applicable for mono) // ---------------------------------------------------------------------- String nologo = (String) compilerArguments.get("-nologo"); if (!StringUtils.isEmpty(nologo)) { args.add("/nologo"); } // ---------------------------------------------------------------------- // add any resource files // ---------------------------------------------------------------------- this.addResourceArgs(config, args); // ---------------------------------------------------------------------- // add source files // ---------------------------------------------------------------------- for (int i = 0; i < sourceFiles.length; i++) { String sourceFile = sourceFiles[i]; args.add(sourceFile); } return (String[]) args.toArray(new String[args.size()]); }