use of net.sf.launch4j.config.Config in project SIMRacingApps by SIMRacingApps.
the class Launch4jTask method execute.
public void execute() throws BuildException {
try {
if (tmpdir != null) {
System.setProperty("launch4j.tmpdir", tmpdir.getPath());
}
if (bindir != null) {
System.setProperty("launch4j.bindir", bindir.getPath());
}
if (_configFile != null && _config != null) {
throw new BuildException(Messages.getString("Launch4jTask.specify.config"));
} else if (_configFile != null) {
ConfigPersister.getInstance().load(_configFile);
Config c = ConfigPersister.getInstance().getConfig();
if (jar != null) {
c.setJar(jar);
}
if (outfile != null) {
c.setOutfile(outfile);
}
if (fileVersion != null) {
c.getVersionInfo().setFileVersion(fileVersion);
}
if (txtFileVersion != null) {
c.getVersionInfo().setTxtFileVersion(txtFileVersion);
}
if (productVersion != null) {
c.getVersionInfo().setProductVersion(productVersion);
}
if (txtProductVersion != null) {
c.getVersionInfo().setTxtProductVersion(txtProductVersion);
}
} else if (_config != null) {
_config.unwrap();
ConfigPersister.getInstance().setAntConfig(_config, getProject().getBaseDir());
} else {
throw new BuildException(Messages.getString("Launch4jTask.specify.config"));
}
final Builder b = new Builder(Log.getAntLog());
b.build();
} catch (ConfigPersisterException e) {
throw new BuildException(e);
} catch (BuilderException e) {
throw new BuildException(e);
}
}
use of net.sf.launch4j.config.Config in project megameklab by MegaMek.
the class Cmd method build.
/**
* @return Output file path.
*/
public File build() throws BuilderException {
final Config c = ConfigPersister.getInstance().getConfig();
try {
c.validate();
} catch (InvariantViolationException e) {
throw new BuilderException(e.getMessage());
}
File rc = null;
File ro = null;
File outfile = null;
FileInputStream is = null;
FileOutputStream os = null;
final RcBuilder rcb = new RcBuilder();
try {
rc = rcb.build(c);
ro = Util.createTempFile("o");
outfile = ConfigPersister.getInstance().getOutputFile();
Cmd resCmd = new Cmd(_basedir);
resCmd.addExe("windres").add(Util.WINDOWS_OS ? "--preprocessor=type" : "--preprocessor=cat").add("-J rc -O coff -F pe-i386").addAbsFile(rc).addAbsFile(ro);
_log.append(Messages.getString("Builder.compiling.resources"));
resCmd.exec(_log);
Cmd ldCmd = new Cmd(_basedir);
ldCmd.addExe("ld").add("-mi386pe").add("--oformat pei-i386").add((c.getHeaderType().equals(Config.GUI_HEADER)) ? "--subsystem windows" : "--subsystem console").add(// strip symbols
"-s").addFiles(c.getHeaderObjects()).addAbsFile(ro).addFiles(c.getLibs()).add("-o").addAbsFile(outfile);
_log.append(Messages.getString("Builder.linking"));
ldCmd.exec(_log);
if (!c.isDontWrapJar()) {
_log.append(Messages.getString("Builder.wrapping"));
int len;
byte[] buffer = new byte[1024];
is = new FileInputStream(Util.getAbsoluteFile(ConfigPersister.getInstance().getConfigPath(), c.getJar()));
os = new FileOutputStream(outfile, true);
while ((len = is.read(buffer)) > 0) {
os.write(buffer, 0, len);
}
}
_log.append(Messages.getString("Builder.success") + outfile.getPath());
return outfile;
} catch (IOException e) {
Util.delete(outfile);
_log.append(e.getMessage());
throw new BuilderException(e);
} catch (ExecException e) {
Util.delete(outfile);
String msg = e.getMessage();
if (msg != null && msg.indexOf("windres") != -1) {
if (e.getErrLine() != -1) {
_log.append(Messages.getString("Builder.line.has.errors", String.valueOf(e.getErrLine())));
_log.append(rcb.getLine(e.getErrLine()));
} else {
_log.append(Messages.getString("Builder.generated.resource.file"));
_log.append(rcb.getContent());
}
}
throw new BuilderException(e);
} finally {
Util.close(is);
Util.close(os);
Util.delete(rc);
Util.delete(ro);
}
}
use of net.sf.launch4j.config.Config in project megameklab by MegaMek.
the class Launch4jTask method execute.
public void execute() throws BuildException {
try {
if (tmpdir != null) {
System.setProperty("launch4j.tmpdir", tmpdir.getPath());
}
if (bindir != null) {
System.setProperty("launch4j.bindir", bindir.getPath());
}
if (_configFile != null && _config != null) {
throw new BuildException(Messages.getString("Launch4jTask.specify.config"));
} else if (_configFile != null) {
ConfigPersister.getInstance().load(_configFile);
Config c = ConfigPersister.getInstance().getConfig();
if (jar != null) {
c.setJar(jar);
}
if (outfile != null) {
c.setOutfile(outfile);
}
if (fileVersion != null) {
c.getVersionInfo().setFileVersion(fileVersion);
}
if (txtFileVersion != null) {
c.getVersionInfo().setTxtFileVersion(txtFileVersion);
}
if (productVersion != null) {
c.getVersionInfo().setProductVersion(productVersion);
}
if (txtProductVersion != null) {
c.getVersionInfo().setTxtProductVersion(txtProductVersion);
}
} else if (_config != null) {
_config.unwrap();
ConfigPersister.getInstance().setAntConfig(_config, getProject().getBaseDir());
} else {
throw new BuildException(Messages.getString("Launch4jTask.specify.config"));
}
final Builder b = new Builder(Log.getAntLog());
b.build();
} catch (ConfigPersisterException e) {
throw new BuildException(e);
} catch (BuilderException e) {
throw new BuildException(e);
}
}
use of net.sf.launch4j.config.Config in project beast-mcmc by beast-dev.
the class Launch4jTask method execute.
public void execute() throws BuildException {
try {
if (tmpdir != null) {
System.setProperty("launch4j.tmpdir", tmpdir.getPath());
}
if (bindir != null) {
System.setProperty("launch4j.bindir", bindir.getPath());
}
if (_configFile != null && _config != null) {
throw new BuildException(Messages.getString("Launch4jTask.specify.config"));
} else if (_configFile != null) {
ConfigPersister.getInstance().load(_configFile);
Config c = ConfigPersister.getInstance().getConfig();
if (jar != null) {
c.setJar(jar);
}
if (outfile != null) {
c.setOutfile(outfile);
}
if (fileVersion != null) {
c.getVersionInfo().setFileVersion(fileVersion);
}
if (txtFileVersion != null) {
c.getVersionInfo().setTxtFileVersion(txtFileVersion);
}
if (productVersion != null) {
c.getVersionInfo().setProductVersion(productVersion);
}
if (txtProductVersion != null) {
c.getVersionInfo().setTxtProductVersion(txtProductVersion);
}
} else if (_config != null) {
_config.unwrap();
ConfigPersister.getInstance().setAntConfig(_config, getProject().getBaseDir());
} else {
throw new BuildException(Messages.getString("Launch4jTask.specify.config"));
}
final Builder b = new Builder(Log.getAntLog());
b.build();
} catch (ConfigPersisterException e) {
throw new BuildException(e);
} catch (BuilderException e) {
throw new BuildException(e);
}
}
use of net.sf.launch4j.config.Config in project cogtool by cogtool.
the class Cmd method build.
/**
* @return Output file path.
*/
public File build() throws BuilderException {
final Config c = ConfigPersister.getInstance().getConfig();
try {
c.validate();
} catch (InvariantViolationException e) {
throw new BuilderException(e.getMessage());
}
File rc = null;
File ro = null;
File outfile = null;
FileInputStream is = null;
FileOutputStream os = null;
final RcBuilder rcb = new RcBuilder();
try {
rc = rcb.build(c);
ro = Util.createTempFile("o");
outfile = ConfigPersister.getInstance().getOutputFile();
Cmd resCmd = new Cmd(_basedir);
resCmd.addExe("windres").add(Util.WINDOWS_OS ? "--preprocessor=type" : "--preprocessor=cat").add("-J rc -O coff -F pe-i386").addAbsFile(rc).addAbsFile(ro);
_log.append(Messages.getString("Builder.compiling.resources"));
resCmd.exec(_log);
Cmd ldCmd = new Cmd(_basedir);
ldCmd.addExe("ld").add("-mi386pe").add("--oformat pei-i386").add((c.getHeaderType().equals(Config.GUI_HEADER)) ? "--subsystem windows" : "--subsystem console").add(// strip symbols
"-s").addFiles(c.getHeaderObjects()).addAbsFile(ro).addFiles(c.getLibs()).add("-o").addAbsFile(outfile);
_log.append(Messages.getString("Builder.linking"));
ldCmd.exec(_log);
if (!c.isDontWrapJar()) {
_log.append(Messages.getString("Builder.wrapping"));
int len;
byte[] buffer = new byte[1024];
is = new FileInputStream(Util.getAbsoluteFile(ConfigPersister.getInstance().getConfigPath(), c.getJar()));
os = new FileOutputStream(outfile, true);
while ((len = is.read(buffer)) > 0) {
os.write(buffer, 0, len);
}
}
_log.append(Messages.getString("Builder.success") + outfile.getPath());
return outfile;
} catch (IOException e) {
Util.delete(outfile);
_log.append(e.getMessage());
throw new BuilderException(e);
} catch (ExecException e) {
Util.delete(outfile);
String msg = e.getMessage();
if (msg != null && msg.indexOf("windres") != -1) {
if (e.getErrLine() != -1) {
_log.append(Messages.getString("Builder.line.has.errors", String.valueOf(e.getErrLine())));
_log.append(rcb.getLine(e.getErrLine()));
} else {
_log.append(Messages.getString("Builder.generated.resource.file"));
_log.append(rcb.getContent());
}
}
throw new BuilderException(e);
} finally {
Util.close(is);
Util.close(os);
Util.delete(rc);
Util.delete(ro);
}
}
Aggregations