use of com.centurylink.mdw.plugin.ant.AntBuilder in project mdw-designer by CenturyLinkCloud.
the class WebLogicServerConfigurator method run.
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(deployOnly ? "Deploying Application" : "Configuring WebLogic Server", 150);
monitor.worked(5);
monitor.subTask("Generating build resources");
String tempLoc = MdwPlugin.getSettings().getTempResourceLocation();
AntBuilder antBuilder;
try {
if (getServerSettings().getProject().isCloudProject()) {
IProject proj = getServerSettings().getProject().getSourceProject();
createCloudBase(proj, monitor);
Generator generator = new Generator(getShell());
// deploy/env folder
PluginUtil.createFoldersAsNeeded(proj, proj.getFolder(tempLoc + "/deploy/env"), monitor);
// project.properties
JetAccess jet = getJet("ear/deploy/env/project.propertiesjet", proj, tempLoc + "/deploy/env/project.properties");
generator.createFile(jet, monitor);
// env.properties.dev
jet = getJet("ear/deploy/env/env.properties.devjet", proj, tempLoc + "/deploy/env/env.properties.dev");
generator.createFile(jet, monitor);
// ApplicationProperties.xml
jet = getJet("cloud/ApplicationProperties.xmljet", proj, tempLoc + "/deploy/config/ApplicationProperties.xml");
generator.createFile(jet, monitor);
// runConfigWLS.cmd
jet = getJet("cloud/runConfigWLS.cmdjet", proj, tempLoc + "/deploy/config/runConfigWLS.cmd");
generator.createFile(jet, monitor);
// deployEar.py
jet = getJet("cloud/deployEar.pyjet", proj, tempLoc + "/deploy/config/deployEar.py");
generator.createFile(jet, monitor);
// build.xml
jet = getJet("cloud/build.xmljet", proj, tempLoc + "/build.xml");
generator.createFile(jet, monitor);
// startWebLogic.cmd
File startWebLogic = new File(getServerSettings().getServerLoc() + "/" + (FILE_SEP.equals("/") ? "startWebLogic.sh" : "startWebLogic.cmd"));
jet = getJet("cloud/startWebLogic.cmdjet", proj, tempLoc + "/" + startWebLogic.getName());
generator.createFile(jet, monitor);
File newStartWebLogic = new File(proj.getFile(new Path(tempLoc + "/" + startWebLogic.getName())).getLocation().toString());
PluginUtil.copyFile(startWebLogic, new File(startWebLogic.getAbsolutePath() + ".bak"));
PluginUtil.copyFile(newStartWebLogic, startWebLogic);
// perform the build
monitor.setTaskName("Deploying app...");
antBuilder = getAntBuilder(proj, tempLoc);
if (deployOnly) {
antBuilder.setTarget("deployEAR");
} else {
antBuilder.setTarget("setupAndDeploy");
monitor.subTask("Executing Ant build (first time may take a while)");
}
antBuilder.getAntProject().setProperty("deploy.dir", tempLoc + "/deploy");
antBuilder.getAntProject().setProperty("server.config.dir", "deploy/config");
antBuilder.getAntProject().setProperty("app.lib.dir", "deploy/ear/APP-INF/lib");
antBuilder.build(monitor);
} else {
IProject proj = getServerSettings().getProject().getEarProject();
antBuilder = getAntBuilder(proj, null);
if (deployOnly)
antBuilder.setTarget("deployEAR");
else
antBuilder.setTarget("configureWLS");
monitor.subTask("Executing Ant build");
antBuilder.build(monitor);
}
getServerSettings().getProject().getSourceProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
monitor.done();
if (antBuilder.getBuildErrorMessages() != null) {
final AntBuilder builder = antBuilder;
MdwPlugin.getDisplay().asyncExec(new Runnable() {
public void run() {
MessageDialog.openError(getShell(), "Ant Build Failed", builder.getBuildErrorMessages().trim());
}
});
}
} catch (Exception ex) {
throw new InvocationTargetException(ex);
} finally {
if (getServerSettings().getProject().isCloudProject()) {
String prefVal = MdwPlugin.getStringPref(PreferenceConstants.PREFS_DELETE_TEMP_FILES_AFTER_SERVER_CONFIG);
if (prefVal == null || prefVal.length() == 0 || Boolean.valueOf(prefVal)) {
// cleanup
try {
getServerSettings().getProject().getSourceProject().getFolder(tempLoc + "/deploy").delete(true, monitor);
getServerSettings().getProject().getSourceProject().getFile(tempLoc + "/startWebLogic.cmd").delete(true, monitor);
getServerSettings().getProject().getSourceProject().getFile(tempLoc + "/build.xml").delete(true, monitor);
} catch (CoreException ex) {
PluginMessages.log(ex);
}
}
}
}
}
use of com.centurylink.mdw.plugin.ant.AntBuilder in project mdw-designer by CenturyLinkCloud.
the class ServerConfigurator method getAntBuilder.
protected AntBuilder getAntBuilder(IProject project, String buildFilePath) {
String buildFileLoc = buildFilePath == null ? "build.xml" : buildFilePath + "/build.xml";
File buildFile = project.getFile(buildFileLoc).getRawLocation().toFile();
AntBuilder antBuilder = new AntBuilder(buildFile);
antBuilder.getAntProject().setBaseDir(project.getLocation().toFile());
antBuilder.getAntProject().setProperty("env", "dev");
return antBuilder;
}
use of com.centurylink.mdw.plugin.ant.AntBuilder in project mdw-designer by CenturyLinkCloud.
the class ProjectUpdateAction method getAntBuilder.
protected AntBuilder getAntBuilder(IProject project) {
String tempLoc = MdwPlugin.getSettings().getTempResourceLocation();
File buildFile = project.getFile(tempLoc + "/build.xml").getRawLocation().toFile();
AntBuilder antBuilder = new AntBuilder(buildFile);
antBuilder.getAntProject().setBaseDir(project.getLocation().toFile());
antBuilder.getAntProject().setProperty("env", "dev");
return antBuilder;
}
Aggregations