Search in sources :

Example 1 with WebComponentExportDataModelProvider

use of org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider in project azure-tools-for-java by Microsoft.

the class AzureDockerUIResources method createArtifact.

public static void createArtifact(Shell shell, IProject project) {
    if (project == null) {
        return;
    }
    String projectName = project.getName();
    String destinationPath = project.getLocation() + "/" + projectName + ".war";
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {
        dialog.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor progressMonitor) {
                progressMonitor.beginTask("Creating WAR artifact", 100);
                try {
                    progressMonitor.subTask(String.format("Building selected project: %s ...", project.getName()));
                    progressMonitor.worked(35);
                    project.build(IncrementalProjectBuilder.FULL_BUILD, null);
                    progressMonitor.subTask("Exporting to WAR ...");
                    progressMonitor.worked(75);
                    IDataModel dataModel = DataModelFactory.createDataModel(new WebComponentExportDataModelProvider());
                    dataModel.setProperty(IJ2EEComponentExportDataModelProperties.PROJECT_NAME, projectName);
                    dataModel.setProperty(IJ2EEComponentExportDataModelProperties.ARCHIVE_DESTINATION, destinationPath);
                    if (dataModel.getDefaultOperation() != null)
                        try {
                            dataModel.getDefaultOperation().execute(null, null);
                        } catch (Exception ignored) {
                        }
                    //						progressMonitor.subTask("");
                    //						progressMonitor.worked(1);
                    //						if (progressMonitor.isCanceled()) {
                    //							if (displayWarningOnCreateKeyVaultCancelAction() == 0) {
                    //								progressMonitor.done();
                    //								return Status.CANCEL_STATUS;
                    //							}
                    //						}
                    progressMonitor.done();
                } catch (Exception e) {
                    String msg = "An error occurred while attempting to create WAR artifact" + "\n" + e.getMessage();
                    log.log(Level.SEVERE, "createArtifact: " + msg, e);
                    e.printStackTrace();
                }
                progressMonitor.done();
            }
        });
    } catch (Exception e) {
        CANCELED = true;
        log.log(Level.SEVERE, "updateAzureResourcesWithProgressDialog: " + e.getMessage(), e);
        e.printStackTrace();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WebComponentExportDataModelProvider(org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with WebComponentExportDataModelProvider

use of org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method export.

public void export(String projectName, String destinationPath) throws Exception {
    System.out.println("Building project '" + projectName + "'...");
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    project.build(IncrementalProjectBuilder.FULL_BUILD, null);
    System.out.println("Exporting to WAR...");
    IDataModel dataModel = DataModelFactory.createDataModel(new WebComponentExportDataModelProvider());
    dataModel.setProperty(IJ2EEComponentExportDataModelProperties.PROJECT_NAME, projectName);
    dataModel.setProperty(IJ2EEComponentExportDataModelProperties.ARCHIVE_DESTINATION, destinationPath);
    dataModel.getDefaultOperation().execute(null, null);
    System.out.println("Done.");
}
Also used : WebComponentExportDataModelProvider(org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) IProject(org.eclipse.core.resources.IProject)

Example 3 with WebComponentExportDataModelProvider

use of org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider in project azure-tools-for-java by Microsoft.

the class WAExportWarEar method exportWarComponent.

/**
	 * This method export dependent dynamic web project as war
	 * with their dependent libraries if any.
	 * @param projName
	 * @param destPath
	 * @throws ExecutionException
	 */
public static void exportWarComponent(String projName, String destPath) throws ExecutionException {
    IDataModel warModel = DataModelFactory.createDataModel(new WebComponentExportDataModelProvider());
    warModel.setProperty(IWebComponentExportDataModelProperties.PROJECT_NAME, projName);
    warModel.setProperty(IWebComponentExportDataModelProperties.ARCHIVE_DESTINATION, destPath);
    warModel.setProperty(IWebComponentExportDataModelProperties.OVERWRITE_EXISTING, true);
    try {
        warModel.getDefaultOperation().execute(null, null);
    } catch (org.eclipse.core.commands.ExecutionException e) {
        errorMessage = String.format("%s%s%s%s%s", Messages.crtErrMsg, " ", "WAR", " of project: ", projName);
        Activator.getDefault().log(errorMessage, e);
    }
}
Also used : WebComponentExportDataModelProvider(org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel)

Aggregations

WebComponentExportDataModelProvider (org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider)3 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)3 IProject (org.eclipse.core.resources.IProject)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1