use of com.centurylink.mdw.plugin.codegen.Generator in project mdw-designer by CenturyLinkCloud.
the class ProjectUpdater method createEarContentsForCloud.
public void createEarContentsForCloud(IProgressMonitor monitor) throws IOException, CoreException {
IFolder appInfLibFolder = localFolder.getFolder("APP-INF/lib");
// create the ear
IFolder deployFolder = workflowProject.getSourceProject().getFolder("deploy");
if (!deployFolder.exists())
deployFolder.create(true, true, monitor);
IFolder earFolder = deployFolder.getFolder("ear");
if (earFolder.exists()) {
try {
earFolder.delete(true, monitor);
} catch (CoreException ex) {
PluginMessages.log(ex);
if ("Problems encountered while deleting resources.".equals(ex.getMessage()))
throw new IOException("Unable to delete existing EAR folder.\nMake sure your server is not running");
}
}
earFolder.create(true, true, monitor);
String[] earJars = (String[]) PluginUtil.appendArrays(WorkflowProject.MDW_SERVICES_LIBS, WorkflowProject.MDW_WARS);
for (String earJar : earJars) {
IFile earJarFile = localFolder.getFile(earJar);
earJarFile.copy(earFolder.getFile(earJar).getFullPath(), true, monitor);
earJarFile.delete(true, monitor);
String earSrcJar = earJar.endsWith(".war") ? earJar.replaceFirst("\\.war", "_src.jar") : earJar.replaceFirst("\\.jar", "_src.jar");
IFile earSrcJarFile = localFolder.getFile(earSrcJar);
if (earSrcJarFile.exists()) {
earSrcJarFile.copy(earFolder.getFile(earSrcJar).getFullPath(), true, monitor);
earSrcJarFile.delete(true, monitor);
}
}
IFolder earAppInf = earFolder.getFolder("APP-INF");
earAppInf.create(true, true, monitor);
appInfLibFolder.copy(earAppInf.getFolder("lib").getFullPath(), true, monitor);
localFolder.getFolder("APP-INF").delete(true, monitor);
// create application.xml
IFolder earMetaInf = earFolder.getFolder("META-INF");
earMetaInf.create(true, true, monitor);
JetAccess jet = getJet("cloud/application.xmljet", workflowProject.getSourceProject(), "deploy/ear/META-INF/application.xml");
Generator generator = new Generator(null);
generator.createFile(jet, monitor);
}
use of com.centurylink.mdw.plugin.codegen.Generator 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.codegen.Generator in project mdw-designer by CenturyLinkCloud.
the class ProjectInflator method generateOsgiArtifacts.
public void generateOsgiArtifacts(IProgressMonitor monitor) throws CoreException {
Generator generator = new Generator(shell);
IProject sourceProject = workflowProject.getSourceProject();
OsgiSettings osgiSettings = workflowProject.getOsgiSettings();
// bundle-context.xml
String springPath = osgiSettings.getResourceDir() + "/META-INF/spring";
JetAccess jet = getJet("osgi/bundle-context.xmljet", sourceProject, springPath + "/bundle-context.xml", null);
PluginUtil.createFoldersAsNeeded(sourceProject, sourceProject.getFolder(new Path(springPath)), monitor);
generator.createFile(jet, monitor);
if (osgiSettings.isGradleBuild()) {
// build.gradle
jet = getJet("osgi/build.gradlejet", sourceProject, "build.gradle", null);
generator.createFile(jet, monitor);
} else {
// pom.xml
String template = workflowProject.checkRequiredVersion(5, 5) ? "osgi/pom.xmljet" : "osgi/52/pom.xmljet";
jet = getJet(template, sourceProject, "pom.xml", null);
generator.createFile(jet, monitor);
}
// BundleActivator.java
String srcPath = osgiSettings.getSourceDir() + "/" + workflowProject.getDefaultSourceCodePackagePath() + "/bundle";
PluginUtil.createFoldersAsNeeded(sourceProject, sourceProject.getFolder(new Path(srcPath)), monitor);
String template = workflowProject.checkRequiredVersion(5, 5) ? "osgi/BundleActivator.javajet" : "osgi/52/BundleActivator.javajet";
jet = getJet(template, sourceProject, srcPath + "/WorkflowBundleActivator.java", null);
generator.createFile(jet, monitor);
if (!workflowProject.checkRequiredVersion(5, 5)) {
// env.properties.dev
String depEnvPath = osgiSettings.getResourceDir() + "/deploy/env";
PluginUtil.createFoldersAsNeeded(sourceProject, sourceProject.getFolder(depEnvPath), monitor);
jet = getJet("ear/deploy/env/env.properties.devjet", sourceProject, depEnvPath + "/env.properties.dev", null);
generator.createFile(jet, monitor);
}
if (workflowProject.isFilePersist())
PluginUtil.createFoldersAsNeeded(sourceProject, workflowProject.getAssetFolder(), monitor);
}
use of com.centurylink.mdw.plugin.codegen.Generator in project mdw-designer by CenturyLinkCloud.
the class ProjectConfigurator method addFrameworkJarsToClasspath.
/**
* For remote and cloud projects.
*/
public void addFrameworkJarsToClasspath(final IProgressMonitor monitor) throws CoreException {
if (project.isRemote()) {
// code generation runs on the UI thread
Generator generator = new Generator(MdwPlugin.getShell());
IProject sourceProject = project.getSourceProject();
// pom.xml
JetAccess jet = getJet("osgi/remote_pom.xmljet", sourceProject, "pom.xml");
generator.createFile(jet, monitor);
// force maven refresh
addMavenNature(monitor);
} else if (project.isOsgi() || project.isWar()) {
// pom.xml is generated with project
} else if (project.isCloudProject()) {
IFolder earFolder = project.getSourceProject().getFolder(new Path("deploy/ear"));
addJarsToClasspath(project.getJavaProject(), earFolder, monitor);
IFolder earAppInfLib = earFolder.getFolder(new Path("APP-INF/lib"));
addJarsToClasspath(project.getJavaProject(), earAppInfLib, monitor);
}
IFolder libFolder = project.getSourceProject().getFolder("lib");
if (libFolder.exists())
addJarsToClasspath(project.getJavaProject(), libFolder, monitor);
IFolder webLibFolder = project.getSourceProject().getFolder(new Path("web/WEB-INF/lib"));
if (webLibFolder.exists())
addJarsToClasspath(project.getJavaProject(), webLibFolder, monitor);
J2EEComponentClasspathUpdater.getInstance().queueUpdateModule(project.getSourceProject());
}
use of com.centurylink.mdw.plugin.codegen.Generator in project mdw-designer by CenturyLinkCloud.
the class ProjectInflator method generateWarCloudArtifacts.
public void generateWarCloudArtifacts(IProgressMonitor monitor) throws CoreException {
Generator generator = new Generator(shell);
IProject sourceProject = workflowProject.getSourceProject();
if (workflowProject.isFilePersist())
PluginUtil.createFoldersAsNeeded(sourceProject, workflowProject.getAssetFolder(), monitor);
// pom.xml
JetAccess jet;
if (workflowProject.isFilePersist()) {
String template = workflowProject.checkRequiredVersion(6, 0) ? "cloud/cloud_fs_pom.xmljet" : "cloud/55/cloud_fs_pom.xmljet";
jet = getJet(template, sourceProject, "pom.xml", null);
} else
jet = getJet("osgi/remote_pom.xmljet", sourceProject, "pom.xml", null);
generator.createFile(jet, monitor);
}
Aggregations