Index: /applications/editors/josm/plugins/multipoly/build.xml
===================================================================
--- /applications/editors/josm/plugins/multipoly/build.xml	(revision 19455)
+++ /applications/editors/josm/plugins/multipoly/build.xml	(revision 19456)
@@ -1,76 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+** This is the build file for the multipoly plugin.
+**
+** Maintaining versions
+** ====================
+** see README.template
+**
+** Usage
+** =====
+** To build it run
+**
+**    > ant  dist
+**
+** To install the generated plugin locally (in you default plugin directory) run
+**
+**    > ant  install
+**
+** The generated plugin jar is not automatically available in JOSMs plugin configuration
+** dialog. You have to check it in first.
+**
+** Use the ant target 'publish' to check in the plugin and make it available to other
+** JOSM users:
+**    set the properties commit.message and plugin.main.version
+** and run
+**    > ant  publish
+**
+**
+-->
 <project name="multipoly" default="dist" basedir=".">
 
- <!-- compilation properties -->
- <property name="josm.build.dir"	value="../../core"/>
- <property name="josm.home.dir"	value="${user.home}/.josm"/>
- <property name="josm"			location="../../core/dist/josm-custom.jar" />
- <property name="plugin.build.dir"	value="build"/>
- <property name="plugin.dist.dir"	value="../../dist"/>
- <property name="plugin.name"		value="${ant.project.name}"/>
- <property name="plugin.jar"		value="${plugin.dist.dir}/${plugin.name}.jar"/>
-
- <!-- There's no josm.jar in the svn, so point "josm" to a local copy of your JOSM binary -->
- <property name="josm" location="../../core/dist/josm-custom.jar" />
-
- <property name="ant.build.javac.target" value="1.5"/>
-
- <target name="init">
-  <mkdir dir="${plugin.build.dir}"></mkdir>
-  <mkdir dir="${plugin.dist.dir}"></mkdir>
- </target>
-
- <target name="compile" depends="init">
-  <echo message="creating ${plugin.jar}"/>
-  <javac srcdir="src" target="1.5" classpath="${josm}" destdir="build" debug="true">
-   <include name="**/*.java" />
-  </javac>
- </target>
-
- <target name="revision">
-  <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
-   <env key="LANG" value="C"/>
-   <arg value="info"/>
-   <arg value="--xml"/>
-   <arg value="."/>
-  </exec>
-  <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
-  <delete file="REVISION"/>
- </target>
-
- <target name="dist" depends="compile,revision">
-  <copy todir="${plugin.build.dir}/images">
-     <fileset dir="images"/>
-  </copy>
-  <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
-   <manifest>
-    <attribute name="Author" value="Bilbo"/>
-    <attribute name="Plugin-Class" value="multipoly.MultipolyPlugin" />
-    <attribute name="Plugin-Description" value="Create multipolygons by one click, much easier than standard way with relation editor." />
-    <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
-    <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
-    <attribute name="Plugin-Link" value="http://svn.openstreetmap.org/applications/editors/josm/plugins/multipoly/"/>
-    <attribute name="Plugin-Mainversion" value="2578"/>
-   </manifest>
-  </jar>
- </target>
-
- <target name="clean">
-  <delete dir="${plugin.build.dir}" />
-  <delete file="${plugin.jar}" />
- </target>
-
- <target name="clean_install">
-  <delete file="${plugins}/multipoly.jar" />
- </target>
-
- <target name="install" depends="dist">
-  <property environment="env"/>
-  <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
-   <and>
-    <os family="windows"/>
-   </and>
-  </condition>
-  <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
- </target>
+
+	<!-- enter the SVN commit message -->
+	<property name="commit.message" value="Changed the constructor signature of the plugin main class" />
+	<!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
+	<property name="plugin.main.version" value="2830" />
+
+
+	<!-- compilation properties -->
+	<property name="josm.build.dir" value="../../core" />
+	<property name="josm.home.dir" value="${user.home}/.josm" />
+	<property name="josm" location="../../core/dist/josm-custom.jar" />
+	<property name="plugin.build.dir" value="build" />
+	<property name="plugin.dist.dir" value="../../dist" />
+	<property name="plugin.name" value="${ant.project.name}" />
+	<property name="plugin.jar" value="${plugin.dist.dir}/${plugin.name}.jar" />
+
+	<!-- There's no josm.jar in the svn, so point "josm" to a local copy of your JOSM binary -->
+	<property name="josm" location="../../core/dist/josm-custom.jar" />
+
+	<property name="ant.build.javac.target" value="1.5" />
+
+	<target name="init">
+		<mkdir dir="${plugin.build.dir}">
+		</mkdir>
+		<mkdir dir="${plugin.dist.dir}">
+		</mkdir>
+	</target>
+
+	<target name="compile" depends="init">
+		<echo message="creating ${plugin.jar}" />
+		<javac srcdir="src" target="1.5" classpath="${josm}" destdir="build" debug="true">
+			<include name="**/*.java" />
+		</javac>
+	</target>
+
+	<target name="revision">
+		<exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
+			<env key="LANG" value="C" />
+			<arg value="info" />
+			<arg value="--xml" />
+			<arg value="." />
+		</exec>
+		<xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true" />
+		<delete file="REVISION" />
+	</target>
+
+	<target name="dist" depends="compile,revision">
+		<copy todir="${plugin.build.dir}/images">
+			<fileset dir="images" />
+		</copy>
+		<jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
+			<manifest>
+				<attribute name="Author" value="Bilbo" />
+				<attribute name="Plugin-Class" value="multipoly.MultipolyPlugin" />
+				<attribute name="Plugin-Description" value="Create multipolygons by one click, much easier than standard way with relation editor." />
+				<attribute name="Plugin-Version" value="${version.entry.commit.revision}" />
+				<attribute name="Plugin-Date" value="${version.entry.commit.date}" />
+				<attribute name="Plugin-Link" value="http://svn.openstreetmap.org/applications/editors/josm/plugins/multipoly/" />
+				<attribute name="Plugin-Mainversion" value="${plugin.main.version}" />
+			</manifest>
+		</jar>
+	</target>
+
+	<target name="clean">
+		<delete dir="${plugin.build.dir}" />
+		<delete file="${plugin.jar}" />
+	</target>
+
+	<target name="clean_install">
+		<delete file="${plugins}/multipoly.jar" />
+	</target>
+
+	<target name="install" depends="dist">
+		<property environment="env" />
+		<condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
+			<and>
+				<os family="windows" />
+			</and>
+		</condition>
+		<copy file="${plugin.jar}" todir="${josm.plugins.dir}" />
+	</target>
+
+	<!--
+	************************** Publishing the plugin *********************************** 
+	-->
+	<!--
+		** extracts the JOSM release for the JOSM version in ../core and saves it in the 
+		** property ${coreversion.info.entry.revision}
+		**
+		-->
+	<target name="core-info">
+		<exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
+			<env key="LANG" value="C" />
+			<arg value="info" />
+			<arg value="--xml" />
+			<arg value="../../core" />
+		</exec>
+		<xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true" />
+		<echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
+		<echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
+		<delete file="core.info.xml" />
+	</target>
+
+	<!--
+		** commits the source tree for this plugin
+		-->
+	<target name="commit-current">
+		<echo>Commiting the plugin source with message '${commit.message}' ...</echo>
+		<exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
+			<env key="LANG" value="C" />
+			<arg value="commit" />
+			<arg value="-m '${commit.message}'" />
+			<arg value="." />
+		</exec>
+	</target>
+
+	<!--
+		** updates (svn up) the source tree for this plugin
+		-->
+	<target name="update-current">
+		<echo>Updating plugin source ...</echo>
+		<exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
+			<env key="LANG" value="C" />
+			<arg value="up" />
+			<arg value="." />
+		</exec>
+		<echo>Updating ${plugin.jar} ...</echo>
+		<exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
+			<env key="LANG" value="C" />
+			<arg value="up" />
+			<arg value="../dist/${plugin.jar}" />
+		</exec>
+	</target>
+
+	<!--
+		** commits the plugin.jar 
+		-->
+	<target name="commit-dist">
+		<echo>
+	***** Properties of published ${plugin.jar} *****
+	Commit message    : '${commit.message}'					
+	Plugin-Mainversion: ${plugin.main.version}
+	JOSM build version: ${coreversion.info.entry.revision}
+	Plugin-Version    : ${version.entry.commit.revision}
+	***** / Properties of published ${plugin.jar} *****					
+						
+	Now commiting ${plugin.jar} ...
+	</echo>
+		<exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
+			<env key="LANG" value="C" />
+			<arg value="-m '${commit.message}'" />
+			<arg value="commit" />
+			<arg value="${plugin.jar}" />
+		</exec>
+	</target>
+
+	<!-- ** make sure svn is present as a command line tool ** -->
+	<target name="ensure-svn-present">
+		<exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
+			<env key="LANG" value="C" />
+			<arg value="--version" />
+		</exec>
+		<fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
+			<!-- return code not set at all? Most likely svn isn't installed -->
+			<condition>
+				<not>
+					<isset property="svn.exit.code" />
+				</not>
+			</condition>
+		</fail>
+		<fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
+			<!-- error code from SVN? Most likely svn is not what we are looking on this system -->
+			<condition>
+				<isfailure code="${svn.exit.code}" />
+			</condition>
+		</fail>
+	</target>
+
+	<target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
+	</target>
 
 </project>
