/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.wgadesigner.builders;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import de.innovationgate.eclipse.wgadesigner.WGADesignerPlugin;
import de.innovationgate.eclipse.wgadesigner.editors.helpers.WGADeployment;
import de.innovationgate.eclipse.wgadesigner.editors.helpers.WGADeploymentManager;
/**
* builder for creating and updating a WGADeployment from an local J2EE-WGAPublisher-Project
*
*
*/
public class WGADeploymentsBuilder extends IncrementalProjectBuilder {
public WGADeploymentsBuilder() {
}
@Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
try {
WGADeploymentManager manager = WGADesignerPlugin.getDefault().getWGADeploymentManager();
WGADeployment deployment = manager.getDeployment(getProject().getName());
if (deployment != null) {
IResourceDelta delta = getDelta(getProject());
if (delta != null) {
if (WGADesignerPlugin.getDefault().isDebugging()) {
System.out.println("Incremental update of WGA deployment '" + deployment.getName() + "'.");
}
deployment.updateWGA(delta, monitor);
} else {
if (WGADesignerPlugin.getDefault().isDebugging()) {
System.out.println("Full update of WGA deployment '" + deployment.getName() + "'.");
}
deployment.updateWGA(getProject(), monitor);
}
} else {
manager.createDeployment(getProject(), monitor);
}
} catch (Exception e) {
throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to create or update wga deployment.", e));
}
return null;
}
}