Author: rombert
Date: Fri May 23 12:07:47 2014
New Revision: 1597072
URL: http://svn.apache.org/r1597072
Log:
SLING-3550 - Inspect bundles for deployment for well-known errors
Ensure that the org.eclipse.wst.validation.validationbuilder is present
when adding the sling.bundle facet to a project.
Modified:
sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingBundleFacetInstallDelegate.java
Modified:
sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingBundleFacetInstallDelegate.java
URL:
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingBundleFacetInstallDelegate.java?rev=1597072&r1=1597071&r2=1597072&view=diff
==============================================================================
---
sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingBundleFacetInstallDelegate.java
(original)
+++
sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingBundleFacetInstallDelegate.java
Fri May 23 12:07:47 2014
@@ -16,7 +16,10 @@
*/
package org.apache.sling.ide.eclipse.core.internal;
+import org.apache.sling.ide.eclipse.core.debug.PluginLogger;
+import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.common.project.facet.core.IDelegate;
@@ -24,10 +27,39 @@ import org.eclipse.wst.common.project.fa
public class SlingBundleFacetInstallDelegate implements IDelegate {
+ private static final String VALIDATION_BUILDER_NAME =
"org.eclipse.wst.validation.validationbuilder";
+
@Override
public void execute(IProject project, IProjectFacetVersion facetVersion,
Object config, IProgressMonitor monitor)
throws CoreException {
+ PluginLogger pluginLogger = Activator.getDefault().getPluginLogger();
+
+ pluginLogger.trace("Installing facet {0} on project {1}",
facetVersion, project);
+
+ IProjectDescription description = project.getDescription();
+ ICommand[] builders = description.getBuildSpec();
+ for (ICommand builder : builders) {
+ if (builder.getBuilderName().equals(VALIDATION_BUILDER_NAME)) {
+ pluginLogger.trace("Validation builder already installed,
skipping");
+ return;
+ }
+ }
+
+ pluginLogger.trace("Installing validation builder");
+
+ ICommand[] newBuilders = new ICommand[builders.length + 1];
+ System.arraycopy(builders, 0, newBuilders, 0, builders.length);
+ ICommand validationCommand = description.newCommand();
+ validationCommand.setBuilderName(VALIDATION_BUILDER_NAME);
+ newBuilders[newBuilders.length - 1] = validationCommand;
+
+ description.setBuildSpec(newBuilders);
+
+ project.setDescription(description, monitor);
+
+ pluginLogger.trace("Installed validation builder");
+
}
}