fix EASYANT-70 Specified targets order not kept when building multi-modules (thanks to Jérôme Leroux)
diff --git a/src/main/java/org/apache/easyant/tasks/SubModule.java b/src/main/java/org/apache/easyant/tasks/SubModule.java
index 7d05658..b53a4ff 100644
--- a/src/main/java/org/apache/easyant/tasks/SubModule.java
+++ b/src/main/java/org/apache/easyant/tasks/SubModule.java
@@ -307,7 +307,7 @@
      * Filter the active set of targets to only those defined in the given project.
      */
     private String filterTargets(Project subProject) {
-        Set<String> filteredTargets = new HashSet<String>();
+        List<String> filteredTargets = new ArrayList<String>();
         Set<?> keys = subProject.getTargets().keySet();
 
         for (String target : targets) {
diff --git a/src/test/java/org/apache/easyant/tasks/SubModuleTest.java b/src/test/java/org/apache/easyant/tasks/SubModuleTest.java
index a0f3c4d..22a9a1f 100644
--- a/src/test/java/org/apache/easyant/tasks/SubModuleTest.java
+++ b/src/test/java/org/apache/easyant/tasks/SubModuleTest.java
@@ -18,8 +18,16 @@
 
 package org.apache.easyant.tasks;
 
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+
 import org.apache.easyant.core.EasyAntMagicNames;
 import org.apache.easyant.core.ant.listerners.MultiModuleLogger;
+import org.apache.easyant.tasks.SubModule.TargetList;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Path;
@@ -29,13 +37,6 @@
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
 public class SubModuleTest extends AntTaskBaseTest {
 
     private SubModule submodule;
@@ -159,4 +160,29 @@
         assertThat(submodule.getProject().getReference(MultiModuleLogger.EXECUTION_TIMER_BUILD_RESULTS),
                 notNullValue());
     }
+        
+    @Test
+    public void shouldRunTargetInRightOrder() throws URISyntaxException {
+        configureBuildLogger(submodule.getProject(), Project.MSG_DEBUG);
+        
+        Path path = new Path(submodule.getProject());
+        FileSet fs = new FileSet();
+        File multimodule = new File(this.getClass().getResource("multimodule").toURI());
+        fs.setDir(multimodule);
+        path.addFileset(fs);
+        path.createPath();
+        
+        submodule.setBuildpath(path);
+        submodule.setTargets(new TargetList("modulewithtarget:firstTarget", "modulewithtarget:secondTarget", "modulewithtarget:thirdTarget"));
+        submodule.execute();
+                
+        assertLogContaining("Executing [modulewithtarget:firstTarget, modulewithtarget:secondTarget, modulewithtarget:thirdTarget] on module1");
+        assertLogContaining("Executing [modulewithtarget:firstTarget, modulewithtarget:secondTarget, modulewithtarget:thirdTarget] on module2");
+        assertLogContaining("ant.project.invoked-targets -> modulewithtarget:firstTarget,modulewithtarget:secondTarget,modulewithtarget:thirdTarget");
+        assertLogContaining("project.executed.targets -> modulewithtarget:firstTarget,modulewithtarget:secondTarget,modulewithtarget:thirdTarget");
+        assertLogContaining("firstProperty=first secondProperty=second thirdProperty=third");
+        
+        assertThat(submodule.getProject().getReference(MultiModuleLogger.EXECUTION_TIMER_BUILD_RESULTS),
+                notNullValue());
+    }
 }
diff --git a/src/test/resources/repositories/plugins/mycompany/modulewithtarget/ants/modulewithtarget-0.1.ant b/src/test/resources/repositories/plugins/mycompany/modulewithtarget/ants/modulewithtarget-0.1.ant
index cf1c9bb..9f45420 100644
--- a/src/test/resources/repositories/plugins/mycompany/modulewithtarget/ants/modulewithtarget-0.1.ant
+++ b/src/test/resources/repositories/plugins/mycompany/modulewithtarget/ants/modulewithtarget-0.1.ant
@@ -19,4 +19,22 @@
 	    <echo>a message from mytarget</echo>
 		<property name="apropertyinmytarget" value="foobar"/>
 	</target>
+	
+	<target name="modulewithtarget:firstTarget">
+		<property name="firstProperty" value="first"/>
+	</target>
+	
+	<target name="modulewithtarget:secondTarget">
+		<property name="firstProperty" value="invalid"/>
+		<property name="secondProperty" value="second"/>
+	</target>
+	
+	<target name="modulewithtarget:thirdTarget">	    
+		<property name="firstProperty" value="invalid"/>
+		<property name="secondProperty" value="invalid"/>
+		<property name="thirdProperty" value="third"/>
+		
+		<echo>firstProperty=${firstProperty} secondProperty=${secondProperty} thirdProperty=${thirdProperty}</echo>
+	</target>
+	
 </project>
\ No newline at end of file