Search in sources :

Example 1 with AntBuilder

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);
                }
            }
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) JetAccess(com.centurylink.mdw.plugin.codegen.JetAccess) CoreException(org.eclipse.core.runtime.CoreException) AntBuilder(com.centurylink.mdw.plugin.ant.AntBuilder) File(java.io.File) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Generator(com.centurylink.mdw.plugin.codegen.Generator)

Example 2 with AntBuilder

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;
}
Also used : AntBuilder(com.centurylink.mdw.plugin.ant.AntBuilder) File(java.io.File)

Example 3 with 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;
}
Also used : AntBuilder(com.centurylink.mdw.plugin.ant.AntBuilder) File(java.io.File)

Aggregations

AntBuilder (com.centurylink.mdw.plugin.ant.AntBuilder)3 File (java.io.File)3 Generator (com.centurylink.mdw.plugin.codegen.Generator)1 JetAccess (com.centurylink.mdw.plugin.codegen.JetAccess)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 Path (org.eclipse.core.runtime.Path)1 SAXException (org.xml.sax.SAXException)1