eclipse plugin: add support for and building for campaign projects
This commit is contained in:
parent
8f5c79a945
commit
75971a6832
5 changed files with 93 additions and 5 deletions
|
@ -3,5 +3,7 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="var" path="ant-launcher.jar"/>
|
||||
<classpathentry kind="var" path="ant.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* @author Timotei Dolean
|
||||
*/
|
||||
package wesnoth_eclipse_plugin.utils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.tools.ant.BuildLogger;
|
||||
import org.apache.tools.ant.DefaultLogger;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.ProjectHelper;
|
||||
|
||||
public class AntUtils
|
||||
{
|
||||
/**
|
||||
* Runs the specified ant file, and returns the output of the runned file
|
||||
* @param antFile
|
||||
* @param properties the hasmap with userproperties to be added to the ant file
|
||||
* @return
|
||||
*/
|
||||
public static String runAnt(String antFile, HashMap<String,String> properties)
|
||||
{
|
||||
final Project project = new Project();
|
||||
ByteArrayOutputStream out=null;
|
||||
|
||||
try
|
||||
{
|
||||
out = new ByteArrayOutputStream();
|
||||
project.addBuildListener(AntUtils.createLogger(out));
|
||||
project.init();
|
||||
File buildFile = new File(antFile);
|
||||
ProjectHelper.configureProject(project, buildFile);
|
||||
|
||||
Iterator<String> iterator = properties.keySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
String key = iterator.next();
|
||||
String value = properties.get(key);
|
||||
project.setUserProperty(key,value);
|
||||
}
|
||||
project.executeTarget(project.getDefaultTarget());
|
||||
}
|
||||
catch (RuntimeException exc)
|
||||
{
|
||||
exc.printStackTrace();
|
||||
}
|
||||
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the default build logger for sending build events to the ant log.
|
||||
*/
|
||||
private static BuildLogger createLogger( ByteArrayOutputStream out )
|
||||
{
|
||||
DefaultLogger logger = new DefaultLogger();
|
||||
|
||||
logger.setMessageOutputLevel(Project.MSG_INFO);
|
||||
logger.setOutputPrintStream(new PrintStream(out));
|
||||
logger.setErrorPrintStream(new PrintStream(out));
|
||||
logger.setEmacsMode(false);
|
||||
|
||||
return logger;
|
||||
}
|
||||
}
|
|
@ -80,7 +80,7 @@ public class CampaignNewWizard extends Wizard implements INewWizard {
|
|||
}
|
||||
public void createProject(IProgressMonitor monitor)
|
||||
{
|
||||
monitor.beginTask("Creating the project structure...", 10);
|
||||
monitor.beginTask("Creating the project structure...", 15);
|
||||
|
||||
try {
|
||||
IProject currentProject = page0_.getProjectHandle();
|
||||
|
@ -105,6 +105,11 @@ public class CampaignNewWizard extends Wizard implements INewWizard {
|
|||
|
||||
// campaign_name.pbl - for uploading the campaign on the webserver
|
||||
createFile(currentProject, page1_.getCampaignName()+".pbl",prepareTemplate("pbl"));
|
||||
monitor.worked(2);
|
||||
|
||||
createFile(currentProject, "build.xml", prepareTemplate("build.xml"));
|
||||
monitor.worked(4);
|
||||
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -153,9 +158,7 @@ public class CampaignNewWizard extends Wizard implements INewWizard {
|
|||
}
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.wizard.Wizard#canFinish()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean canFinish() {
|
||||
IWizardPage page = getContainer().getCurrentPage();
|
||||
|
|
13
utils/java/eclipse_plugin/templates/build.xml
Normal file
13
utils/java/eclipse_plugin/templates/build.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="$$project_name" default="copyAll">
|
||||
<!-- <property file="build.properties"/> -->
|
||||
<target name="copyAll">
|
||||
<copy verbose="true" todir="${wesnoth.user.dir}/data/add-ons/">
|
||||
<fileset dir="">
|
||||
<!-- <exclude name=".project"/> -->
|
||||
<exclude name="build.xml"/>
|
||||
<exclude name="build.properties"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
</project>
|
|
@ -3,4 +3,5 @@
|
|||
campaign_structure templates/camp_structure.txt
|
||||
campaign templates/campaign.txt
|
||||
scenario templates/scenario.txt
|
||||
pbl templates/pbl.txt
|
||||
pbl templates/pbl.txt
|
||||
build.xml templates/build.xml
|
||||
|
|
Loading…
Add table
Reference in a new issue