Created
June 18, 2011 10:13
-
-
Save redfish4ktc/1032966 to your computer and use it in GitHub Desktop.
Extension du BuilderTerminal du Scort Enterprise Studio 5.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.scort.es.builder; | |
import java.io.File; | |
import java.io.PrintStream; | |
import com.scort.es.global.Constants; | |
import com.scort.es.terminals.generator.AOStandaloneLauncher; | |
import com.scort.es.util.CommandArgs; | |
// Reimplementation des classes originales scort qui n'utilisent pas d'elements graphiques | |
// Ceci permet de faire fonctionner la generation sur un environnement qui n'a pas de peripherique graphique configure, | |
// par exemple, un serveur de build sous linux | |
public class ScortHeadlessBuilderTerminal { | |
public static void main(String args[]) { | |
try { | |
DiswsBuilderTerminal builder = new DiswsBuilderTerminal(); | |
String repositoryPath = builder.loadArgs(args); | |
if (repositoryPath == null) { | |
throw new RuntimeException("Repository file is not defined"); | |
} | |
builder.generation(new File(repositoryPath), System.out); | |
} | |
catch (Exception e) { | |
throw new RuntimeException("Error occurs", e); | |
} | |
} | |
// adapte de BuilderTerminal | |
protected String loadArgs(String args[]) { | |
CommandArgs arguments = getCommonArgs(args); | |
String repositoryPath = loadArgs(arguments); | |
return repositoryPath; | |
} | |
// pris de AbstractBuilder | |
protected String loadArgs(CommandArgs arguments) { | |
/* 228 */if (!arguments.checkCommandLine()) | |
/* 228 */System.exit(-1); | |
/* 230 */String esPath = arguments.getParameterValue("-PATH"); | |
/* 231 */if (!(new File(esPath)).isDirectory()) | |
/* 232 */throw new RuntimeException("Invalid ROOT path ... Please update \"-PATH\" value in command line"); | |
/* 235 */String repositoryPath = arguments.getParameterValue("-RESOURCE"); | |
/* 236 */if (repositoryPath != null && !(new File(repositoryPath)).isFile()) { | |
/* 237 */throw new RuntimeException( | |
"Invalid repository file ... Please update \"-RESOURCE\" value in command line"); | |
} | |
// else | |
// { | |
/* 240 */System.setProperty("scort.SCORT_PRODUCT_HOME", esPath); | |
/* 242 */return repositoryPath; | |
// } | |
} | |
// copie de AbstractBuilder | |
protected CommandArgs getCommonArgs(String args[]) { | |
/* 212 */CommandArgs arguments = new CommandArgs(args); | |
/* 213 */arguments.accept("-PATH", false, true, true, | |
(new StringBuilder(" the installation path of ")).append(Constants.PRODUCT).toString()); | |
/* 218 */arguments.accept("-RESOURCE", false, false, true, " the path of the resource to be built"); | |
/* 223 */return arguments; | |
} | |
// pris de BuilderTerminal | |
protected void generation(File cfgFile, PrintStream outputLog) { | |
/* 80 */AOStandaloneLauncher builder = new AOStandaloneLauncher(); | |
boolean JCAmode = false; | |
/* 81 */try { | |
builder.initialize(cfgFile.getAbsolutePath(), outputLog, JCAmode, null); | |
} | |
catch (Exception e) { | |
throw new RuntimeException("Error occurs when generating from config file " + cfgFile, e); | |
} | |
/* 82 */builder.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment