releng tools
diff --git a/plugins/org.eclipse.wtp.releng.fixups/OSGI-INF/l10n/bundle.properties b/plugins/org.eclipse.wtp.releng.fixups/OSGI-INF/l10n/bundle.properties
index b60c0e2..95e9214 100644
--- a/plugins/org.eclipse.wtp.releng.fixups/OSGI-INF/l10n/bundle.properties
+++ b/plugins/org.eclipse.wtp.releng.fixups/OSGI-INF/l10n/bundle.properties
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 2010 IBM Corporation and others.
+# 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
#Properties file for org.eclipse.wtp.releng.fixups
Bundle-Name = Releng Fixups
Bundle-Vendor = Eclipse Web Tools Platform
diff --git a/plugins/org.eclipse.wtp.releng.fixups/build.properties b/plugins/org.eclipse.wtp.releng.fixups/build.properties
index 18fb417..cd877b7 100644
--- a/plugins/org.eclipse.wtp.releng.fixups/build.properties
+++ b/plugins/org.eclipse.wtp.releng.fixups/build.properties
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 2010 IBM Corporation and others.
+# 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
diff --git a/plugins/org.eclipse.wtp.releng.fixups/plugin.xml b/plugins/org.eclipse.wtp.releng.fixups/plugin.xml
index 6a8f113..7c37e1d 100644
--- a/plugins/org.eclipse.wtp.releng.fixups/plugin.xml
+++ b/plugins/org.eclipse.wtp.releng.fixups/plugin.xml
Binary files differ
diff --git a/plugins/org.eclipse.wtp.releng.fixups/src/org/eclipse/wtp/releng/fixups/CheckAndFixConsistency.java b/plugins/org.eclipse.wtp.releng.fixups/src/org/eclipse/wtp/releng/fixups/CheckAndFixConsistency.java
index f93b889..9c1f3e1 100644
--- a/plugins/org.eclipse.wtp.releng.fixups/src/org/eclipse/wtp/releng/fixups/CheckAndFixConsistency.java
+++ b/plugins/org.eclipse.wtp.releng.fixups/src/org/eclipse/wtp/releng/fixups/CheckAndFixConsistency.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.wtp.releng.fixups;
import java.io.BufferedReader;
@@ -6,6 +16,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.io.StringBufferInputStream;
import java.io.StringWriter;
import java.util.ArrayList;
@@ -16,6 +27,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.console.ConsolePlugin;
@@ -26,6 +38,13 @@
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;
+/**
+ * Simple tool to make features more consistent. Check license property is the
+ * standard value, and if not fixes that, and write new license.html file.
+ *
+ * @author davidw
+ *
+ */
public class CheckAndFixConsistency {
@@ -34,23 +53,30 @@
private static final String LICENSE_KEY = "license=";
private static final String PLUGINID = "org.eclipse.wtp.releng.fixups";
private static final String EOL = System.getProperty("line.separator", "\n");
- // remember a slash '\' denotes continuation in a properties file, and the
- // regex expression needs to escape that, so "\\", and to get in a string,
- // each needs to be escaped, so "\\\\"
+ /*
+ * remember a slash '\' denotes continuation in a properties file, and the
+ * regex expression needs to escape that, so "\\", and to get in a string,
+ * each needs to be escaped, so that's why we need "\\\\" in continuation
+ * regex pattern
+ */
private static final String CONTINUATION = "\\\\ *$";
private static final String CONSOLE_NAME = "Releng Console";
private static boolean DEBUG = false;
- String standardlicense = null;
- ArrayList featureProjects = new ArrayList();
- ArrayList featureProjectsMissingProperties = new ArrayList();
- ArrayList featureProjectsMissingLicense = new ArrayList();
- ArrayList featuresModified = new ArrayList();
- ArrayList featuresOkNotModified = new ArrayList();
- ArrayList featuresCouldNotBeModified = new ArrayList();
+ private String standardlicense = null;
+ private ArrayList featureProjects = new ArrayList();
+ private ArrayList featureProjectsMissingProperties = new ArrayList();
+ private ArrayList featureProjectsMissingLicense = new ArrayList();
+ private ArrayList featuresModified = new ArrayList();
+ private ArrayList featuresOkNotModified = new ArrayList();
+ private ArrayList featuresCouldNotBeModified = new ArrayList();
+ private int nFeatures;
public CheckAndFixConsistency() {
}
+ /*
+ * lazy init instance variables that require IO, if not done yet.
+ */
private void init() throws IOException {
if (standardlicense == null) {
InputStream propstream = null;
@@ -74,7 +100,8 @@
*/
public Object checkAndFixConsistency() throws ExecutionException {
- Object returnobject = null;
+ // assume return is ok, unless set otherwise.
+ Object returnobject = IStatus.OK;
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
initCounterArrays();
@@ -82,6 +109,7 @@
IProject project = projects[j];
IFile file = project.getFile("feature.xml");
if (file != null && file.exists()) {
+ nFeatures++;
IFile propfile = project.getFile("feature.properties");
if (propfile != null && propfile.exists()) {
featureProjects.add(project);
@@ -101,15 +129,29 @@
}
}
- report(featureProjectsMissingProperties, "The following feature(s) contained no feature.properties file");
- report(featureProjectsMissingLicense, "The following feature(s) contained no license property");
- report(featuresOkNotModified, "The following feature(s) were found ok, and not modified");
- report(featuresModified, "The following feature(s) were modified");
- report(featuresCouldNotBeModified, "The following feature(s) needed to be modified, but for some reason could not be");
+ reportSummaryOfResults();
+
return returnobject;
}
+ private void reportSummaryOfResults() {
+ MessageConsole myConsole = findConsole(CONSOLE_NAME);
+ MessageConsoleStream out = myConsole.newMessageStream();
+ myConsole.activate();
+ out.println();
+ out.println("\tTotal number of features found: " + nFeatures);
+ out.println();
+ report(out, featureProjectsMissingProperties, "The following feature(s) contained no feature.properties file");
+ report(out, featureProjectsMissingLicense, "The following feature(s) contained no license property");
+ report(out, featuresOkNotModified, "The following feature(s) were found ok, and not modified");
+ report(out, featuresModified, "The following feature(s) were modified");
+ report(out, featuresCouldNotBeModified, "The following feature(s) needed to be modified, but for some reason could not be");
+ }
+
+ /*
+ * Make sure arrays are cleared, incase instance is ran more than once.
+ */
private void initCounterArrays() {
featureProjects.clear();
featureProjectsMissingProperties.clear();
@@ -295,15 +337,14 @@
- private void report(ArrayList tocheck, String message) {
- MessageConsole myConsole = findConsole(CONSOLE_NAME);
- myConsole.activate();
- MessageConsoleStream out = myConsole.newMessageStream();
-
-// IWorkbenchPage page = ...;//obtain the active page
-// String id = IConsoleConstants.ID_CONSOLE_VIEW;
-// IConsoleView view = (IConsoleView) page.showView(id);
-// view.display(myConsole);
+ private void report(MessageConsoleStream out, ArrayList tocheck, String message) {
+
+
+
+// IWorkbenchPage page = ...;//obtain the active page
+// String id = IConsoleConstants.ID_CONSOLE_VIEW;
+// IConsoleView view = (IConsoleView) page.showView(id);
+// view.display(myConsole);
if (tocheck != null && tocheck.size() > 0) {
@@ -317,17 +358,23 @@
}
}
- private MessageConsole findConsole(String name) {
- ConsolePlugin plugin = ConsolePlugin.getDefault();
- IConsoleManager conMan = plugin.getConsoleManager();
- IConsole[] existing = conMan.getConsoles();
- for (int i = 0; i < existing.length; i++)
- if (name.equals(existing[i].getName()))
- return (MessageConsole) existing[i];
- //no console found, so create a new one
- MessageConsole myConsole = new MessageConsole(name, null);
- conMan.addConsoles(new IConsole[]{myConsole});
- return myConsole;
- }
+ private MessageConsole findConsole(String name) {
+
+ MessageConsole myConsole = null;
+ ConsolePlugin plugin = ConsolePlugin.getDefault();
+ IConsoleManager conMan = plugin.getConsoleManager();
+ IConsole[] existing = conMan.getConsoles();
+ for (int i = 0; i < existing.length; i++)
+ if (name.equals(existing[i].getName())) {
+ myConsole = (MessageConsole) existing[i];
+ }
+ if (myConsole == null) {
+ // no console found, so create a new one
+ myConsole = new MessageConsole(name, null);
+ conMan.addConsoles(new IConsole[]{myConsole});
+ }
+
+ return myConsole;
+ }
}
diff --git a/plugins/org.eclipse.wtp.releng.fixups/src/org/eclipse/wtp/releng/fixups/handlers/CheckLicenses.java b/plugins/org.eclipse.wtp.releng.fixups/src/org/eclipse/wtp/releng/fixups/handlers/CheckLicenses.java
index 65b8174..cb4fc7a 100644
--- a/plugins/org.eclipse.wtp.releng.fixups/src/org/eclipse/wtp/releng/fixups/handlers/CheckLicenses.java
+++ b/plugins/org.eclipse.wtp.releng.fixups/src/org/eclipse/wtp/releng/fixups/handlers/CheckLicenses.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.wtp.releng.fixups.handlers;
import org.eclipse.core.commands.AbstractHandler;