Bug 565262 - [Robotics, ROS2] Dependencies of CMakeLists.txt for message packages are incomplete

- Fusion methods of duplicate PackageXMLUtils class, only version in utils folder is kept

Change-Id: I91879b91024d15212ddb97508f8668eb48589627
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
diff --git a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/CreateCompPackageXML.xtend b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/CreateCompPackageXML.xtend
index 2d165b8..b6b6e71 100644
--- a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/CreateCompPackageXML.xtend
+++ b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/CreateCompPackageXML.xtend
@@ -19,7 +19,7 @@
 
 import static extension org.eclipse.papyrus.robotics.ros2.codegen.utils.PackageTools.pkgName
 import org.eclipse.papyrus.infra.tools.file.IPFileSystemAccess
-import static extension org.eclipse.papyrus.robotics.ros2.codegen.build.PackageXMLUtils.*
+import static extension org.eclipse.papyrus.robotics.ros2.codegen.utils.PackageXMLUtils.*
 import static extension org.eclipse.papyrus.robotics.ros2.codegen.utils.ComponentUtils.getDependsPackage;
 import java.util.List
 import org.eclipse.papyrus.robotics.ros2.codegen.utils.MessageUtils
diff --git a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/CreateMsgPkgPackageXML.xtend b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/CreateMsgPkgPackageXML.xtend
index 9d9cc23..604f335 100644
--- a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/CreateMsgPkgPackageXML.xtend
+++ b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/CreateMsgPkgPackageXML.xtend
@@ -20,7 +20,7 @@
 import org.eclipse.uml2.uml.Package
 
 import static extension org.eclipse.papyrus.robotics.ros2.codegen.utils.PackageTools.pkgName
