mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-01 00:33:56 +00:00
eclipse plugin: regenerate 'build.xml' when it's missing,
...so build can continue
This commit is contained in:
parent
4f7f57fb35
commit
ef078b5162
@ -18,9 +18,6 @@ import org.osgi.framework.BundleContext;
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin
|
||||
{
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "Wesnoth_Eclipse_Plugin";
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
@ -65,7 +62,7 @@ public class Activator extends AbstractUIPlugin
|
||||
*/
|
||||
public static ImageDescriptor getImageDescriptor(String path)
|
||||
{
|
||||
return imageDescriptorFromPlugin(PLUGIN_ID, path);
|
||||
return imageDescriptorFromPlugin(Constants.PLUGIN_ID, path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,11 @@ import org.eclipse.xtext.ui.XtextProjectHelper;
|
||||
*/
|
||||
public class Constants
|
||||
{
|
||||
/** Plugin related */
|
||||
public static final String PLUGIN_FULL_PATH =
|
||||
Constants.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "/";
|
||||
public static final String PLUGIN_ID = "Wesnoth_Eclipse_Plugin";
|
||||
|
||||
/** Preferences Constants **/
|
||||
public static final String P_WESNOTH_EXEC_PATH = "wesnoth_exec_path";
|
||||
public static final String P_WESNOTH_WORKING_DIR = "wesnoth_working_dir";
|
||||
@ -36,4 +41,7 @@ public class Constants
|
||||
/** Nature Constants **/
|
||||
public static final String NATURE_WESNOTH = "Wesnoth_Eclipse_Plugin.wesnothNature";
|
||||
public static final String NATURE_XTEXT = XtextProjectHelper.NATURE_ID;
|
||||
|
||||
/** Templates related */
|
||||
public static final String TEMPLATES_FILENAME = "templatesIndex.txt";
|
||||
}
|
||||
|
@ -9,7 +9,9 @@
|
||||
package wesnoth_eclipse_plugin.builder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@ -23,14 +25,17 @@ import org.eclipse.core.resources.IResourceVisitor;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import wesnoth_eclipse_plugin.Constants;
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.preferences.Preferences;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.utils.AntUtils;
|
||||
import wesnoth_eclipse_plugin.utils.PreprocessorUtils;
|
||||
import wesnoth_eclipse_plugin.utils.ProjectUtils;
|
||||
import wesnoth_eclipse_plugin.utils.ResourceUtils;
|
||||
import wesnoth_eclipse_plugin.utils.StringUtils;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
|
||||
@ -74,10 +79,19 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
|
||||
// in the user add-ons directory (incremental)
|
||||
if (!(new File(getProject().getLocation().toOSString() + "/build.xml").exists()))
|
||||
{
|
||||
Logger.getInstance().log("build.xml is missing",
|
||||
"The 'build.xml' file is missing. The building cannot continue.");
|
||||
// TODO: better way of handling this - maybe regenerating?
|
||||
return null;
|
||||
Logger.getInstance().log("build.xml is missing. regenerating",
|
||||
"The 'build.xml' file is missing. It will be regenerated.");
|
||||
|
||||
List<ReplaceableParameter> params = new ArrayList<ReplaceableParameter>();
|
||||
params.add(new ReplaceableParameter("$$project_name", getProject().getName()));
|
||||
params.add(new ReplaceableParameter("$$project_dir_name",
|
||||
getProject().getName().equals("User Addons")? "" : getProject().getName()));
|
||||
ResourceUtils.createBuildXMLFile(
|
||||
getProject().getLocation().toOSString() + "/build.xml", params);
|
||||
|
||||
getProject().refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
|
||||
Logger.getInstance().log("build.xml regenerated",
|
||||
"The 'build.xml' file was successfully regenerated.");
|
||||
}
|
||||
monitor.worked(2);
|
||||
|
||||
|
@ -12,8 +12,8 @@ import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
|
||||
import wesnoth_eclipse_plugin.schema.SchemaParser;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.GUIUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
public class ReloadFilesHandler extends AbstractHandler
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package wesnoth_eclipse_plugin.wizards;
|
||||
package wesnoth_eclipse_plugin.templates;
|
||||
|
||||
public class ReplaceableParameter{
|
||||
public String paramName;
|
@ -6,7 +6,7 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package wesnoth_eclipse_plugin.wizards;
|
||||
package wesnoth_eclipse_plugin.templates;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -17,13 +17,14 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import wesnoth_eclipse_plugin.Constants;
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.utils.Pair;
|
||||
import wesnoth_eclipse_plugin.utils.StringUtils;
|
||||
|
||||
public class TemplateProvider
|
||||
{
|
||||
private static TemplateProvider instance_;
|
||||
private static TemplateProvider instance_;
|
||||
private final HashMap<String, String> templates_ = new HashMap<String, String>();
|
||||
|
||||
public static TemplateProvider getInstance()
|
||||
@ -36,10 +37,6 @@ public class TemplateProvider
|
||||
return instance_;
|
||||
}
|
||||
|
||||
public final String templatesFile = "templatesIndex.txt";
|
||||
|
||||
private final String pluginFullPath_ = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
|
||||
/**
|
||||
* Loads the templates from the file system
|
||||
*/
|
||||
@ -47,11 +44,11 @@ public class TemplateProvider
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.getInstance().log("reading templates from: " + pluginFullPath_ + templatesFile);
|
||||
Logger.getInstance().log("reading templates from: " +
|
||||
Constants.PLUGIN_FULL_PATH + Constants.TEMPLATES_FILENAME);
|
||||
|
||||
BufferedReader reader =
|
||||
new BufferedReader(new FileReader(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()
|
||||
+ templatesFile));
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new FileReader(Constants.PLUGIN_FULL_PATH + Constants.TEMPLATES_FILENAME));
|
||||
BufferedReader tmpReader;
|
||||
String line, tmpLine, content;
|
||||
|
||||
@ -70,15 +67,15 @@ public class TemplateProvider
|
||||
|
||||
content = "";
|
||||
|
||||
if (new File(pluginFullPath_ + tokensStrings[1]).exists())
|
||||
if (new File(Constants.PLUGIN_FULL_PATH + tokensStrings[1]).exists())
|
||||
{
|
||||
tmpReader = new BufferedReader(new FileReader(pluginFullPath_ + tokensStrings[1]));
|
||||
tmpReader = new BufferedReader(
|
||||
new FileReader(Constants.PLUGIN_FULL_PATH + tokensStrings[1]));
|
||||
while ((tmpLine = tmpReader.readLine()) != null)
|
||||
{
|
||||
content += tmpLine + '\n';
|
||||
}
|
||||
templates_.put(tokensStrings[0], content);
|
||||
// System.out.println(String.format("read %s with content: %s\n",tokensStrings[0],content));
|
||||
tmpReader.close();
|
||||
}
|
||||
}
|
||||
@ -95,10 +92,11 @@ public class TemplateProvider
|
||||
* @param parameters The parameters to replace into the template
|
||||
* @return
|
||||
*/
|
||||
public String getProcessedTemplate(String templateName, ArrayList<ReplaceableParameter> parameters)
|
||||
public String getProcessedTemplate(String templateName,
|
||||
List<ReplaceableParameter> parameters)
|
||||
{
|
||||
String tmpTemplate = TemplateProvider.getInstance().getTemplate(templateName);
|
||||
if (tmpTemplate == null)
|
||||
if (tmpTemplate == null || parameters == null)
|
||||
return null;
|
||||
|
||||
String result = "";
|
@ -18,6 +18,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
@ -29,6 +30,8 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
|
||||
public class ResourceUtils
|
||||
{
|
||||
@ -207,4 +210,25 @@ public class ResourceUtils
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the 'build.xml' with the specified path
|
||||
* @param path The full path to the 'build.xml' file
|
||||
* @param params The parameters list to replace in the template of 'build.xml'
|
||||
*/
|
||||
public static void createBuildXMLFile(String path,
|
||||
List<ReplaceableParameter> params)
|
||||
{
|
||||
try{
|
||||
File antFile = new File(path);
|
||||
antFile.createNewFile();
|
||||
FileWriter writer = new FileWriter(antFile);
|
||||
writer.write(
|
||||
TemplateProvider.getInstance().getProcessedTemplate("build_xml", params));
|
||||
writer.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -39,8 +39,8 @@ import wesnoth_eclipse_plugin.Activator;
|
||||
import wesnoth_eclipse_plugin.Constants;
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.preferences.Preferences;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
|
||||
public class WorkspaceUtils
|
||||
{
|
||||
|
@ -23,13 +23,13 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
|
||||
import wesnoth_eclipse_plugin.Constants;
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.Pair;
|
||||
import wesnoth_eclipse_plugin.utils.ProjectUtils;
|
||||
import wesnoth_eclipse_plugin.utils.ResourceUtils;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
public class CampaignNewWizard extends NewWizardTemplate
|
||||
{
|
||||
|
@ -23,13 +23,13 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
|
||||
import wesnoth_eclipse_plugin.Constants;
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.Pair;
|
||||
import wesnoth_eclipse_plugin.utils.ProjectUtils;
|
||||
import wesnoth_eclipse_plugin.utils.ResourceUtils;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
public class EmptyProjectNewWizard extends NewWizardTemplate
|
||||
{
|
||||
|
@ -31,10 +31,10 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
public class EraNewWizard extends NewWizardTemplate
|
||||
{
|
||||
|
@ -31,10 +31,10 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
public class FactionNewWizard extends NewWizardTemplate
|
||||
{
|
||||
|
@ -20,9 +20,9 @@ import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.StringUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardPageTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
public class WizardLauncherPage1 extends NewWizardPageTemplate
|
||||
{
|
||||
|
@ -32,13 +32,13 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.GUIUtils;
|
||||
import wesnoth_eclipse_plugin.utils.ProjectUtils;
|
||||
import wesnoth_eclipse_plugin.utils.ResourceUtils;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
/**
|
||||
* This is a sample new wizard. Its role is to create a new file resource in the
|
||||
|
@ -27,12 +27,12 @@ import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import wesnoth_eclipse_plugin.jface.DoubleInputDialog;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.GUIUtils;
|
||||
import wesnoth_eclipse_plugin.utils.ListUtils;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
@Deprecated
|
||||
public class MoveTypeWizard extends NewWizardTemplate
|
||||
|
@ -27,12 +27,12 @@ import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Spinner;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.GUIUtils;
|
||||
import wesnoth_eclipse_plugin.utils.ListUtils;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
@Deprecated
|
||||
public class RaceWizard extends NewWizardTemplate
|
||||
|
@ -10,11 +10,11 @@ package wesnoth_eclipse_plugin.wizards.unit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.GUIUtils;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
@Deprecated
|
||||
public class UnitTypeWizard extends NewWizardTemplate
|
||||
|
@ -30,11 +30,11 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
import wesnoth_eclipse_plugin.Logger;
|
||||
import wesnoth_eclipse_plugin.templates.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.templates.TemplateProvider;
|
||||
import wesnoth_eclipse_plugin.utils.GUIUtils;
|
||||
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
|
||||
import wesnoth_eclipse_plugin.wizards.NewWizardTemplate;
|
||||
import wesnoth_eclipse_plugin.wizards.ReplaceableParameter;
|
||||
import wesnoth_eclipse_plugin.wizards.TemplateProvider;
|
||||
|
||||
@Deprecated
|
||||
public class UnitsNewWizard extends NewWizardTemplate
|
||||
|
Loading…
x
Reference in New Issue
Block a user