Index: /applications/editors/josm/plugins/multipoly/src/multipoly/MultipolyAction.java
===================================================================
--- /applications/editors/josm/plugins/multipoly/src/multipoly/MultipolyAction.java	(revision 19455)
+++ /applications/editors/josm/plugins/multipoly/src/multipoly/MultipolyAction.java	(revision 19456)
@@ -30,130 +30,152 @@
 /**
  * Create multipolygon from selected ways automatically.
- *
+ * 
  * New relation with type=multipolygon is created
- *
- * If one or more of ways is already in relation with type=multipolygon or the way is not closed,
- * then error is reported and no relation is created
- *
- * The "inner" and "outer" roles are guessed automatically.
- * First, bbox is calculated for each way. then the largest area is assumed to be outside
- * and the rest inside
- * In cases with one "outside" area and several cut-ins, the guess should be always good ...
- * In more complex (multiple outer areas) or buggy (inner and outer ways intersect) scenarios
- * the result is likely to be wrong.
+ * 
+ * If one or more of ways is already in relation with type=multipolygon or the
+ * way is not closed, then error is reported and no relation is created
+ * 
+ * The "inner" and "outer" roles are guessed automatically. First, bbox is
+ * calculated for each way. then the largest area is assumed to be outside and
+ * the rest inside In cases with one "outside" area and several cut-ins, the
+ * guess should be always good ... In more complex (multiple outer areas) or
+ * buggy (inner and outer ways intersect) scenarios the result is likely to be
+ * wrong.
  */
 public class MultipolyAction extends JosmAction {
 
- public MultipolyAction() {
-  super(tr("Create multipolygon"), "multipoly_create", tr("Create multipolygon."),
-  Shortcut.registerShortcut("tools:multipoly", tr("Tool: {0}", tr("Create multipolygon")),
-  KeyEvent.VK_M, Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true);
- }
+	public MultipolyAction() {
+		super(tr("Create multipolygon"), "multipoly_create",
+				tr("Create multipolygon."), Shortcut.registerShortcut(
+						"tools:multipoly", tr("Tool: {0}",
+								tr("Create multipolygon")), KeyEvent.VK_M,
+						Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true);
+	}
 
- /**
-  * The action button has been clicked
-  * @param e Action Event
-  */
- public void actionPerformed(ActionEvent e) {
+	/**
+	 * The action button has been clicked
+	 * 
+	 * @param e
+	 *            Action Event
+	 */
+	public void actionPerformed(ActionEvent e) {
 
-  // Get all ways in some type=multipolygon relation
-  HashSet<OsmPrimitive> relationsInMulti = new HashSet<OsmPrimitive>();
-  for (Relation r : Main.main.getCurrentDataSet().getRelations()) {
-   if (!r.isUsable()) continue;
-   if (r.get("type")!="multipolygon") continue;
-   for (RelationMember rm : r.getMembers()) {
-    OsmPrimitive m=rm.getMember();
-    if (m instanceof Way) {
-     relationsInMulti.add(m);
-    }
-   }
-  }
+		// Get all ways in some type=multipolygon relation
+		HashSet<OsmPrimitive> relationsInMulti = new HashSet<OsmPrimitive>();
+		for (Relation r : Main.main.getCurrentDataSet().getRelations()) {
+			if (!r.isUsable())
+				continue;
+			if (r.get("type") != "multipolygon")
+				continue;
+			for (RelationMember rm : r.getMembers()) {
+				OsmPrimitive m = rm.getMember();
+				if (m instanceof Way) {
+					relationsInMulti.add(m);
+				}
+			}
+		}
 
-  //List of selected ways
-  List<Way> selectedWays = new ArrayList<Way>();
-  //Area of largest way (in square degrees)
-  double maxarea=0;
-  //Which way is the largest one (outer)
-  Way maxWay=null;
+		// List of selected ways
+		List<Way> selectedWays = new ArrayList<Way>();
+		// Area of largest way (in square degrees)
+		double maxarea = 0;
+		// Which way is the largest one (outer)
+		Way maxWay = null;
 
-  // For every selected way
-  for (OsmPrimitive osm : Main.main.getCurrentDataSet().getSelected()) {
-   if (osm instanceof Way) {
-    Way way = (Way)osm;
-    //Check if way is already in another multipolygon
-    if (relationsInMulti.contains(osm)) {
-     JOptionPane.showMessageDialog(Main.parent,tr("One of the selected ways is already part of another multipolygon."));
-     return;
-    }
-    EastNorth first=null,last=null;
-    //Boundingbox of way
-    double minx=9999,miny=9999,maxx=-9999,maxy=-9999;
-    for (Pair<Node,Node> seg : way.getNodePairs(false)) {
-     if (first==null) first=seg.a.getEastNorth();
-     last=seg.b.getEastNorth();
-     double x=seg.a.getEastNorth().east();
-     double y=seg.a.getEastNorth().north();
-     if (x<minx) minx=x;
-     if (y<miny) miny=y;
-     if (x>maxx) maxx=x;
-     if (y>maxy) maxy=y;
-    }
-    //Check if first and last node are the same
-    if (!first.equals(last)) {
-     JOptionPane.showMessageDialog(Main.parent,tr("Multipolygon must consist only of closed ways."));
-     return;
-    }
-    //Determine area
-    double area=(maxx-minx)*(maxy-miny);
-    selectedWays.add(way);
-    if (area>maxarea) {
-     maxarea=area;
-     maxWay=way;
-    }
-   }
-  }
+		// For every selected way
+		for (OsmPrimitive osm : Main.main.getCurrentDataSet().getSelected()) {
+			if (osm instanceof Way) {
+				Way way = (Way) osm;
+				// Check if way is already in another multipolygon
+				if (relationsInMulti.contains(osm)) {
+					JOptionPane
+							.showMessageDialog(
+									Main.parent,
+									tr("One of the selected ways is already part of another multipolygon."));
+					return;
+				}
+				EastNorth first = null, last = null;
+				// Boundingbox of way
+				double minx = 9999, miny = 9999, maxx = -9999, maxy = -9999;
+				for (Pair<Node, Node> seg : way.getNodePairs(false)) {
+					if (first == null)
+						first = seg.a.getEastNorth();
+					last = seg.b.getEastNorth();
+					double x = seg.a.getEastNorth().east();
+					double y = seg.a.getEastNorth().north();
+					if (x < minx)
+						minx = x;
+					if (y < miny)
+						miny = y;
+					if (x > maxx)
+						maxx = x;
+					if (y > maxy)
+						maxy = y;
+				}
+				// Check if first and last node are the same
+				if (!first.equals(last)) {
+					JOptionPane
+							.showMessageDialog(
+									Main.parent,
+									tr("Multipolygon must consist only of closed ways."));
+					return;
+				}
+				// Determine area
+				double area = (maxx - minx) * (maxy - miny);
+				selectedWays.add(way);
+				if (area > maxarea) {
+					maxarea = area;
+					maxWay = way;
+				}
+			}
+		}
 
-  if (Main.map == null) {
-   JOptionPane.showMessageDialog(Main.parent, tr("No data loaded."));
-   return;
-  }
+		if (Main.map == null) {
+			JOptionPane.showMessageDialog(Main.parent, tr("No data loaded."));
+			return;
+		}
 
-  if (selectedWays.size()<2) {
-   JOptionPane.showMessageDialog(Main.parent, tr("You must select at least two ways."));
-   return;
-  }
+		if (selectedWays.size() < 2) {
+			JOptionPane.showMessageDialog(Main.parent,
+					tr("You must select at least two ways."));
+			return;
+		}
 
-  Collection<Command> cmds = new LinkedList<Command>();
-  //Create new relation
-  Relation rel=new Relation();
-  rel.put("type","multipolygon");
-  //Add ways to it
-  for (int i=0;i<selectedWays.size();i++) {
-   Way s=selectedWays.get(i);
-   String xrole="inner";
-   if (s==maxWay) xrole="outer";
-   RelationMember rm=new RelationMember(xrole,s);
-   rel.addMember(rm);
-  }
-  //Add relation
-  cmds.add(new AddCommand(rel));
-  //Commit
-  Main.main.undoRedo.add(new SequenceCommand(tr("Create multipolygon"), cmds));
-  Main.map.repaint();
- }
+		Collection<Command> cmds = new LinkedList<Command>();
+		// Create new relation
+		Relation rel = new Relation();
+		rel.put("type", "multipolygon");
+		// Add ways to it
+		for (int i = 0; i < selectedWays.size(); i++) {
+			Way s = selectedWays.get(i);
+			String xrole = "inner";
+			if (s == maxWay)
+				xrole = "outer";
+			RelationMember rm = new RelationMember(xrole, s);
+			rel.addMember(rm);
+		}
+		// Add relation
+		cmds.add(new AddCommand(rel));
+		// Commit
+		Main.main.undoRedo.add(new SequenceCommand(tr("Create multipolygon"),
+				cmds));
+		Main.map.repaint();
+	}
 
- /** Enable this action only if something is selected */
- @Override protected void updateEnabledState() {
-  if (getCurrentDataSet()==null) {
-   setEnabled(false);
-  } else {
-   updateEnabledState(getCurrentDataSet().getSelected());
-  }
- }
+	/** Enable this action only if something is selected */
+	@Override
+	protected void updateEnabledState() {
+		if (getCurrentDataSet() == null) {
+			setEnabled(false);
+		} else {
+			updateEnabledState(getCurrentDataSet().getSelected());
+		}
+	}
 
- /** Enable this action only if something is selected */
- @Override protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
-  setEnabled(selection != null && !selection.isEmpty());
- }
-
+	/** Enable this action only if something is selected */
+	@Override
+	protected void updateEnabledState(
+			Collection<? extends OsmPrimitive> selection) {
+		setEnabled(selection != null && !selection.isEmpty());
+	}
 }
Index: /applications/editors/josm/plugins/multipoly/src/multipoly/MultipolyPlugin.java
===================================================================
--- /applications/editors/josm/plugins/multipoly/src/multipoly/MultipolyPlugin.java	(revision 19455)
+++ /applications/editors/josm/plugins/multipoly/src/multipoly/MultipolyPlugin.java	(revision 19456)
@@ -8,4 +8,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.plugins.Plugin;
+import org.openstreetmap.josm.plugins.PluginInformation;
 
 /**
@@ -14,27 +15,26 @@
 public class MultipolyPlugin extends Plugin {
 
-  protected String name;
+	protected String name;
 
-  public MultipolyPlugin() {
-    name = tr("Create multipolygon");
-    JMenu toolsMenu = null;
-    for (int i = 0; i < Main.main.menu.getMenuCount() && toolsMenu == null; i++) {
-      JMenu menu = Main.main.menu.getMenu(i);
-      String name = menu.getText();
-      if (name != null && name.equals(tr("Tools"))) {
-        toolsMenu = menu;
-      }
-    }
+	public MultipolyPlugin(PluginInformation info) {
+		super(info);
+		name = tr("Create multipolygon");
+		JMenu toolsMenu = null;
+		for (int i = 0; i < Main.main.menu.getMenuCount() && toolsMenu == null; i++) {
+			JMenu menu = Main.main.menu.getMenu(i);
+			String name = menu.getText();
+			if (name != null && name.equals(tr("Tools"))) {
+				toolsMenu = menu;
+			}
+		}
 
-    if (toolsMenu == null) {
-      toolsMenu = new JMenu(name);
-      toolsMenu.add(new JMenuItem(new MultipolyAction()));
-      Main.main.menu.add(toolsMenu, 2);
-    } else {
-      toolsMenu.addSeparator();
-      toolsMenu.add(new JMenuItem(new MultipolyAction()));
-    }
-
-  }
-
+		if (toolsMenu == null) {
+			toolsMenu = new JMenu(name);
+			toolsMenu.add(new JMenuItem(new MultipolyAction()));
+			Main.main.menu.add(toolsMenu, 2);
+		} else {
+			toolsMenu.addSeparator();
+			toolsMenu.add(new JMenuItem(new MultipolyAction()));
+		}
+	}
 }