-import static extension org.eclipse.papyrus.robotics.ros2.codegen.build.PackageXMLUtils.*
+import static extension org.eclipse.papyrus.robotics.ros2.codegen.utils.PackageXMLUtils.*
 import static extension org.eclipse.papyrus.robotics.ros2.codegen.utils.MessageUtils.calcDependencies
 
 class CreateMsgPkgPackageXML {
diff --git a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/PackageXMLUtils.xtend b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/PackageXMLUtils.xtend
deleted file mode 100644
index e387134..0000000
--- a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/build/PackageXMLUtils.xtend
+++ /dev/null
@@ -1,151 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2018 CEA LIST.
- * 
- * 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- * 
- * Contributors:
- *  Ansgar Radermacher  ansgar.radermacher@cea.fr
- * 
- *****************************************************************************/
-
-package org.eclipse.papyrus.robotics.ros2.codegen.build
-
-import org.eclipse.uml2.uml.Package
-import org.eclipse.papyrus.robotics.bpc.profile.bpc.Entity
-import org.eclipse.uml2.uml.util.UMLUtil
-import org.eclipse.papyrus.robotics.bpc.profile.bpc.BPCPackage
-import org.eclipse.emf.ecore.EAttribute
-import java.util.List
-import java.util.Collections
-import org.eclipse.papyrus.robotics.ros2.preferences.Ros2PreferenceUtils
-
-/**
- * Set of utility functions for package creation
- */
-class PackageXMLUtils {
-
-	/**
-	 * Return the description of a model from the Entity stereotype
-	 */
-	static def description(List<Package> modelList) {
-		val description = getField(modelList, BPCPackage.eINSTANCE.entity_Description);
-		if (description !== null) {
-			return description
-		}
-		return "No description"
-	}
-
-	static def description(Package model) {
-		return description(Collections.singletonList(model))
-	}
-
-	/**
-	 * get author name. If authorship is set and contains a space, assume that it starts with an email address
-	 * @param modelList a list of models (belonging to the same ROS2 package) - take
-	 *		information from first model with non-null information
-	 */
-	def static getAuthorName(List<Package> modelList) {
-		val author = getField(modelList, BPCPackage.eINSTANCE.entity_Authorship);
-		if (author !== null) {
-			val idx = author.indexOf(" ");
-			if (idx > 0) {
-				return author.substring(idx + 1);
-			}
-			return author;
-		}
-		return Ros2PreferenceUtils.authorName;
-	}
-
-	def static getAuthorName(Package model) {
-		return getAuthorMail(Collections.singletonList(model))
-	}
-
-	/**
-	 * get author mail. If authorship is set and contains a space, assume that it starts with an email address
-	 * @param modelList a list of models (belonging to the same ROS2 package) - take
-	 *		information from first model with non-null information
-	 */
-	def static getAuthorMail(List<Package> modelList) {
-		val author = getField(modelList, BPCPackage.eINSTANCE.entity_Authorship);
-		if (author !== null) {
-			val idx = author.indexOf(" ");
-			if (idx > 0) {
-				return author.substring(0, idx);
-			}
-			return author;
-		}
-		return Ros2PreferenceUtils.authorMail;
-	}
-
-	def static getAuthorMail(Package model) {
-		return getAuthorMail(Collections.singletonList(model))
-	}
-
-	/**
-	 * Get maintainer name. If maintainer is set and contains a space, assume that it starts with an email address
-	 * Take maintainer information from provenance field in RobMoSys
-	 * @param modelList a list of models (belonging to the same ROS2 package) - take
-	 *		information from first model with non-null information
-	 */
-	def static getMaintainerName(List<Package> modelList) {
-		val maintainer = getField(modelList, BPCPackage.eINSTANCE.entity_Provenance);
-		if (maintainer !== null) {
-			val idx = maintainer.indexOf(" ");
-			if (idx > 0) {
-				return maintainer.substring(idx + 1);
-			}
-			return maintainer;
-		}
-		return Ros2PreferenceUtils.maintainerName;
-	}
-
-	def static getMaintainerName(Package model) {
-		return getMaintainerName(Collections.singletonList(model))
-	}
-
-	/**
-	 * Get maintainer mail. If maintainer is set and contains a space, assume that it starts with an email address
-	 * Take maintainer information from provenance field in RobMoSys
-	 * @param modelList a list of models (belonging to the same ROS2 package) - take
-	 *		information from first model with non-null information
-	 */
-	def static getMaintainerMail(List<Package> modelList) {
-		val maintainer = getField(modelList, BPCPackage.eINSTANCE.entity_Provenance);
-		if (maintainer !== null) {
-			val idx = maintainer.indexOf(" ");
-			if (idx > 0) {
-				return maintainer.substring(0, idx);
-			}
-			return maintainer;
-		}
-		return Ros2PreferenceUtils.maintainerMail;
-	}
-
-	def static getMaintainerMail(Package model) {
-		return getMaintainerMail(Collections.singletonList(model))
-	}
-
-	/**
-	 * return the first non-null field (feature) from the Entity stereotype
-	 * from a list of packages
-	 * 
-	 * @param modelList
-	 *            a list of packages (root of models)
-	 * @param feature
-	 *            The feature to query
-	 * @return the author/maintainer/... information
-	 */
-	def static String getField(List<Package> modelList, EAttribute feature) {
-		for (pkg : modelList) {
-			val application = UMLUtil.getStereotypeApplication(pkg, Entity);
-			if (application !== null && application.eGet(feature) instanceof String) {
-				return application.eGet(feature) as String;
-			}
-		}
-		return null
-	}
-}
diff --git a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/utils/PackageXMLUtils.xtend b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/utils/PackageXMLUtils.xtend
index bdffe52..843e371 100644
--- a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/utils/PackageXMLUtils.xtend
+++ b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/utils/PackageXMLUtils.xtend
@@ -1,15 +1,15 @@
 /*****************************************************************************
  * Copyright (c) 2018 CEA LIST.
- *
- *
+ * 
+ * 
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v2.0
  * which accompanies this distribution, and is available at
  * https://www.eclipse.org/legal/epl-2.0/
- *
+ * 
  * Contributors:
  *  Ansgar Radermacher  ansgar.radermacher@cea.fr
- *
+ * 
  *****************************************************************************/
 
 package org.eclipse.papyrus.robotics.ros2.codegen.utils
@@ -17,9 +17,10 @@
 import org.eclipse.uml2.uml.Package
 import org.eclipse.papyrus.robotics.bpc.profile.bpc.Entity
 import org.eclipse.uml2.uml.util.UMLUtil
-import org.eclipse.uml2.uml.Element
 import org.eclipse.papyrus.robotics.bpc.profile.bpc.BPCPackage
 import org.eclipse.emf.ecore.EAttribute
+import java.util.List
+import java.util.Collections
 import org.eclipse.papyrus.robotics.ros2.preferences.Ros2PreferenceUtils
 
 /**
@@ -28,12 +29,29 @@
 class PackageXMLUtils {
 
 	/**
-	 * get author name. If authorship is set, assume that it starts with an email address
+	 * Return the description of a model from the Entity stereotype
 	 */
-	def static getAuthorName(Package model) {
-		val author = getField(model, BPCPackage.eINSTANCE.entity_Authorship);
+	static def description(List<Package> modelList) {
+		val description = getField(modelList, BPCPackage.eINSTANCE.entity_Description);
+		if (description !== null) {
+			return description
+		}
+		return "No description"
+	}
+
+	static def description(Package model) {
+		return description(Collections.singletonList(model))
+	}
+
+	/**
+	 * get author name. If authorship is set and contains a space, assume that it starts with an email address
+	 * @param modelList a list of models (belonging to the same ROS2 package) - take
+	 *		information from first model with non-null information
+	 */
+	def static getAuthorName(List<Package> modelList) {
+		val author = getField(modelList, BPCPackage.eINSTANCE.entity_Authorship);
 		if (author !== null) {
-		val idx = author.indexOf(" ");
+			val idx = author.indexOf(" ");
 			if (idx > 0) {
 				return author.substring(idx + 1);
 			}
@@ -42,8 +60,17 @@
 		return Ros2PreferenceUtils.authorName;
 	}
 
-	def static getAuthorMail(Package model) {
-		val author = getField(model, BPCPackage.eINSTANCE.entity_Authorship);
+	def static getAuthorName(Package model) {
+		return getAuthorMail(Collections.singletonList(model))
+	}
+
+	/**
+	 * get author mail. If authorship is set and contains a space, assume that it starts with an email address
+	 * @param modelList a list of models (belonging to the same ROS2 package) - take
+	 *		information from first model with non-null information
+	 */
+	def static getAuthorMail(List<Package> modelList) {
+		val author = getField(modelList, BPCPackage.eINSTANCE.entity_Authorship);
 		if (author !== null) {
 			val idx = author.indexOf(" ");
 			if (idx > 0) {
@@ -54,8 +81,18 @@
 		return Ros2PreferenceUtils.authorMail;
 	}
 
-	def static getMaintainerName(Package model) {
-		val maintainer = getField(model, BPCPackage.eINSTANCE.entity_Provenance);
+	def static getAuthorMail(Package model) {
+		return getAuthorMail(Collections.singletonList(model))
+	}
+
+	/**
+	 * Get maintainer name. If maintainer is set and contains a space, assume that it starts with an email address
+	 * Take maintainer information from provenance field in RobMoSys
+	 * @param modelList a list of models (belonging to the same ROS2 package) - take
+	 *		information from first model with non-null information
+	 */
+	def static getMaintainerName(List<Package> modelList) {
+		val maintainer = getField(modelList, BPCPackage.eINSTANCE.entity_Provenance);
 		if (maintainer !== null) {
 			val idx = maintainer.indexOf(" ");
 			if (idx > 0) {
@@ -66,8 +103,18 @@
 		return Ros2PreferenceUtils.maintainerName;
 	}
 
-	def static getMaintainerMail(Package model) {
-		val maintainer = getField(model, BPCPackage.eINSTANCE.entity_Provenance);
+	def static getMaintainerName(Package model) {
+		return getMaintainerName(Collections.singletonList(model))
+	}
+
+	/**
+	 * Get maintainer mail. If maintainer is set and contains a space, assume that it starts with an email address
+	 * Take maintainer information from provenance field in RobMoSys
+	 * @param modelList a list of models (belonging to the same ROS2 package) - take
+	 *		information from first model with non-null information
+	 */
+	def static getMaintainerMail(List<Package> modelList) {
+		val maintainer = getField(modelList, BPCPackage.eINSTANCE.entity_Provenance);
 		if (maintainer !== null) {
 			val idx = maintainer.indexOf(" ");
 			if (idx > 0) {
@@ -78,27 +125,27 @@
 		return Ros2PreferenceUtils.maintainerMail;
 	}
 
+	def static getMaintainerMail(Package model) {
+		return getMaintainerMail(Collections.singletonList(model))
+	}
+
 	/**
-	 * return the first occurrence of the non-null field (author or maintainer) in the
-	 * ownership tree
-	 *
-	 * @param element
-	 *            a UML element
-	 * @param clazz
-	 *            The stereotype in form of a class (static profile)
-	 * @return the author information
+	 * return the first non-null field (feature) from the Entity stereotype
+	 * from a list of packages
+	 * 
+	 * @param modelList
+	 *            a list of packages (root of models)
+	 * @param feature
+	 *            The feature to query
+	 * @return the author/maintainer/... information
 	 */
-	def static String getField(Element element, EAttribute feature) {
-		val application = UMLUtil.getStereotypeApplication(element, Entity);
-		if (application !== null && application.eGet(feature) !== null) {
-			return application.authorship;
-		} else {
-			val owner = element.getOwner();
-			if (owner !== null) {
-				return getField(owner, feature);
-			} else {
-				return null;
+	def static String getField(List<Package> modelList, EAttribute feature) {
+		for (pkg : modelList) {
+			val application = UMLUtil.getStereotypeApplication(pkg, Entity);
+			if (application !== null && application.eGet(feature) instanceof String) {
+				return application.eGet(feature) as String;
 			}
 		}
+		return null
 	}
 }